qid
int64
1
74.7M
question
stringlengths
0
70k
date
stringlengths
10
10
metadata
list
response
stringlengths
0
115k
4,171,140
I was working on a problem and faced a this system of equations ($y\_i$ and $x\_i$ are givens) $$ y\_i = \sum\_{j=0}^{n} c\_j e^{jx\_i} \quad0 \le i \le n$$ is there a way to determine this system is solvable or not?
2021/06/12
[ "https://math.stackexchange.com/questions/4171140", "https://math.stackexchange.com", "https://math.stackexchange.com/users/598860/" ]
You get exactly one solution if you have $y\_i,x\_i$ for $i=0,\dots,n$ (rather than $1,\dots,n$) and the values $z\_i=e^{x\_i}$ are distinct. (If the $x\_i$ are real, this is equivalent to the $x\_i$ being distinct.) If you do have $n+1$ equations consider the $(n+1)\times(n+1)$ [Vadermonde matrix](https://en.wikipedia.org/wiki/Vandermonde_matrix): $$V=(v\_{ij})\_{i,j=0}^n=(z\_i^j)=(e^{jx\_i})$$ Then you are seeking the solution to: $$V\begin{pmatrix}c\_0\\c\_1\\\vdots\\c\_n\end{pmatrix}=\begin{pmatrix}y\_0\\y\_1\\\vdots\\y\_n\end{pmatrix}$$ But if the $z\_i$ are distinct, then $V$ is invertible, and you get: $$\begin{pmatrix}c\_0\\c\_1\\\vdots\\c\_n\end{pmatrix}=V^{-1}\begin{pmatrix}y\_0\\y\_1\\\vdots\\y\_n\end{pmatrix}$$ So, as your question is stated, given $y\_i,x\_i$ for $i=1,\dots,n$ with $e^{x\_i}$ distinct, then you can get infinitely many solutions by picking any pair $x\_0,y\_0$ so that the $e^{x\_0}$ is distinct from the other $e^{x\_i}.$ Or, alternatively, you can find a unique solution where $c\_n=0$ using $i=1,\dots,n.$ You can get a solution when the $z\_i$ are not distinct, but only if $y\_i=y\_j$ whenever $z\_i=z\_j.$
53,116,703
I've got a class using two generic parameters in its constructor. I would like to implement a method to compare two instances of this class, as done in the code below. It works quite well except when one of the parameter is an arrays. I've read different topics about how to compare arrays with `java.util.Arrays.equals(Object[] a, Object[] a2)` but as my parameters are not defined as arrays, I can't use this method. How could return "true" in the content of my array is the same? Or is it possible to cast my parameters to use `java.util.Arrays.equals(Object[] a, Object[] a2)`? ``` public class Pair<U, V> { public final U first; public final V second; public Pair(U first, V second) { this.first = first; this.second = second; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair<?, ?> myPair= (Pair<?, ?>) o; if (!first.equals(myPair.first) || !second.equals(myPair.second)) return false; return true; } } ```
2018/11/02
[ "https://Stackoverflow.com/questions/53116703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6061004/" ]
``` @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair<?, ?> myPair = (Pair<?, ?>)o; if (first.getClass().isArray() ^ first.getClass().isArray() || second.getClass().isArray() ^ second.getClass().isArray()) return false; return deepEquals(first, myPair.first) && deepEquals(second, myPair.second); } private static boolean deepEquals(Object one, Object two) { if (one instanceof byte[]) return Arrays.equals((byte[])one, (byte[])two); if (one instanceof char[]) return Arrays.equals((char[])one, (char[])two); if (one instanceof short[]) return Arrays.equals((short[])one, (short[])two); if (one instanceof int[]) return Arrays.equals((int[])one, (int[])two); if (one instanceof long[]) return Arrays.equals((long[])one, (long[])two); if (one instanceof boolean[]) return Arrays.equals((boolean[])one, (boolean[])two); if (one instanceof float[]) return Arrays.equals((float[])one, (float[])two); if (one instanceof double[]) return Arrays.equals((double[])one, (double[])two); if (one instanceof Object[]) return Arrays.equals((Object[])one, (Object[])two); return one.equals(two); } ```
5,629,495
im a newbie in android. I would like to ask if anybody knows why i'm getting this "connection refused" IOException when i try to establish a TCP/IP connection between two android device. I tried to ping both device and they are responding. Anybody please... Thanks in advance... ``` E/TCP_IP connect thread( 7466): java.net.ConnectException: /192.168.4.100:8080 - Connection refused E/TCP_IP connect thread( 7466): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:254) E/TCP_IP connect thread( 7466): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:219) E/TCP_IP connect thread( 7466): at java.net.Socket.startupSocket(Socket.java:781) E/TCP_IP connect thread( 7466): at java.net.Socket.<init>(Socket.java:316) E/TCP_IP connect thread( 7466): at com.neugent.WIFI.TCP_IP$ConnectThread.run(TCP_IP.java:291) ```
2011/04/12
[ "https://Stackoverflow.com/questions/5629495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/692101/" ]
If it's the missing INTERNET permission, add this line to your `Android.manifest` file just above the `<application>` tag. `<uses-permission android:name="android.permission.INTERNET/>`
45,631,132
The flag `CF` is set when we compare two digits and one number is less than another: ``` mov eax,1 cmp eax,2 jb truWay ``` In binary form: ``` 1=00000001 2=00000010=11111101+1(add. code)=11111110и 00000001+11111110=11111111(no carry) ``` Why does instruction `cmp eax,2` set the `CF` flag? There was no carry, or I'm wrong.
2017/08/11
[ "https://Stackoverflow.com/questions/45631132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2667757/" ]
You can refer to [these slides](http://web.cse.ohio-state.edu/~teodorescu.1/download/teaching/cse675.au08/Cse675.02.F.ALUDesign_part1.pdf) to understand how subtraction is performed in an ALU. While it is true that A - B = A + (-B) and that in two's complement this is A + ¬B + 1, this consideration accounts for the result only. A subtracter implemented with half-adders takes the form               [![A subtracter implemented with half-adders, note the inverted output carry](https://i.stack.imgur.com/0C4Ni.png)](https://i.stack.imgur.com/0C4Ni.png) Note that the *CarryOut* bit is inverted. You can check that this is necessary and correct by taking your example (limiting the size to 4 bits): 1 - 2 = 1 + (-2) = 0001b + 1110b = 0|1111b since ¬0 = 1 we have a borrow while for 2 - 1 one has 2 - 1 = 2 + (-1) = 0010b + 1111b = 1|0001b since ¬1 = 0 we have no borrow So in your example, there is a borrow, and thus CF is set, exactly because 0001b + 1110b produces no carry. For a more formal proof of the correctness of the inverted carry out flag, once can use induction on the number of bits. *Base case* *n = 1* This can be proven with a truth table ``` a b a-b (a+¬b+1) ¬carryOut Expected borrow 0 0 0+1+1 = 1|0 0 0 0 1 0+0+1 = 0|1 1 1 1 0 1+1+1 = 1|1 0 0 1 1 1+0+1 = 1|0 0 0 ``` *Induction case* When subtracting two n-bit numbers A = an an-1 ... a0 and B = bn bn-1 ... b0 we can have A > B, A < B or A = B. In the first case there is a *k* such that ak < bk and aj = bj for all *j* > *k* up to *n*. The condition ak < bk implies ak = 0 and bk = 1. Thus A and ¬B are equal down to the *k-1*-th bit so only this many bits influence the carry out. But by the induction hypothesis, the carry out is correct, so it is correct in this case too. The same process goes for the case A > B. The case A = B is easier as the whole operation is reduced to A + ¬A + 1 which reduces to 111...1 + 1 that always produces a carry out and thus no borrow.
55,935,015
i was trying to convert from a char array to integers and the atoi function is working properly except when i put a zero in the first index...it didn't print it ``` #include<iostream> using namespace std; int main() { char arr[]= "0150234"; int num; num=atoi(arr); cout << num; return 0; } ``` I expect the output of 0150234 but the actual output is 150234
2019/05/01
[ "https://Stackoverflow.com/questions/55935015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9560780/" ]
I think inside the atoi function you have typecasted the string to integer because of which the 0 gets removed. You can never get a 0 printed before a number since it doesn't make sense. 000001 will always be represented as 1. I hope this clears your doubt.
5,020,203
I am attempting to add a new record to a table similar to the example listed below. When I run the query I get the following error: QODBC3: Unable to bind variable. What do I need to do to correct the error? ``` QSqlQuery query; query.prepare("INSERT INTO Table (id, val, time) VALUES (:id, :val, :time)"); query.bindValue(":id", 1); query.bindValue(":val", "23"); query.bindValue(":time", QTime(8, 0)); query.exec(); ```
2011/02/16
[ "https://Stackoverflow.com/questions/5020203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/241060/" ]
I would guess it doesn't know how to bind the QTime object. Should you be using the toString method?
2,301,474
Is there $A \subset \mathbb{R}^n$, such that $A$ is compact, contains the origin and has measure zero? I know that the finite set A, of the form $A=\{ x\_{1},...,x\_{n} \}$, is a set of measure zero, but I don't know about its compactness nor if one can include the element zero amoung its elements.
2017/05/29
[ "https://math.stackexchange.com/questions/2301474", "https://math.stackexchange.com", "https://math.stackexchange.com/users/443436/" ]
A non-trivial one would be the standard Cantor set in $\mathbb{R}^n$. It's closed, bounded (contained in the unit rectangle $[0,1]^n$, thus compact. It also contains the origin and is of measure zero.
52,468
Recently I watched a documentary film from "Star Media" (a Russian film) called "The First World War". Up to this moment, I thought that the February Revolution happened because there was a huge economic problem and people were living in very poor conditions. Now I understand that the world war contributed to this problem (but I hadn't thought about it before). According to the film (and I believe it's true), the Bolsheviks signed a peace treaty with very bad terms for the Russian Empire (the Russian Empire had to pay reparations and lost some territories). So now I'm confused: How did the Bolshevik leader become so popular in Russia and have a lot of monuments?
2019/05/05
[ "https://history.stackexchange.com/questions/52468", "https://history.stackexchange.com", "https://history.stackexchange.com/users/37707/" ]
This contains several questions. First, why was Lenin (more exactly, his party) popular in 1918-1922. The short answer is "because they distributed landowners land among peasants" (Only to seize it back after 15 years of dictatorship). They also stopped the unpopular war (by surrender) and declared the right of nations for self-determination (only to conquer most of them back within 2 years). Second, why was he popular after his death, and until now. Because his successors who established a dictatorship in the country with total control and huge propaganda apparatus created a cult of Lenin. They, the ruling party, not the people, erected all those monuments. For several generations the population was intensively brainwashed (and the part of it which resisted brainwashing was physically exterminated). These rulers maintained the cult of Lenin which exists (to a smaller extent) even now. In the independent Ukraine people destroyed all monuments to Lenin in a short period since 2014. But another revolution (of 2014) was necessary to make this possible. You may compare this with the cult of Mao. His rule led to death of more people than Stalin and Hitler combined, and completely ruined the economy. Still his cult exists. Because the party created by Mao still rules in China.
60,511,619
here is my code ``` ArrayList <String> arr = new ArrayList<String>(); arr.add("123 456"); String []arr2 = arr.get(0).split(" "); char[]x=arr2[0].toCharArray(); char[]y=arr2[1].toCharArray(); System.out.println(x[0]); System.out.println(y[0]); int z = x[0]+y[0]; System.out.println(z); ``` i get a result of 1 6 but the z is 103 how is that possible when ``` char xx=1; char yy=6; int zz = xx+yy; System.out.println(zz); ``` results to 7
2020/03/03
[ "https://Stackoverflow.com/questions/60511619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12379338/" ]
Why are you adding char primitives? If you're trying to concatenate, it works only within String objects, or between String and primitives. <https://docs.oracle.com/javase/tutorial/java/data/strings.html> In case you're wondering why you get those results, char is sort of a compatible primitive with int, so they can be sum (they will return the sum of the ascii values corresponding to the characters). <http://www.asciitable.com/> Here you can check the values for your chars, but I don't think this is what you want to do.
34,931,506
I have the following strings: One Rule : Get all consecutive Square bracket strings : for example, > > string 1 : [hello][qwqwe:]sdsdfsdf [note2] > string 2 : > [somethingelse]sdfsdf [note 1] > string 3 : aasdad[note 3] > > > I would like to get the substrings : > > output 1 : [hello][qwqwe:] > output 2 : [somethingelse] > output > 3 : > > > If the string doesn't have square brackets, I do not want an output. If the string has a square bracket delimited string which is not consecutive, it should not match aswell. I tried using the regex expression > > ([.\*])\* > > > But it matches everything between two square brackets. If you notice the first string, I do not need the part of the string that violates my rule.
2016/01/21
[ "https://Stackoverflow.com/questions/34931506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3488682/" ]
Approach 1: Matching multiple consecutive `[...]`s at string start *as a single string* ======================================================================================= You need to use the following regex: ``` ^(\[[^]]*])+ ``` See [regex demo](http://regexstorm.net/tester?p=%5e(%5c%5b%5b%5e%5d%5d*%5d)%2b&i=%5bhel%5b%5b%5blo%5d%5bqwq%5b%5b%5bwe%3a%5dsdsdfsdf+%5bnote2%5d+%0d%0a%5bsomethingelse%5dsdfsdf+%5bnote+1%5d+%0d%0aaasdad%5bnote+3%5d&o=nm) The `^(\[[^]]*])+` matches: * `^` - start of string (in the demo, it matches at line start due to the multiline modifier) * `(\[[^]]*])+` - captured into Group 1 (you can access all of those values via `.Groups[1].Captures` collection) one or more occurrences of... + `\[` - a literal `[` + `[^]]*` - zero or more characters other than `]` + `]` - a literal `]`. [C# code demo](http://ideone.com/fYxnE4): ``` var txt = "[hello][qwqwe:]sdsdfsdf [note2]"; var res = Regex.Match(txt, @"^(\[[^]]*])+"); // Run the single search Console.WriteLine(res.Value); // Display the match var captures = res.Groups[1].Captures.Cast<Capture>().Select(p => p.Value).ToList(); Console.WriteLine(string.Join(", ", captures)); // Display captures ``` Approach 2: Matching multiple consecutive `[...]`s at string start *separately* =============================================================================== You can use `\G` operator: ``` \G\[[^]]*] ``` See [regex demo](http://regexstorm.net/tester?p=%5cG%5c%5b%5b%5e%5d%5d*%5d&i=%5bhel%5b%5blo%5d%5bqwq%5b%5bwe%3a%5dsdsdfsdf+%5bnote2%5d+) It will match the `[...]` substrings at the start of the string and then after each successful match. **Regex explanation**: * `\G` - a zero-width assertion (anchor) matching the location at the beginning of a string, or after each successful match * `\[[^]]*]` - a literal `[` (`\[`) followed by zero more (`*`) characters other than a `]`, followed by a closing `]`. If you need to return a single string of all `[...]`s found at the beginning of the string, you need to concatenate the matches: ``` var txt = "[hello][qwqwe:]sdsdfsdf [note2]"; var res = Regex.Matches(txt, @"\G\[[^]]*]").Cast<Match>().Select(p => p.Value).ToList(); Console.WriteLine(string.Join("", res)); ``` See [IDEONE demo](http://ideone.com/WnrVKZ)
13,004,202
I am using [PyContract](http://pypi.python.org/pypi/contract/1.4) (not [PyContracts](http://pypi.python.org/pypi/PyContracts/1.4.0)) to implement design-by-contracts for my genetic algorithms framework. The main module is `GA.py`, which calls a function from `crossover.py` (let's call it `foocross`). I have written precondition and postcondition expressions for `foocross`. Now, I would like those conditions to be checked when I run the `main` in GA.py. I introduced a false precondition in `foocross` just to test if the contracts were being checked, but it seems that they are not. How do I make sure that the contracts are being checked? Here's a minimal section of my code: ``` # GA.py def main(): # some code crossover.foocross(params) # some more code if __name__ == "__main__": main() #crossover.py def injectionco(p1, p2, chrom): """ pre: isinstance(p1, int) # this should raise an error. p1 is never an int isinstance(p2, list) isinstance(chrom, int) forall(p1, lambda elem: any(isinstance(elem, i.__class__) for i in p2)) forall(p2, lambda elem: any(isinstance(elem, i.__class__) for i in p1)) len(p1) == len(p2) post: p1 is __old__.p1 p2 is __old__.p2 p1 == __old__.p1 p2 == __old__.p2 isinstance(__return__, p1.__class__) # returns an individual len(__return__) == len(p1) id(__return__) not in [id(p1), id(p2)] forall(__return__, lambda elem: __return__.count(elem) == 1) """ #code return #something ``` PS: this was a pretty difficult question for me to write because I had to strip out a LOT of my code (since the framework is pretty complex) and I'm new to design-by-contract. So if I've missed out on some information that would help answer this question, please ask and I'll happily provide more info :)
2012/10/22
[ "https://Stackoverflow.com/questions/13004202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/198633/" ]
It's a very simple mechanism that was introduced sometime around iBooks 1.5+, and finally made available to use all with the addition of the `+[UIScreen brightness]` API in iOS 5. Because it accepts a simple float from 0.0-1.0, storing it is a no-brainer, and restoring it can be done in any of the UIApplication delegate methods trivially. In fact, I wrote a sample app (OOH, [Shiny](http://dl.dropbox.com/u/54072935/Shiny.zip)) which restores screen brightness on launch, and saves it on exit.
38,729,273
I'm looking for a way to colorize the output from `./configure` so that all instances of `yes` at the end of a check show in one color and `no` in another. I think there may be a way of creating the echo message using `AS_IF` to test the check result and then set the output using the usual bash color commands. I'd obviously prefer to not have to spend time doing this if it's already been done.
2016/08/02
[ "https://Stackoverflow.com/questions/38729273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1825933/" ]
Lucky for you, Autoconf is basically one giant C-preprocessor-abuse, so its internals are all exposed and it's easy to do something hacky that, fair warning, might not carry over from one Autoconf version to the next. The definition of `AC_MSG_RESULT` (which prints most of those yes/no messages) is found in `/usr/share/autoconf/autoconf/general.m4`, and is quite simply defined as printing a given message to the log file as well as to the terminal: ``` m4_define([AC_MSG_RESULT], [{ _AS_ECHO_LOG([result: $1]) _AS_ECHO([$1]); }dnl ]) ``` Since the Autoconf internals called in that macro are exposed to your configure.ac, you can just override `AC_MSG_RESULT` with your own macro that calls them. Here's one that worked for me, printing "yes" in green, "no" in red, and all other results in blue. Include it before any other macro calls in your configure.ac: ``` m4_pushdef([AC_MSG_RESULT], [ { result="$1" _AS_ECHO_LOG([result: $result]) AS_CASE(["x$result"], [xnone\ needed], _AS_ECHO([$(tput setaf 4)$result$(tput sgr0)]), [xyes*], _AS_ECHO([$(tput setaf 2)$result$(tput sgr0)]), [xno*], _AS_ECHO([$(tput setaf 1)$result$(tput sgr0)]), _AS_ECHO([$(tput setaf 4)$result$(tput sgr0)])); }dnl ]) ``` But seriously, don't do this.
58,811,959
I have been using the code below to send sms to customers telling them their account balances after a given period. so far the code is able to send sms to one person at a time. Can i modify the code to send the message to all customers. ``` <?php function sendsms($sms_username,$sms_password,$sender_ID,$number,$message) { if(isset($sms_username) && isset($sms_password)) { $username = trim($sms_username);//your sms user account $password = trim($sms_password);//your sms password $type = '0';//FOR FLASH MESSAGES SET type to 1 $dlr = '1';//request for delivery report $destination = $number;;//phone number $source = urlencode($sender_ID);//This is the sender or label that will be received by client/user. MAXIMUM 11 CHARACTERS $message = urlencode("$message");//message content to be sent to user/client //Form url api $url = "https://api.sendingthesms/bulksms/?username=" .$username."&password=".$password."&type=0&dlr=1&destination=".$destination."&source=".$source."&message=" . $message; $scc = stream_context_create(array('http' => array('protocol_version' => 1.1)));//enforce http 1.1 $response = file_get_contents("$url",0,$scc);//fire/call nalo sms api return $response; }else { return "username cannot be empty"; } } echo sendsms("username","mypassword","$session_username",$mainphone3, $mysms); header("location:index.php"); exit; ?> ```
2019/11/12
[ "https://Stackoverflow.com/questions/58811959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12358842/" ]
-First, you can change your if statement with the condition if your loop at the first character in the phrase and meets a space. -Second, you can change how the way you swap from this : ``` phrase[i] = temp; phrase[i] = phrase[j]; phrase[j] = temp; ``` with this : ``` temp = phrase[i]; phrase[i] = phrase[j]; phrase[j] = temp; ```
15,384,108
I have a SSIS package where1 record (hard coded) flow through. ![enter image description here](https://i.stack.imgur.com/pPzEg.png) I have variable in DFT scope. ![enter image description here](https://i.stack.imgur.com/dw2of.png) I assign value to variable using Row Count Transaformation. ![enter image description here](https://i.stack.imgur.com/Azv3P.png) The value should be 1 i verify it by using script component. ``` public override void PostExecute() { System.Windows.Forms.MessageBox.Show(ReadWriteVariables[0].Value.ToString()); base.PostExecute(); /* Add your code here for postprocessing or remove if not needed You can set read/write variables here, for example: Variables.MyIntVar = 100 */ } ``` I look for zero condition through condition in Conditional split transformation. ![enter image description here](https://i.stack.imgur.com/EUP2H.png) Strangely it satisfies equal to zero condition whrease I think it should have value 1. Even Messagebox through script component shows value 1. ![enter image description here](https://i.stack.imgur.com/trIke.png) what could be the reason? Are value in varible realize only towards end of DFT or Conditional Split has some problem reading correct value or something else which i am not able to think up?
2013/03/13
[ "https://Stackoverflow.com/questions/15384108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1318701/" ]
The value for `variable` being assigned inside a `data flow task` can't be used in the `split transformation` or later in the Data Flow task . The values generally get `populated` once DFT gets `completed` . ``` Variable values does not update during the execution of Data Flow task ``` Even though you are able to see `value 1` or set some other value to `Variable` from script transformation in post or pre execution events ,these values gets effected only after the execution of `DFT` Hence the updated value can be used in precedence constraint or other tasks in control flow . Read [this](http://microsoft-ssis.blogspot.in/2011/02/how-to-skip-trailer-records.html) article .
21,816,052
How can I have the same effect in iOS `UITextView` like below image. Blur effect from the bottom of `UITextView` ![Gradient at the bottom of UItextView](https://i.stack.imgur.com/udcaL.png) Thanks in Advance :)
2014/02/16
[ "https://Stackoverflow.com/questions/21816052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1520570/" ]
Try the following: I tried the following with image but not UITextView ``` UIView *vwTest = [[UIView alloc] initWithFrame:_textView.frame]; [vwTest setBackgroundColor:[UIColor whiteColor]]; [vwTest setUserInteractionEnabled:NO]; [self.view addSubview:vwTest]; NSArray *colors = [NSArray arrayWithObjects: (id)[[UIColor colorWithWhite:0 alpha:1] CGColor], (id)[[UIColor colorWithWhite:0 alpha:0] CGColor], nil]; CAGradientLayer *layer = [CAGradientLayer layer]; [layer setFrame:vwTest.bounds]; [layer setColors:colors]; [layer setStartPoint:CGPointMake(0.0f, 1.0f)]; [layer setEndPoint:CGPointMake(0.0f, 0.6f)]; [vwTest.layer setMask:layer]; ```
476,176
I want to ask what is the little numbers on top/over any random number? For example, 75 in² and 125 ft3. What is it called and what does it mean is my question. I couldn't find anything online since I don't know what it is called.
2018/12/08
[ "https://english.stackexchange.com/questions/476176", "https://english.stackexchange.com", "https://english.stackexchange.com/users/318987/" ]
In terms of formatting, numbers and letters that appear in the top half of a line are in *superscript*. Similarly, numbers in the bottom half of a line would be called *subscript*. "Super" and "sub" describe their position over or under the main text. In your examples, these superscript numbers stand for a mathematical exponent or power as applied to a unit of measurement. If I were reading it out loud, I might say "seventy-five inches squared," or (more clearly) "seventy-five square inches." It means that I am talking about a unit of distance extending in two dimensions. It's a measurement of surface area, just like houses can be measured in square feet (ft2) and land can be measured in square miles (mi2). The cubic version (in3) would refer to a measurement across three dimensions, or a measurement of volume. Other measurements can also be squared or cubed, especially when doing calculations in STEM fields, but square inches/feet/miles are the most common examples of this in the US.
38,237
For example, we always assumed that the data or signal error is a Gaussian distribution? why? I have asked this question on stackoverflow, the link: <https://stackoverflow.com/questions/12616406/anyone-can-tell-me-why-we-always-use-the-gaussian-distribution-in-machine-learni>
2012/09/29
[ "https://stats.stackexchange.com/questions/38237", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/14477/" ]
I looked at the answers on SO. I don't think they are satisfactory. People often argue for the normal distribution because of the central limit theorem. That may be okay in large samples when the problem involves averages. But machine learning problems can be more complex and sample sizes are not always large enough for normal approximations to apply. Some argue for mathematical convenience. That is no justification especially when computers can easily handle added complexity and computer-intensive resampling approaches. But I think the question should be challenged. Who says the Guassian distribution is "always" used or even just predominantly used in machine learning. Taleb claimed that statistics is dominated by the Gaussian distribution especially when applied to finance. He was very wrong about that! In machine learning aren't kernel density classification approaches, tree classifiers and other nonparametric methods sometimes used? Aren't nearest neighbor methods used for clustering and classification? I think they are and I know statisticians use these methods very frequently.
33,502,647
I have successfully generated EF classes for a remote MySQL database, with a resulting `.edmx`object that contains the `Context` and table-associated C# classes. I built the application and tried to add the EF classes as object data sources, but the wizard only displays the `Properties` namespace and its contents. [![DataSourceWizard](https://i.stack.imgur.com/H5bOj.png)](https://i.stack.imgur.com/H5bOj.png) The same happens when I tried writing a static property that uses the generated classes. The data source wizard doesn't display any other namespace. What am I missing? Thanks.
2015/11/03
[ "https://Stackoverflow.com/questions/33502647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/374253/" ]
Apparently there's a bug in Visual Studio. I reverted to .NET framework 4.5.2 from 4.6 and the data sources reappeared.
376,572
How electrical energy can be power over time when electrical energy is actually potential energy? from a lot of sources (wiki ,study.com..) comes the information that electric energy is potential or kinetic energy. In other sources is said to be electric power p x t so i am confused by this if anyone could explain to me what was right.
2017/12/27
[ "https://physics.stackexchange.com/questions/376572", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/179787/" ]
> > Would not air pressure keep the paper pressed against the book's cover? > > > To an extent, possibly. This is not the main reason why it is done though; although it does relate to your newspaper-ruler example. The reason would be to minimize the effects of air drag on the piece of paper. Although all objects influenced the same by gravity; they react differently with the air. A piece of paper would fall a lot slower than the book if they were both exposed to air drag. Instead; the piece of paper avoids the drag by travelling in the streamline of the book. Realistically, if the piece of paper were to fall slower than the book under the influence of gravity (due to lower mass) then even with the air pressure, it should still slowly separate from the book. (the reason the ruler breaks in the newspaper experiment is because you are trying to act against the pressure *very quickly*). Either way; this isn't really a great experiment to demonstrate how different masses react the same to gravitational force. Both the book and the paper have very large areas; therefore the drag force is substantial. To eliminate the drag force they set up the experiment in a way that pressure differences could keep the paper and the book falling with similar speeds, even if gravity was acting unevenly. Really, this test should be done in a vacuum to eliminate this source of potential error. It's a good sign that you can *recognize* this error in the experiment. Noticing details like this is important when designing good experiments.
6,740,655
I'm having a problem doing a request using Typhoeus as my query needs to have quotation marks into it. If the URl is ``` url = "http://app.com/method.json?'my_query'" ``` everything works fine. However, the method I'm trying to run only returns the results I want if the query is the following (i've tested it in browser): ``` url2 = "http://app.com/method.json?"my_query"" ``` When running ``` Typhoeus::Request.get(url2) ``` I get (URI::InvalidURIError) Escaping quotes with "\" does not work. How can I do this? Thanks
2011/07/18
[ "https://Stackoverflow.com/questions/6740655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/558452/" ]
You should be properly encoding your URI with [`URI.encode`](http://ruby-doc.org/stdlib/libdoc/uri/rdoc/classes/URI/Escape.html#M009396) or [`CGI.escape`](http://ruby-doc.org/stdlib/libdoc/cgi/rdoc/classes/CGI.html#M000093), doing so will get you proper URLs like this: ``` http://app.com/method.json?%27my_query%27 # Single quotes http://app.com/method.json?%22my_query%22 # Double quotes ```
29,952
I've not seen a lot of material on this. I've seen people attempting to bring a C++ program back to C++ code, and claiming how hard it is, but C code from C++ program? I don't know. If it is *possible,* what obstacles would be in the way? If *impossible,* what particular features make it so?
2022/01/29
[ "https://reverseengineering.stackexchange.com/questions/29952", "https://reverseengineering.stackexchange.com", "https://reverseengineering.stackexchange.com/users/40222/" ]
If you're asking whether it's possible for an automated decompiler to produce C code as output for a given C++ input binary (rather than producing C++ code as output), the answer is that most decompilers are going to do this anyway, and are not going to give you a choice as to which language they produce as output. Machine-code decompilers generally produce a C-like pseudocode, which, in general, cannot be immediately recompiled to C code. A better question would be "to what extent can the C-like pseudocode produced by decompilers represent features of C++ that are not in C", to which the answer depends on the specific decompiler in question. If you're asking whether it's possible to manually decompile a C++ program into a C program, the answer is yes. Just as you can take a program written in C++ and manually translate it into C, you can manually decompile a binary into any language you want. There's going to be a lot of manual work regardless of which language you choose to decompile the program into. Although C and C++ are not the same language, the first C++ compilers worked by translating C++ code into C code, and using a regular C compiler on the result (see: CFront <https://en.wikipedia.org/wiki/Cfront>). You can simulate most C++ constructs in C, although it's going to be a lot more work than simply taking advantage of the features introduced by C++.
4
I am looking for a starting point for my project, preferably using popular systems (ones there is a lot of support for). I have an Arduino Uno, a Raspberry Pi, and a lot of willpower :) Anyone here built a project using the systems above? Observation: I'd like to start with a simple line-following vehicle and build up afterwards.
2012/10/23
[ "https://robotics.stackexchange.com/questions/4", "https://robotics.stackexchange.com", "https://robotics.stackexchange.com/users/32/" ]
The Arduino is really an AVR Atmega328p. The Arduino is a fine off-the-shelf implementation of this microcontroller, but if you make many of them, you can buy the chip for less than $3 each in bulk, and it requires very little circuitry to run on its own -- a crystal and a couple of capacitors to run at 20 Mhz, or not even that if you can run at the built-in 8 MHz resonant oscillator frequency. It's fine for generating control signals: Servo PWM, step/direction, control for H-bridges, etc.) It's also OK for running sensors: Ultrasonic time measurement, IR voltage conversion measurement, on/off contactors, etc -- this includes whatever optical sensor you'd use for "line sensing." There will be a little code space left over after doing these tasks, so the simple control loop of "is the line to the right, left, or center of me -> do the appropriate turn" can be built into that system. However, as soon as you want to do something bigger, like path planning, environmental awareness, memory, SLAM, etc, you will not be able to fit that into the Arduino. Thus, the best system for your requirements probably includes tying all the physical hardware to the Arduino, and then talking to the Arduino from the Raspberry Pi. The RPi has a modicum of CPU power (700 MHz ARM) and RAM (256-512 MB RAM) and thus can run higher-level control algorithms like path planning, localization, SLAM, etc. If you go with a bare AVR controller, there are UART outputs on the Raspberry Pi, but the problem is that the RPi is 3.3V and the Arduino Uno is 5V. Either go with a 3.3V Arduino version, or use a voltage divider to step down 5.0V output from the Arduino to the 3.3V input of the Raspberry Pi. I use a 2.2 kOhm high and 3.3 kOhm low resistor and it works fine. You can feed the 3V output from the Raspberry Pi directly into the RXD of the AVR, because it will treat anything at 1.2V or up as "high."
56,490,250
I'm trying to conditionally hide a `DatePicker` in SwiftUI. However, I'm having any issue with mismatched types: ``` var datePicker = DatePicker($datePickerDate) if self.showDatePicker { datePicker = datePicker.hidden() } ``` In this case, `datePicker` is a `DatePicker<EmptyView>` type but `datePicker.hidden()` is a `_ModifiedContent<DatePicker<EmptyView>, _HiddenModifier>`. So I cannot assign `datePicker.hidden()` to `datePicker`. I've tried variations of this and can't seem to find a way that works. Any ideas? **UPDATE** You can unwrap the `_ModifiedContent` type to get the underlying type using it's `content` property. However, this doesn't solve the underlying issue. The `content` property appears to just be the original, unmodified date picker.
2019/06/07
[ "https://Stackoverflow.com/questions/56490250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3814799/" ]
Rather than dynamically setting a variable and using it in my view, I found that I was able to hide or show the date picker this way: ``` struct ContentView : View { @State var showDatePicker = true @State var datePickerDate: Date = Date() var body: some View { VStack { if self.showDatePicker { DatePicker($datePickerDate) } else { DatePicker($datePickerDate).hidden() } } } } ``` Or, optionally, not including the date picker instead of hiding it: ``` struct ContentView : View { @State var showDatePicker = true @State var datePickerDate: Date = Date() var body: some View { VStack { if self.showDatePicker { DatePicker($datePickerDate) } } } } ```
220,614
The most basic code(i guess so) to find all the factors of a number Note:factors include 1 and the number itself Here's the code: ``` c=0 x=int(input("Enter number:")) for i in range(1,x+1): if x%i==0: print("factor",c+1,":",i) c=c+1 print("Total number of factors:",c) ``` Please make this code efficient.....ie: Help to reduce the number of iterations
2019/05/21
[ "https://codereview.stackexchange.com/questions/220614", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/200977/" ]
Just to have a more readable (than the [answer](https://codereview.stackexchange.com/a/220618/98493) by [@Justin](https://codereview.stackexchange.com/users/195671/justin)) and complete (than the [answer](https://codereview.stackexchange.com/a/220617/98493) by [@Sedsarq](https://codereview.stackexchange.com/users/201168/sedsarq)) version of the algorithm presented in the other answers, here is a version that keeps the factors in a `set` and uses the fact that factors always come in pairs: ``` from math import sqrt def get_factors(n): """Returns a sorted list of all unique factors of `n`.""" factors = set() for i in range(1, int(sqrt(n)) + 1): if n % i == 0: factors.update([i, n // i]) return sorted(factors) ``` Compared to your code this has the added advantage that it is encapsulated in a function, so you can call it repeatedly and give it a clear name and docstring describing what the function does. It also follows Python's official style-guide, [PEP8](https://www.python.org/dev/peps/pep-0008/), which programmers are encouraged to follow. With regards to which code is fastest, I'll let this graph speak for itself: [![enter image description here](https://i.stack.imgur.com/aVney.png)](https://i.stack.imgur.com/aVney.png) For the `op` function I used this code which has your checking of all factors up to `x`: ``` def op(x): factors = [] for i in range(1,x+1): if x%i==0: factors.append(i) return factors ``` And the `factors` function is from the [answer](https://codereview.stackexchange.com/a/220618/98493) by [@Justin](https://codereview.stackexchange.com/users/195671/justin). --- If all you really want is the number of factors, the best way is probably to use the prime factor decomposition. For this you can use a list of primes together with the algorithm in the [answer](https://codereview.stackexchange.com/a/220727/98493) by [@Josay](https://codereview.stackexchange.com/users/9452/josay): ``` from math import sqrt from functools import reduce from operators import mul def prime_sieve(limit): prime = [True] * limit prime[0] = prime[1] = False for i, is_prime in enumerate(prime): if is_prime: yield i for n in range(i * i, limit, i): prime[n] = False def prime_factors(n): primes = prime_sieve(int(sqrt(n) + 1)) for p in primes: c = 0 while n % p == 0: n //= p c += 1 if c > 0: yield p, c if n > 1: yield n, 1 def prod(x): return reduce(mul, x) def number_of_factors(n) return prod(c + 1 for _, c in prime_factors(n)) ``` Comparing this with just taking the `len` of the output of the `get_factors` function and this function which implements your algorithm as `op_count`: ``` def len_get_factors(n): return len(get_factors(n)) def op_count(n): c = 0 for i in range(1, n + 1): if n % i == 0: c = c + 1 return c ``` The following timings result (note the increased range compared to the previous plot): [![enter image description here](https://i.stack.imgur.com/YaTnu.png)](https://i.stack.imgur.com/YaTnu.png)
41,463
I have an arduino Uno and nodemcu development board.[![enter image description here](https://i.stack.imgur.com/vsM3q.jpg)](https://i.stack.imgur.com/vsM3q.jpg) I have an OV7076 camera and used with arduino UNO. It worked flawlessly with it and the code used is provided in the [Instructables tutorial][2] named as FromComputerNerd.ino. Now i want to use it with Nodemcu. Whereas Nodemcu have a single Analog input but OV7076 uses two analog inputs [shown in][2]. So to get it I am trying to use Multiplexer. I can change the code so that it would adjust for analog pins. But will the code be compatible with Nodemcu. Since it was written for arduino uno.If not, What changes can be done to make it compatible? <http://www.instructables.com/id/OV7670-Without-FIFO-Very-Simple-Framecapture-With-/>
2017/07/10
[ "https://arduino.stackexchange.com/questions/41463", "https://arduino.stackexchange.com", "https://arduino.stackexchange.com/users/35205/" ]
Camera doesn't send data via Analog to Arduino. A5 and A4 are I2C bus beside Analog. NodeMCU has Software I2C protocol bus too, You can use D1 (GPIO 5) as CLK, and D2 (GPIO 4) as SDA. see : <https://github.com/esp8266/Arduino/blob/master/doc/libraries.rst#i2c-wire-library>
3,539,856
> > Prove that $~a,~b~$ are integers and $~a \ge2~$, then either $~b~$ is not divisible by $~a~$ or $~b+1~$ is not divisible by $~a~$. > > > Should I use contradiction of uniqueness of prime factorisation to prove or simply prove by mathematical induction?
2020/02/09
[ "https://math.stackexchange.com/questions/3539856", "https://math.stackexchange.com", "https://math.stackexchange.com/users/749124/" ]
Assume for a contradiction that $a,b$ are integers such that $a\ge 2,$ and both $b$ and $b+1$ is divisible by $a.$ Then, $(b+1)-b=1$ must also be divisible by $a,$ a contradiction. (By definition, there exists an integer $n$ such that $an=1.$ However, since $a,1>0,$ $n$ must be greater than $0,$ or in other words, $n\ge 1.$ Thus, we have $1=an\ge a\ge 2,$ a contradiction.) Thus, either $b$ or $b+1$ is not divisible by $a.$
69,069,482
I am getting time in this format like startTime="1:00 am" and endTime="12:00 pm" how can to check if endTime>startTime . I'm using react-timekeeper component
2021/09/06
[ "https://Stackoverflow.com/questions/69069482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15682271/" ]
Well you need to check the date somehow, if you want the date to be a part of the calculation. There might be a nicer approach, but an easy one is to just loop the range and compare the date. ``` Sub Differences() Dim vRng As Range, r As Variant, vDate As String Set vRng = Range("B2", Range("B2").End(xlDown)) For Each r In vRng If r.Offset(, -1) = vDate Then r.Offset(, 3) = r - r.Offset(-1) Else r.Offset(, 3) = r End If vDate = r.Offset(, -1) Next r End Sub ```
4,173,530
What is the best way to validate a cost/price input by a user, validation rules below: * Examples of formats allowed .23, .2, 1.23, 0.25, 5, 6.3 (maximum of two digits after decimal point) * Minimum value of 0.01 * Maximum value of 9.99
2010/11/13
[ "https://Stackoverflow.com/questions/4173530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/489978/" ]
### Check the price and verify the format ``` #rails 3 validates :price, :format => { :with => /\A\d+(?:\.\d{0,2})?\z/ }, :numericality => {:greater_than => 0, :less_than => 10} #rails 2 validates_numericality_of :price, :greater_than => 0, :less_than => 10 validates_format_of :price, :with => /\A\d+(?:\.\d{0,2})?\z/ ```
23,822
I'd like to stay in the EU for some time, maybe get a residence permit if possible. The question is what are my healthcare options. As far as I know, citizens of EU countries can get public healthcare coverage. Can I get this by paying for it? Are there any alternatives for people with a residence permit yet without citizenship? Obviously, there's an option of travel insurance but I hope that for a longer stay there might be options with better or at least cheaper coverage.
2022/01/31
[ "https://expatriates.stackexchange.com/questions/23822", "https://expatriates.stackexchange.com", "https://expatriates.stackexchange.com/users/24573/" ]
That's not exactly the way it works, health insurance is typically based on residence or (mandatory) contributions. I have varying level of familiarity with the healthcare system in half-a-dozen EU countries and I do not know a single one that would offer free coverage to citizens *qua* citizens. In some cases, living and working in a country would in fact provide you with (statutory) health insurance coverage. In others, having independent health insurance coverage is a requirement to get a residence permit in the first place. Citizenship, however seldom makes a huge difference (save for the fact you can always come back even in situation where you wouldn't qualify for a residence permit).
14,520
When I am pedaling hard and shift to a larger sprocket, the shift is not smooth or sometimes doesn't happen at all. Sometimes even double up-shifts don't work. There is no problem shifting when I test for it without riding. What could be the issue?
2013/02/18
[ "https://bicycles.stackexchange.com/questions/14520", "https://bicycles.stackexchange.com", "https://bicycles.stackexchange.com/users/3925/" ]
On ground, after shifting, look at your bike from the back. The sprocket into which you have attempted to shift, and the pulley in the derailleur should be aligned. If the pulley is more to the right than sprocket, you need to get it aligned to the sprocket, by tightening in the screw on shifter or on the rear derailleur. As you tighten the screw, you should see pulley moving horizontally. If that does not help, other problem might be that your chain hanger is bent, but that happens much less often, and typically after some crash or hard hit on the rear derailleur. If that is the case, taking your bike to LBS sounds like a good idea.
316,749
> > It is now clear that no such creatures as vampires have been seen and none \_\_\_ in the world. > > > A. was found > > > B. have been found > > > I chose B, but the answer is A. I don't see the necessity to use the past tense here. Besides, allowing for that "have been seen" is already mentioned, I think it should follow some kind of rules of consistency.
2022/06/06
[ "https://ell.stackexchange.com/questions/316749", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/152414/" ]
"Creatures" is plural, so "was" cannot be used in the sentence. Therefore the answer is B. It means that no creatures such as vampires were found from the past all the way to the present.
22,535,102
This is my code: ``` XmlTextReader reader = new XmlTextReader(xmlPath); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(reader); XmlNode root = xmlDoc.DocumentElement; XmlNode node = root.SelectSingleNode("marketingid"); ``` XML that works: ``` <confirmsubmit> <marketingid>-1</marketingid> </confirmsubmit> ``` XML that doesn't work: ``` <confirmsubmit xmlns="http:...."> <marketingid>-1</marketingid> </confirmsubmit> ``` What is the way to deal with the xmlns attribute and how can i parse it? Is it has anything to do with namespace? **EDIT:** This is the code that works: ``` XmlTextReader reader = new XmlTextReader(xmlPath); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(reader); XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable); nsmgr.AddNamespace("ns", xmlDoc.DocumentElement.NamespaceURI); XmlNode book = xmlDoc.SelectSingleNode("/ns:confirmsubmit/ns:marketingid", nsmgr); ``` This all XPath is more complicated than seems, I would recommand to begginers like my to read: <http://www.w3schools.com/xpath/xpath_syntax.asp>
2014/03/20
[ "https://Stackoverflow.com/questions/22535102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2338687/" ]
You need to add a XmlNamespaceManager instance in the game, as shown in this example from the [documentation](https://msdn.microsoft.com/en-us/library/4bektfx9(v=vs.110).aspx): > > > ``` > public class Sample > { > public static void Main() > { > > XmlDocument doc = new XmlDocument(); > doc.Load("booksort.xml"); > > //Create an XmlNamespaceManager for resolving namespaces. > XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); > nsmgr.AddNamespace("bk", "urn:samples"); > > //Select and display the value of all the ISBN attributes. > XmlNodeList nodeList; > XmlElement root = doc.DocumentElement; > nodeList = root.SelectNodes("/bookstore/book/@bk:ISBN", nsmgr); > foreach (XmlNode isbn in nodeList){ > Console.WriteLine(isbn.Value); > } > > } > } > > ``` > >
9,786,515
I'm not having much success when attempting building `pgmagick` on OS X Lion with XCode 4.3.1. I've installed both ImageMagick and GraphicsMagick, along side boost, using the following commands (via homebrew): ``` $ brew install graphicsmagick --with-magick-plus-plus $ brew install imagemagick --with-magick-plus-plus $ brew install boost --with-thread-unsafe ``` then I'm cloning the repo at <https://bitbucket.org/hhatto/pgmagick>: ``` $ hg clone https://bitbucket.org/hhatto/pgmagick/src $ cd pgmagick $ python setup.py build ``` However I always receive the following error: ``` ld: library not found for -lboost_python collect2: ld returned 1 exit status ``` Based on the output on stdout, setup *is* looking in the right place for the boost (`/usr/local/lib`). I've also tried `easy_install` and `pip` but with no luck. I'm using Pythonbrew but have also disabled this and tried using the stock python install -- still no success. Any suggestions on how I can fix the problem, or further diagnose the issue?
2012/03/20
[ "https://Stackoverflow.com/questions/9786515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30478/" ]
According to my own reproduction of this issue in brew 0.9 and OSX 10.6.8, the problem is `--with-thread-unsafe` isn't being honored by the current brew formula file. You can verify this by checking the formula with `brew edit boost` and seeing if the option appears within the contents of the formula. Because of this, `libboost_python-mt.a` and `libboost_python-mt.dylib` are being built instead of `libboost_python.a` and `libboost_python.dylib`. The easiest ways to fix this are to edit your pgmagick setup.py to replace `boost_lib="boost_python"` with `boost_lib="boost_python-mt"` (as pointed out [here](https://stackoverflow.com/a/9868631/517815)) or to follow [the instructions and patch here](https://github.com/mxcl/homebrew/pull/8928). It's otherwise a known issue.
17,506,647
In my custom Wordpress theme I am trying to animate all my table "nodes" in as the page loads simultaneously. I can get this animation to work by applying the animation to each element individually but since trying to automate this process the animation fades all my nodes in at the same time and I do not understand why. The below code generates my nodes... ``` <div class="span12 news-tiles-container"> <div class="row span12 news-tiles-inner"> <?php $node_id = 1; $node_size_id = 1; ?> <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php if($node_size_id > 3) { $node_size_id = 1; } ?> <a href='<?php the_permalink(); ?>'> <div class='node node<?php echo $node_id ?> size<?php echo $node_size_id ?>' style='background-image: url(<?php the_field( 'thumbnail' ); ?>);'> <div id="news-caption" class="span12"> <p class="span9"><?php the_title(); ?></p> <img class="more-arrow" src="<?php bloginfo('template_directory'); ?>/images/more-arrow.png" alt="Enraged Entertainment logo"/> </div> </div> </a> <?php $node_size_id++; $node_id++; ?> <?php endwhile; endif; ?> </div> </div> ``` And I am using the following code to control there animate in ``` $(document).ready(function(){ // Hide all of the nodes $('.node').hide(0); // Local Variables var node_id = 1; var nodes = 10; var i = 0; while(i <= nodes) { $('.node'+node_id).hide(0).delay(500).fadeIn(1000); node_id+=1; nodes--; } }); ``` I assume it is something to do with my while loop, but the node counter increments successfully so it should be applying the animation to node1 then node2 then node3 and so on. Thanks in advance Alex.
2013/07/06
[ "https://Stackoverflow.com/questions/17506647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1020154/" ]
Use your brandy dandy `.fadeQueue()`: [working jsFiddle](http://jsfiddle.net/rARAW/) ``` $.fn.fadeQueue = function(){ $(this).fadeIn(function(){ if(!$(this).is(':last-child')) // making sure we are not done $(this).next().fadeQueue(); }); } ``` This will wait for the callback of `.fadeIn()` for each div before moving to the next one..
51,512
For some months, I'm renting an apartment in the Canary Islands. It looks like the plugs are not grounded. For example, when I connect my laptop, a ThinkPad T420si, then I feel an unpleasant sensation on my bare legs when connected to mains ([220V/50Hz](http://de.wikipedia.org/wiki/L%C3%A4nder%C3%BCbersicht_Steckertypen,_Netzspannungen_und_-frequenzen#L.C3.A4nderliste)). A similar sensation I get when touching certain parts, incl. plastic parts (!), of my smartphone when connected to the laptop. *Contrary to what I wrote before:* When connected to the USB charger, I do *not* get that sensation when touching the smartphone. My guess is that the outlets are not properly grounded. While I assume there is no risk for my health, I am a bit worried about my electronic devices. Also, I may want to do some electronics soldering, and I don't like the idea of the soldering iron's tip possibly being on a different potential than ground. *What options do I have to remedy the problem? An isolating transformer?* Update as of 2014-10-15 WEST ============================ After removing the Schuko ([fype F](http://www.iec.ch/worldplugs/typeF.htm)) multiplier, and upon close inspection of the outlet, I realized that the center hole is *not* a screw hole. It is ground, i.e. this outlet is of [type L](http://www.iec.ch/worldplugs/typeL.htm). So I bought an adapter, and yesterday the problem was gone: ![Photo of adapter type L to type F](https://i.stack.imgur.com/OrUaY.jpg) Facepalm! But wait, today the problem is back, and in the entire apartment! For the first time, I felt a potential when touching the washing machine in the bathroom, and this one is connected with a Schuko plug to a Schuko outlet: ![Photo of washing machine plug type F in outlet of the same type](https://i.stack.imgur.com/DuQI4.jpg) Something is wrong here. Probably unrelated: Some days ago there was a power outage, I think affecting several houses, i.e. not just the one I'm living in.
2014/10/12
[ "https://diy.stackexchange.com/questions/51512", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/27184/" ]
This is not about grounding, or perhaps it is... Lets start with your connectors: Do you have AC-connectors at your devices with or without grounding pin? Laptop psu may have a protective earth connection, a phone charger won't have one. I've never seen a phone charger with protective earth connection. Both PSUs are doubly insulated, I'm pretty sure, which means primary side is galvanically separated from secondary side, which includes everything which can be touched with bare hands. How does this sensation of 50 Hz AC come over to touchable parts? There's something calle Y-Capacitor between primary and secondary side in these PSUs. It is used to provides a stable potential for the regulating circuitry of the PSU, i.e. it prevents the secondary side from "floating". It can be described by two small capacitors in series between neutral lead and live lead on primary side with the middle node connected to the ground of the secondary side. Hence, on a 230V system, the secondary side gets a level of 115 V AC. The capacitor is designed to permit a maximum current of 0,35 mA to flow, if shorted to ground. This is a current you can sense, but which cannot harm you or your equipment. If something with earthing in your mansion was wrong, it would not change this effect in my opinion. In the rare case, your PSUs really have a protective earth connector you should not be able to sense that voltage as it was conducted away. In this rare case you should get an electrician soon, because if you touch your oven or washing machine there is no such limiting capacitor to protect you in case of an failure. I have a different theory why you feel somthing you do not know at home. On canary islands it is rather warm and carpets are rare while most homes have tiled floor. If you live somewhere cold the rest of the year you probably have carpets or wooden floor which reduce capacitive coupling by orders of magnitude. You just may not feel the phenomenon while it is there, too. Update ------ Relating to your updates: **Now you do have a problem.** When you feel a tickling sensation when touching devices like a washing machine there is one possible conclusion: the potential of protective earth connected with the housing of your devices differs from the potential of your house. Which can mean different things. * You have only 2-wire conduits in your house. The neutral and protective earth in your wall outlets are connected to one common wire (usually blue in EU). Some connections in your house have too high ohmic resistance. When under heavy load, voltage on N **and** PE rises, hence you can feel the influenced voltage. * Protective Earth is somewhere broken, effectively. This is **really** bad, as all Class 1 equipment relies on working PE and a short to housing, which especially water bearing devices are prone to, will put the full voltage to touchable parts of the defective devices. * And if PE is interrupted at the equipotential bus bar it gets even worse. Not only a faulty potential from one defective device will propagate through your complete building and be present on every Schuko (PE contact), but will also be induced by assymetric load in the 3-phase-network between the next transformer station and your house. Which means, even if all devices in your house are depowered properly, PE-conductors may conduct harmful voltages. For the last two options, your life is at risk. You should get an electrician to prove me wrong. The first possibility can be verified by opening a wall outlet (of course after opening the circuit breaker, securing it against reconnecting, verifying all pins in the outlet are deenergised and so on). If there are two wires only and one of them connects to N and PE you have a “bootleg ground”, which renders even ground fault interruptors partially useless.
53,520,080
I need to encrypt user names that i receive from an external partners SSO. This needs to be done because the user names are assigned to school children. But we still need to be able to track each individual to prevent abuse of our systems, so we have decided to encrypt the user names in our logs etc. This way, a breach of our systems will not compromise the identity of the children. Heres my predicament. I have very limited knowledge in this area, so i am looking for advice on which algorithm to use. I was thinking of using an asymmetrical algorithm, like PGP, and throwing away one of the keys so that we will not be able to decrypt the user name. My questions: * Does PGP encryption always provide the same output given the same input? * Is PGP a good choice for this, or should we use an other algorithm? * Does anyone have a better suggestion for achieving the same thing - anonymization of the user
2018/11/28
[ "https://Stackoverflow.com/questions/53520080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4149494/" ]
If you want a one-way function, you don't want encryption. You want hashing. The easiest thing to do is to use a hash like SHA-256. I recommend salting the username before hashing. In this case, I would probably pick a static salt like `edu.myschoolname:` and put that in front of the username. Then run that through SHA-256. Convert the result to Base-64 or hex encoding, and use the resulting string as the "username." From a unix command line, this would look like: ``` $ echo -n "edu.myschoolname:[email protected]" | shasum -a 256 09356cf6df6aea20717a346668a1aad986966b192ff2d54244802ecc78f964e3 - ``` That output is unique to that input string (technically it's not "unique" but you will never find a collision, by accident or by searching). And that output is stable, in that it will always be the same for the given input. (I believe that PGP includes some randomization; if it doesn't, it should.) --- (Regarding comments below) Cryptographic hash algorithms are extremely secure for their purposes. Non-cryptographic hash algorithms are not secure (but also aren't meant to be). There are no major attacks I know of against SHA-2 (which includes SHA-256 and SHA-512). You're correct that your system needs to be robust against someone with access to the code. If they know what userid they're looking for, however, no system will be resistant to them discovering the masked version of that id. If you encrypt, an attacker with access to the key can just encrypt the value themselves to figure out what it is. But if you're protecting against the reverse: preventing attackers from determining the id when they do not already know the id they're looking for, the correct solution is a cryptographic hash, specifically SHA-256 or SHA-512. Using PGP to create a one-way function is using a cryptographic primitive for something it is not built to do, and that's always a mistake. If you want a one-way function, you want a hash.
206,136
We know that a cat is able to endure, continue, or survive despite a near encounter with death or disaster because cats have nine lives (according to a common myth). > > Example: > - Mr. Pickles has been missing for a few days, but I wouldn't worry about him. **He is a cat with nine lives.** > > > > Does my bold self-made sentence work properly and idiomatically here?
2019/04/19
[ "https://ell.stackexchange.com/questions/206136", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/5652/" ]
It is in the past tense. This is a "[future in the past](https://www.englishpage.com/verbpage/futureinpast.html)" construction. The question is rhetorical. Leonard isn't looking for an answer, but he phrases his statement as a question. Changing it back to a statement gives: > > I told you I would be working nights. > > > So in the past Leonard said "I will be working nights". In the past Leonard used a future tense. When he reports this the tense of "will" is changed to the past tense. The past tense of "will" is "would". This construction is quite rare, it is most likely to appear in reported speech, thoughts or emotions > > I knew it would be fun. > > > Leonard could have used a "going to" for the future with little or no change in meaning. > > Didn't I tell you I was going to be working nights? > > >
3,028,475
I'm having the following tables: Table a | Field | Type | Null | Key | | --- | --- | --- | --- | | bid | int(10) unsigned | YES | | | cid | int(10) unsigned | YES | | Table b | Field | Type | Null | | --- | --- | --- | | bid | int(10) unsigned | NO | | cid | int(10) unsigned | NO | | data | int(10) unsigned | NO | When I want to select all rows from b where there's a corresponding bid/cid-pair in a, I simply use a natural join `SELECT b.* FROM b NATURAL JOIN a;` and everything is fine. When `a.bid` or `a.cid` is `NULL`, I want to get every row where the other column matches, *e.g.* if `a.bid` is `NULL`, I want every row where `a.cid = b.cid`, if both are `NULL` I want every column from `b`. My naive solution was this: ``` SELECT DISTINCT b.* FROM b JOIN a ON (ISNULL(a.bid) OR a.bid=b.bid ) AND (ISNULL(a.cid) OR a.cid=b.cid) ``` Is there any better way to to this?
2010/06/12
[ "https://Stackoverflow.com/questions/3028475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/73299/" ]
No, that's pretty much it. (I'd generally rephrase `ISNULL(a.bind)` as `a.bind IS NULL` for ANSI SQL compliance FWIW.)
627,683
I've figured out that extracting a `.zip` you need the path to the directory as well when you are recursively looking through subdirectories. So how do you store the path? This is nearly there but doesn't work properly when there is a space in the `{zip_file}`. ``` zip_dir=$PWD/$(basename "${zip_file}") ```
2015/05/24
[ "https://askubuntu.com/questions/627683", "https://askubuntu.com", "https://askubuntu.com/users/323574/" ]
I created this from your other question as well. It took me a bit, but this is what I was able to come up with to create the folders based on the zip file name, removing the `.zip` from the folder name, then extracting the zip file into that folder. ``` #!/bin/bash echo "Start folder create..." find . -type f -iname "*.zip" | while read filename do filename1=${filename:2} foldername=$PWD/"${filename1%.*}" mkdir -p "$foldername" unzip "$filename" -d "$foldername" echo "Created directory $foldername and extracted files to it." done ``` The line `filename1=${filename:2}` strips off the `./` of the name.
60,583,052
I was trying to test my code with fixed time. so I wrote something like this: ```rust use std::time::{SystemTime, UNIX_EPOCH}; trait Clock { fn now(&self) -> SystemTime; } trait MixInClock { type Impl; } struct RealClock; impl<T: MixInClock<Impl = RealClock>> Clock for T { fn now(&self) -> SystemTime { SystemTime::now() } } struct FakeClock; impl <T: MixInClock<Impl = FakeClock>> Clock for T { fn now(&self) -> SystemTime { UNIX_EPOCH } } struct DIContainer; impl MixInClock for DIContainer { type Impl = FakeClock; } ``` This code gives me an error: ``` error[E0119]: conflicting implementations of trait `Clock`: --> src/lib.rs:19:1 | 12 | impl<T: MixInClock<Impl = RealClock>> Clock for T { | ------------------------------------------------- first implementation here ... 19 | impl <T: MixInClock<Impl = FakeClock>> Clock for T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation ``` Why? There's no possibility that `T` implements `MixInClock<Impl = RealClock>` and `MixInClock<Impl = FakeClock>` at same time. right? <https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=95e3647b30ae0e37c45ac18da495a3c5>
2020/03/07
[ "https://Stackoverflow.com/questions/60583052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13025505/" ]
You ran into a [long-standing issue with Rust's coherence rules](https://github.com/rust-lang/rust/issues/20400). There are proposals how to resolve this, but the work has been postponed for now. Quoting [Jonas Schievink's most recent comment on the bug](https://github.com/rust-lang/rust/issues/20400#issuecomment-493206721): > > To give an update on this: In 2016, [RFC 1672](https://github.com/rust-lang/rfcs/pull/1672) was proposed to fix this, but was postponed until the Chalk integration is done. Additionally, according to [rust-lang/rfcs#1672 (comment)](https://github.com/rust-lang/rfcs/pull/1672#issuecomment-262152934), allowing these kinds of impls would allow users to express mutually exclusive traits, which is a very powerful feature that needs more in-depth consideration by the language team (hence marking as blocked on an RFC as well). > > >
22,393,605
how to get text from json without [" "] only text ,in android project this is my json from url {"code":200,"lang":"en-ru","text":["Better late than never"]} i need get text "text":["Better late than never"] without [" "] only text: Better late than never myclass MAINACTIVITY ``` public class MainActivity extends Activity { JSONParser jsonparser = new JSONParser(); TextView tv; String ab; JSONObject jobj = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tv = (TextView) findViewById(R.id.tvResult); new retrievedata().execute(); } class retrievedata extends AsyncTask<String,String,String>{ @Override protected String doInBackground(String... arg0) { // TODO Auto-generated method stub jobj = jsonparser.makeHttpRequest("https://translate.yandex.net/api/v1.5/tr.json/translate?key=YOURAPIKEY&text=Better%20late%20than%20never&lang=ru"); // check your log for json response Log.d("Login attempt", jobj.toString()); ab = jobj.optString("text"); return ab; } protected void onPostExecute(String ab){ tv.setText(ab); } } } ``` MY JSONPARSER CLASS ``` public class JSONParser { static InputStream is = null; static JSONObject jobj = null; static String json = ""; public JSONParser(){ } public JSONObject makeHttpRequest(String url){ DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); try { HttpResponse httpresponse = httpclient.execute(httppost); HttpEntity httpentity = httpresponse.getEntity(); is = httpentity.getContent(); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { BufferedReader reader = new BufferedReader(new InputStreamReader(is,"utf-8"),8); StringBuilder sb = new StringBuilder(); String line = null; try { while((line = reader.readLine())!=null){ sb.append(line+"\n"); } is.close(); json = sb.toString(); try { jobj = new JSONObject(json); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return jobj; } } ```
2014/03/14
[ "https://Stackoverflow.com/questions/22393605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3413314/" ]
To uninstall the version of Typescript used by Visual Studio, use "add/remove programs" in Windows and remove "TypeScript for Visual Studio". It's installed as a program rather than an extension for VS (and as you've noticed, it doesn't use the NodeJs version).
20,710
After around 15 minutes of playing Battlefield: Bad Company 2, my computer completely locks up with the game's image on screen and the last second of sound constantly looping. I have to hard restart the machine to get it to come back. I'm not sure if this issue is isolated to BF:BC2 but it's the only game I've been playing recently. I've tried leaving a Source Engine game running and it didn't crash for the hour it was open so I'm guessing it's just because BF:BC2 is a more intensive game on the system. Could this be a temperature issue? I've previously played BF:BC2 on the same computer during the summer (it's winter here now) without any issues so I'm guessing this is unlikely. Perhaps faulty RAM or another component? My specs are: * Intel Core 2 Duo E7200 * 4GB RAM * NVIDIA GeForce 9600 GT * Windows 7 Professional 64-bit These are my temperatures when in Windows - are they bad? ![Temperatures](https://i.stack.imgur.com/UVRRJ.png) I can try and get a picture of them while I've got a game running if that would help.
2011/04/23
[ "https://gaming.stackexchange.com/questions/20710", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/-1/" ]
Your temps are mostly fine, maybe the CPU is a bit hot, if these are idle temperatures. Seems like it's the RAM or the CPU. GPU faults don't act up like that. So, you setup an isolated stress test for each suspect. **RAM:** Download memtest86+ and install it on a medium and boot your system with it. I'd suggest USB key: <http://www.memtest.org/#downiso> If it passes the tests, move on to CPU. If it doesn't, find and remove the faulty RAM stick and repeat the test. **CPU**: Download prime95 and run it, no need to reboot: <http://www.mersenne.org/> It might also be that your CPU is running too hot. In that case, open your case (warranty is lost, if any) and clean the dust off from the heat sink and the fans, if any. See if the temperatures drop. If not, the heat sink might have come loose, or has not enough contact to the CPU die. You might want to re-apply the heat conducting fluid.
72,534,839
I am struggling to update the interpolation of `thing`. This simple function should change the value of the data but instead does nothing. Chrome logs the change of thing in the console but the HTML does not update. ``` <template> <div class="container-xl pb-5"> <button class="mb-2 btn-lg selected-dropdown" @click="dropSelect('B')"> {{ thing }} </button> </div> </template> <script lang="ts"> import { defineComponent } from "vue"; export default defineComponent({ data() { return { thing: "A", }; }, methods: { dropSelect(thing: any) { console.log(thing); return this.thing; }, }, }); </script> ```
2022/06/07
[ "https://Stackoverflow.com/questions/72534839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1939661/" ]
Since the function `getData` is `async`, it's a `Future` and you can't use a future methods inside your tree widget directly you can use it inside your widget tree using the widget `FutureBuilder` ``` FutureBuilder( future: getData(), builder: (context, snapshot){ if (!snapshot.hasData) return const SizedBox(); return Text(snapshot.data?.toString() ?? ''); } ``` also, you have to modify your method to make it return something, Ex.: ``` getData() async { User? user = await FirebaseAuth.instance.currentUser; print(user?.displayName); return user?.displayName; } ``` --- **UPDATE:** to access all the info you want from the `User` object, let your method return the whole object; ``` getData() async { User? user = await FirebaseAuth.instance.currentUser; print(user?.displayName); return user; } ``` and your `FutureBuilder` will be ``` FutureBuilder( future: getData(), builder: (context, snapshot){ if (!snapshot.hasData) return const SizedBox(); if (snapshot.data == null) return const Text('Current user is null'); return Column( children: [ Text('Name: ${snapshot.data?.displayName}'), Text('Email: ${snapshot.data?.email}'), ///Add any attribute you want to show.. ] ); } ```
78,579
In one of my projects my requirement is to insert/add more than 15000 records/entries at one og in a custom list. After searching some of the blogs i found some useful information about adding bulk entries in custom list.I tried to add by the batch files, i called processbatchdata method for bulk entries. Referred link : <http://www.arboundy.com/code/sharepoint/bulk-add-new-items-to-a-sharepoint-list-using-processbatchdata/> However i ended up with the performance issue,its taking more than 2 minutes for adding 5000 entries. Can anyone help me on this issue. Many Thanks.
2013/10/01
[ "https://sharepoint.stackexchange.com/questions/78579", "https://sharepoint.stackexchange.com", "https://sharepoint.stackexchange.com/users/19863/" ]
If you are complaining about 2 minutes being slow for 5k items, presumably this isn't a one time import - you may consider looking at [Business Connectivity Services](http://msdn.microsoft.com/en-us/library/ff798319.aspx) to connect directly to your external data source.
25,653,399
On one controller, I have a function that handles a drill down that sets that record's information on another controller's config variables. It seems to set them fine the from first controller. When it switches to the other controller, it says those variables are undefined. What is going on? Controller handling drill down: ``` // Set site name for Site Summary MyApp.app.getController('otherController').setSiteId(siteId); MyApp.app.getController('otherController').setSiteName(siteName); console.log(MyApp.app.getController('otherController').getSiteId()); console.log(MyApp.app.getController('otherController').getSiteName()); // Prints out the correct values that are supposed to be set ``` Other controller where the values aren't sticking: ``` Ext.define('MyApp.controller.otherController', { extend: 'Ext.app.Controller', config: { siteId: -1, siteName: '' }, init: function() { this.listen( { component: { 'somePnl': { beforerender: this.onBeforeRender }, // stuff onBeforeRender: function() { console.log("this.siteName = " + this.siteName); console.log("this.siteId = " + this.siteId); }, // Prints out 'undefined' } ``` I can't seem to figure out why the setting of those variables aren't sticking
2014/09/03
[ "https://Stackoverflow.com/questions/25653399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2115016/" ]
ExtJS recommends using generated setter and getter for configs. The direct access is not documented. Doc: <http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.Class-cfg-config> So using ``` console.log("this.siteName = " + this.getSiteName()); console.log("this.siteId = " + this.getSiteId()); ``` is best practice and should do the job.
23,794,483
I'm just starting coding in Django and I have code that repeat itself on a lot of pages. for example: ``` <select name="seasons" id="season-id"> {% for season in seasons %} {% if season_id|add:0 == season.id %} <option value="{{ season.id }}" selected="selected">{{ season.name }}</option> {% else %} <option value="{{ season.id }}">{{ season.name }}</option> {% endif %} {% endfor %} </select> ``` In previous language I could use view helpers to make it more DRY. How can I accomplish this in Django.
2014/05/21
[ "https://Stackoverflow.com/questions/23794483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/490570/" ]
Extract the code into a separate template file and [`include`](https://docs.djangoproject.com/en/dev/ref/templates/builtins/#include) it instead of repeating: ``` {% include "seasons.html" %} ``` FYI, you can also specify that you want to pass only `seasons` variable into the context of included template: ``` {% include "seasons.html" with seasons=seasons only %} ```
2,676,057
Feel free to close and/or redirect if this has been asked, but here's my situation: I've got an application that will require doing a bunch of small units of work (polling a web service until something is done, then parsing about 1MB worth of XML and putting it in a database). I want to have a simple async queueing mechanism that'll poll for work to do in a queue, execute the units of work that need to be done, and have the flexibility to allow for spawning multiple worker processes so these units of work can be done in parallel. (Bonus if there's some kind of event framework that would also me to listen for when work is complete.) I'm sure there is stuff to do this. Am I describing Twisted? I poked through the documentation, I'm just not sure exactly how my problems maps onto their framework, but I haven't spent much time with it. Should I just look at the multiprocess libraries in Python? Something else?
2010/04/20
[ "https://Stackoverflow.com/questions/2676057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2484/" ]
There's [celery](http://ask.github.com/celery/getting-started/introduction.html). You could break it down into 2 different `Tasks`: one to poll the web service and queue the second task, which would be in charge of parsing the XML and persisting it.
13,069,605
In my assignment the third step is to Call the method merge to merge the two lists in list1 so that the list1 **remains sorted.** I write my code but it doesn't work well , the output show wrong because it important to be sorted ``` public static void merge (ArrayList<Integer> list1, ArrayList<Integer> list2) { int i; int n=list1.size(); int pos , j=0; for (pos =0 ;pos<n ; pos++) { for ( i=0 ; i<n ; i++) if (list1.get(j)>list2.get(pos)) list1.add(pos,list2.get(pos)); else j++; } } ```
2012/10/25
[ "https://Stackoverflow.com/questions/13069605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1772461/" ]
You only need one `for` loop assuming both lists are sorted: ``` public static void merge(List<Integer> l1, List<Integer> l2) { for (int index1 = 0, index2 = 0; index2 < l2.size(); index1++) { if (index1 == l1.size() || l1.get(index1) > l2.get(index2)) { l1.add(index1, l2.get(index2++)); } } } ``` If `l2` isn't sorted, you need two loops: ``` public static void merge(List<Integer> l1, List<Integer> l2) { for (int index2 = 0; index2 < l2.size(); index2++) { for (int index1 = 0; ; index1++) { if (index1 == l1.size() || l1.get(index1) > l2.get(index2)) { l1.add(index1, l2.get(index2)); break; } } } } ```
7,242,226
What is the fastest way to get a list of all members/users in a given AD group and determine whether or not a user is enabled (or disabled)? We are potentially talking about 20K users, so I would like to avoid hitting the AD for each individual user.
2011/08/30
[ "https://Stackoverflow.com/questions/7242226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/154991/" ]
If you're on .NET 3.5 and up, you should check out the `System.DirectoryServices.AccountManagement` (S.DS.AM) namespace. Read all about it here: * [Managing Directory Security Principals in the .NET Framework 3.5](http://msdn.microsoft.com/en-us/magazine/cc135979.aspx) * [MSDN docs on System.DirectoryServices.AccountManagement](http://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.aspx) Basically, you can define a domain context and easily find users and/or groups in AD: ``` // set up domain context PrincipalContext ctx = new PrincipalContext(ContextType.Domain); // find the group in question GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, "YourGroupNameHere"); // if found.... if (group != null) { // iterate over members foreach (Principal p in group.GetMembers()) { Console.WriteLine("{0}: {1}", p.StructuralObjectClass, p.DisplayName); // do whatever you need to do to those members UserPrincipal theUser = p as UserPrincipal; if(theUser != null) { if(theUser.IsAccountLockedOut()) { ... } else { ... } } } } ``` The new S.DS.AM makes it really easy to play around with users and groups in AD!
9,874
I can't remember when and where I had this discussion, but I remember being corrected when I was speaking by a stranger saying that it is never correct to say *give me half of this*; instead, the grammatically correct phrase would be *give me one half of this*. I've never been a pro at where numbers fit in with the English language, so maybe someone here could shed some light on this.
2011/01/25
[ "https://english.stackexchange.com/questions/9874", "https://english.stackexchange.com", "https://english.stackexchange.com/users/4064/" ]
It is perfectly acceptable to say "give me half of that". In English, "half" in understood on its own to mean "[one of two equal parts of something](http://www.merriam-webster.com/dictionary/half "Half - Definition, Merriam-Webster Dictionary\"")". To put it another way: * It would make no sense to say "give me no halves of that". You would just say "give me none of that". * It would make no sense to say "give me two halves of that". You would just say "give me all of that". Saying "give me one half of that" is redundant. It's equivalent to saying "give me one of one of those two equal parts of that."
32,082,233
I have a dataframe with missing values. How can I write either a python or an R code to replace empty spaces with 0, a single string with 1, and multiple strings joined by "\t" with a number corresponding to how many "\t"s + 1. my data frame: ``` col1 col2 col3 row1 5blue 2green5 white row2 white green\twhite3\t3blue5 row3 blue3 white row4 7blue green2 row5 3green 3white6 row6 6blue green\t6white7 green row7 5blue5 6green white row8 blue6 ``` Output expected: ``` col1 col2 col3 row1 1 1 1 row2 0 1 3 row3 1 0 1 row4 1 1 0 row5 0 1 1 row6 1 2 1 row7 1 1 1 row8 1 0 0 ``` Any ideas? Thanks
2015/08/18
[ "https://Stackoverflow.com/questions/32082233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2597415/" ]
I'm using a function that goes to each column element and checks if the element is a space (You can change that depending on what you have. It looks likes a space to me) and returns 0 if it is, otherwise it splits the string by "\t" and counts the strings that are produced. ``` # example dataset dt = data.frame(col1 = c("green\twhite3\t3blue5","green"), col2 = c(" ", "green\twhite3"), stringsAsFactors = F) dt # col1 col2 # 1 green\twhite3\t3blue5 # 2 green green\twhite3 ff = function(x) { res = vector() # create an empty vector to store counts for each element for (i in 1:length(x)){ # iterate through each element res[i] = ifelse(x[i]==" ", 0, length(unlist(strsplit(x[i],"\t")))) # if the element is space return 0, else split string by \t and count new strings } return(res) # return the stored values } data.frame(sapply(dt, function(x) ff(x))) # apply the function to all columns and save it as a data.frame # col1 col2 # 1 3 0 # 2 1 2 ```
15,840,273
I have an existing MVC3 application which allows users to upload files and share them with others. The current model is that if a user wants to change a file, they have to delete the one there and re-upload the new version. To improve this, we are looking into integrating WebDAV to allow the online editing of things like Word documents. So far, I have been using the .Net server and client libraries from <http://www.webdavsystem.com/> to set the website up as a WebDAV server and to talk with it. However, we don't want users to interact with the WebDAV server directly (we have some complicated rules on which users can do what in certain situations based on domain logic) but go through the previous controller actions we had for accessing files. So far it is working up to the point where we can return the file and it gives the WebDAV-y type prompt for opening the file. The problem is that it is always stuck in read-only mode. I have confirmed that it works and is editable if I use the direct WebDAV URL but not through my controller action. Using Fiddler I think I have found the problem is that Word is trying to talk negotiate with the server about the locking with a location that isn't returning the right details. The controller action for downloading the file is "/Files/Download?filePath=bla" and so Word is trying to talk to "/Files" when it sends the OPTIONS request. Do I simply need to have an action at that location that would know how to respond to the OPTIONS request and if so, how would I do that response? Alternatively, is there another way to do it, perhaps by adding some property to the response that could inform Word where it should be looking instead? Here is my controller action: ``` public virtual FileResult Download(string filePath) { FileDetails file = _fileService.GetFile(filePath); return File(file.Stream, file.ContentType); } ``` And here is the file service method: ``` public FileDetails GetFile(string location) { var fileName = Path.GetFileName(location); var contentType = ContentType.Get(Path.GetExtension(location)); string license ="license"; var session = new WebDavSession(license) {Credentials = CredentialCache.DefaultCredentials}; IResource resource = session.OpenResource(string.Format("{0}{1}", ConfigurationManager.AppSettings["WebDAVRoot"], location)); resource.TimeOut = 600000; var input = resource.GetReadStream(); return new FileDetails { Filename = fileName, ContentType = contentType, Stream = input }; } ``` It is still very early days on this so I appreciate I could be doing this in entirely the wrong way and so any form of help is welcome.
2013/04/05
[ "https://Stackoverflow.com/questions/15840273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/799403/" ]
In the end it seems that the better option was to allow users to directly talk to the WebDAV server and implement the authentication logic to control it. The IT Hit server has extensions that allow you to authenticate against the forms authentication for the rest of the site using basic or digest authentication from Office. Using that along with some other customisations to the item request logic gave us what we needed.
49,646,136
I am trying to put date in column if column 1 is empty. So tried below code but doesn't work. Here input file is pipe separated, so need output also pipe separated code 1 ``` if ($1=="") {$1="date +%m%Y"} ``` code 2 ``` if ($1=="") {$1=`date +%m%Y`} ``` code 3 ``` if ($1=="") {$1=("Time = %m%Y", systime());} ``` required output ``` |042018| ``` sample input ``` ourceIifier|SourleName|GntCode|Dision|Suvision|ProfitCe1|Profie2|Plade|Retuiod|SuppliN SAP|SAP_OSR_INV||||||||08AAACT2T| ``` Expected ouput ``` ourceIifier|SourleName|GntCode|Dision|Suvision|ProfitCe1|Profie2|Plade|Retuiod|SuppliN SAP|SAP_OSR_INV|||||||042018|08AAACT2T| ``` my code : ``` awk -F"|" -v OFS="|" 'NR>1{ if (match($14,/[0-9]+\.[0-9]+\.[0-9]{4}$/)) { split ($14, mdy, "."); $14 = sprintf ("%02d-%02.f-%02.f", substr(mdy[3],0,4), mdy[1], mdy[2]); if ($1=="") {$1="SAP"} if ($2=="") {$2="SAP_OSR_INV"} if ($9=="") {$9="date +%m%Y"} if ($26 ~ /^[0-9]$/) {$26=sprintf("%02.f",$26)} if ($58~/^1000$/) {$10="27AAACT2438A1ZT";}}1' input.csv > output.csv ``` Here in column9($9) statement "if ($9=="") {$9="date +%m%Y"}" i want to put date.
2018/04/04
[ "https://Stackoverflow.com/questions/49646136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9153621/" ]
You forgot to output the results and didn't get date correctly, this one works: ``` awk -v date="$(date +"%m%Y")" '$1=="" {$1=date} {print $0}' ```
51,169,227
I have Android layout listed below, but *layout\_marginBottom* is not working - there is no any margin between *myTextView* and *myRecyclerView*. Any ideas, what may be wrong with my layout? ``` <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:paddingBottom="10dp" android:paddingLeft="10dp" android:paddingTop="10dp" android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:id="@+id/myTextView" android:text="*** Descritpion text" app:layout_constraintWidth_default="spread" android:layout_width="0dp" android:layout_height="wrap_content" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toTopOf="@+id/myRecyclerView" android:layout_marginBottom="300dp" /> <android.support.v7.widget.RecyclerView android:id="@+id/myRecyclerView" app:layout_constraintTop_toBottomOf="@+id/myTextView" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintHorizontal_bias="0" app:layout_constraintVertical_bias="0" app:layout_constraintWidth_default="spread" app:layout_constraintHeight_default="wrap" android:layout_width="0dp" android:layout_height="0dp" /> </android.support.constraint.ConstraintLayout> ```
2018/07/04
[ "https://Stackoverflow.com/questions/51169227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5752684/" ]
To understand your question correctly, do you meant to say telnet is not found inside the running container? If not then you can install if while building the image itself.
36,144,214
I have a vb string with this value: `c:\program\bin\files` I need to convert this string to this value: `files` All i need is the last folder of the path. The path is not fixed. It can be anything like: `d:\app\win\7\sp1\update` In this case the string must be converted to: `update` I think that should be done by searching the string backwards for the first occurrence of `\` and removing everything before it, including the `\` itself. But obviously i don't know how to do it. :) Thank you! **EDIT:** I need to use this to fill a ComboBox... This is what i am using: ``` ComboBox1.Items.AddRange(IO.Directory.GetDirectories(appPath & "\Updates\Version")) ``` It gives me a ComboBox like: ``` c:/program/Updates/Version/Beta1 c:/program/Updates/Version/Beta2 c:/program/Updates/Version/Beta3 c:/program/Updates/Version/Beta4 ``` And i would like to have the ComboBox like: ``` Beta1 Beta2 Beta3 Beta4 ```
2016/03/22
[ "https://Stackoverflow.com/questions/36144214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1181161/" ]
Rather than try to pull apart the string yourself, have a look at the [System.IO.Path](https://msdn.microsoft.com/en-us/library/system.io.path(v=vs.110).aspx) class. In your case, the GetFileName method does what you want: ``` lastFolder = System.IO.Path.GetFileName(path) ``` To fill a combo box with names you can use a LINQ query like this: ``` ComboBox1.Items.AddRange( From path In IO.Directory.GetDirectories(IO.Path.Combine(appPath, "Updates\Version")) Select IO.Path.GetFileName(path)) ``` Also, try to use the Path.Combine method when joining path fragments together. It's safer than just joining strings.
1,863,954
$$\int \frac{dx}{x(x^n +1)} $$ $$t=x^n + 1$$ $${dt}=nx^{n-1}{dx}$$ $$\frac{dx}{x}=\frac{dt}{nx^n}$$ $$\int \frac{1}{n}\frac{dt}{t(t-1)} $$ I tried $t=\sin^2\theta $ but back substitution will be difficult . How to integrate this type of integration ?
2016/07/19
[ "https://math.stackexchange.com/questions/1863954", "https://math.stackexchange.com", "https://math.stackexchange.com/users/346279/" ]
Let $$I = \int\frac{1}{x(x^n+1)}dx = \int\frac{1}{\left(1+x^{-n}\right)}\cdot \frac{1}{x^{n+1}}dx$$ Now put $1+x^{-n} = t\; $ Then $\displaystyle -\frac{1}{n}\cdot \frac{1}{x^{n+1}}dx = dt$ So $$I =-n\int\frac{1}{t}dt=-n\ln |t|+\mathcal{C} = n\ln \left|\frac{x^n}{1+x^n}\right|+\mathcal{C}$$
1,954,608
> > Prove that $$\binom{2n}{n}>\frac{4n}{n+1}\forall \; n\geq 2, n\in \mathbb{N}$$ > > > $\bf{My\; Try::}$ Using $$(1+x)^n = \binom{n}{0}+\binom{n}{1}x+\binom{n}{2}x^2+........+\binom{n}{n}x^n$$ and $$(x+1)^n = \binom{n}{0}x^n+\binom{n}{1}x^{n-1}+\binom{n}{2}x^{n-1}+........+\binom{n}{n}$$ Now Coefficients of $x^n$ in $\displaystyle (1+x)^{2n} = \binom{2n}{n} = \binom{n}{0}^2+\binom{n}{1}^2+\binom{n}{2}^2+.....+\binom{n}{n}^2$ Now Using $\bf{Cauchy\; Schwarz}$ Inequality $$\left[\binom{n}{0}^2+\binom{n}{1}^2+\binom{n}{2}^2+.....+\binom{n}{n}^2\right]\cdot \left[1^2+1^2+....+1^2\right]\geq \left[\binom{n}{0}+\binom{n}{1}+\binom{n}{2}+.....+\binom{n}{n}\right]^2=2^{2n}=4^n>4n\forall n\geq 2,n\in \mathbb{N}$$ So $$\binom{2n}{n} = \binom{n}{0}^2+\binom{n}{1}^2+\binom{n}{2}^2+.....+\binom{n}{n}^2>\frac{4n}{n+1}\forall n\geq 2,n\in \mathbb{N}$$ My question is , Is my proof is right, If not then how can i solve it. Also plz explain any shorter way, Thanks
2016/10/05
[ "https://math.stackexchange.com/questions/1954608", "https://math.stackexchange.com", "https://math.stackexchange.com/users/14311/" ]
$$\binom{2n}n=\frac{n+1}{1}\frac{n+2}{2}\cdots\frac{2n-1}{n-1}\frac{2n}{n}\ge2^n>\frac{4n}{n+1}.$$
28,000,501
May be its a duplicate question. I did search about this and referred these Articles * [use of properties vs backing field inside owner class](https://stackoverflow.com/questions/2457010/use-of-properties-vs-backing-field-inside-owner-class), * [should i prefer properties with or without private fields](https://softwareengineering.stackexchange.com/questions/161166/should-i-prefer-properties-with-or-without-private-fields), * [Properties Matter](http://csharpindepth.com/Articles/Chapter8/PropertiesMatter.aspx). The point i understood was, 1. Access like making field read only 2. We can include some logics in 3. setter/getter used for data binding What I really want to clear was, ``` public class Employee { public string strName; } public class Employee { public string strName {get;set;} } ``` **My questions:** 1. Whats the difference between this two implementations 2. Is there any place ( i mean actual scenario) where we can justify a need for auto implemented properties instead the first implementation as shown above as first. **UPDATE** I know its a duplicate question and i mentioned it. Please consider my 2nd point in questions i asked. what the answer precisely ? I couldn't understand that. Whether its a good practice or what is the need if i do not have any logic to set that value ? Fine thank you all for replying. I got it now clear. Since i am very new i cant grasp it. But now i got the point. Sorry for wasting all your time.
2015/01/17
[ "https://Stackoverflow.com/questions/28000501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2404117/" ]
With auto implemented properties you can do ``` public class Employee { public string StrName {get; private set;} } ``` And make an external read-only, but internal settable property. Which is something you can't do with your public variable
66,921,057
I'm new to bash scripting and trying to learn. I have a variable $temp, that contains what I get from an API call, which is a long list of SHA1 hashes. I want to take what is in $temp and create an array that I can loop through and compare each entry to a string I have defined. Somehow, I can not seem to get it to work. The array I create always only contains only one element. It is like the rest of the string in $temp is being ignored. I have tried multiple approaches, and can't get anything working the way I want it to. Here's the code snippet: ``` temp=$(curl --silent --request GET "https://api.pwnedpasswords.com/range/$shortendHash") echo "Temp is: $temp" declare -A myArr read myArr <<<$temp echo ${myArr[@]} echo ${myArr[0]} echo ${myArr[1]} ``` When I run this, I get a full list of hashes, when I echo $temp (line 2), something like this: "Temp is: 002C3CADF9FC86069F09961B10E0EDEFC45:1 003BE35BD9466D19258E79C8665AFB072F6:1 0075B2ADF782F9677BDDF8CC5778900D986:8 00810352C02B145FF304FCBD5BEF4F7AA9F:1 013720F40B99D6BCF6F08BD7271523EBB49:1 01C894A55EBCB6048A745B37EC2D989F102:1 030B46D53696C8889910EE0F9EB42CEAE97:4 03126B56153F0564F4A6ED6E734604C67E8:2 043196099707FCB0C01F8C2111086A92A0B:1 0452CABBEF8438F358F0BD8089108D0910E:5 0490255B206A2C0377EBD080723BF72DDAE:2 05AD1141C41237E061460DB5CA5412C1A48:4 05C1D058E4439F8F005EFB32E7553E6AA5B:1 067AF515CC712AC4ACA012311979DBC7C9A:2 ... and so on.." But the ``` echo ${myArr[@]} echo ${myArr[0]} echo ${myArr[1]} ``` returns (first value is ${myArr[@]}, second is ${myArr[0]}, and last one is an empty line, indicating that there is no value at array position 1): 002C3CADF9FC86069F09961B10E0EDEFC45:1 002C3CADF9FC86069F09961B10E0EDEFC45:1 I hope someone can help with this. Thanks a lot in advance!
2021/04/02
[ "https://Stackoverflow.com/questions/66921057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14851149/" ]
``` declare -A myArr # creates an associative array (hash) declare -a myArr # creates an array ``` Neither is necessary here. `read` can create the array for you. See `help declare` and `help read`. --- ``` temp=$(curl --silent --request GET "https://api.pwnedpasswords.com/range/$shortendHash") # -a: assign the words read to sequential indices of the array read -a myArr <<<"$temp" declare -p myArr ``` Output: > > declare -a myArr=([0]="002C3CADF9FC86069F09961B10E0EDEFC45:1" [1]="003BE35BD9466D19258E79C8665AFB072F6:1" [2]="0075B2ADF782F9677BDDF8CC5778900D986:8" [3]="00810352C02B145FF304FCBD5BEF4F7AA9F:1" [4]="013720F40B99D6BCF6F08BD7271523EBB49:1" [5]="01C894A55EBCB6048A745B37EC2D989F102:1" [6]="030B46D53696C8889910EE0F9EB42CEAE97:4" [7]="03126B56153F0564F4A6ED6E734604C67E8:2" [8]="043196099707FCB0C01F8C2111086A92A0B:1" [9]="0452CABBEF8438F358F0BD8089108D0910E:5" [10]="0490255B206A2C0377EBD080723BF72DDAE:2" [11]="05AD1141C41237E061460DB5CA5412C1A48:4" [12]="05C1D058E4439F8F005EFB32E7553E6AA5B:1" [13]="067AF515CC712AC4ACA012311979DBC7C9A:2") > > >
17,696,760
![enter image description here](https://i.stack.imgur.com/Dl6v9.png) As show in Picture above UIView A & UIView C are Added on UIView B. for B ClipToBounds is YES so the Red area is not visible. Is it possible to get Visible rectangle of A & C ( shown with Lines ) I need show Rectangle in visible area when I touches e.g View A. thats it. ![enter image description here](https://i.stack.imgur.com/wllxD.png)
2013/07/17
[ "https://Stackoverflow.com/questions/17696760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/355082/" ]
You can get an intersection rect of the two rects by using [CGRectIntersection()](http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CGGeometry/Reference/reference.html#//apple_ref/doc/uid/TP30000955-CH1g-F17157) method ``` CGRect intersectionRect = CGRectIntersection(viewA.frame, viewB.frame); if(CGRectIsNull(intersectionRect)) { //Rects do not intersect } ```
5,524,712
I currently have a design like follows View1(mainview) creates a view2, sets a reference back to view1 in view2, presents view2 view2 creates a view3, sets view3 to have the same view1 reference, presents view3 view3 then needs to , depending on user selection, call a function on view1, which currently works perfectly and it should then present view1. The issue is I need a way of showing view1 when view3 is done, so this reference gets passed along and clearly works because the method called on it executes. The issue I have is when trying to present it the app freezes. I also tried creating a new view1, setting it to the reference and presenting that, this causes a freeze too. What could be the issue? I present it like everything else.
2011/04/02
[ "https://Stackoverflow.com/questions/5524712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/356387/" ]
I suddenly realised what caused my problem. I had previously changed the default setting for mass\_assignment in a config file to enforce that all attributes were protected unless declared otherwise. An obvious mistake in retrospect but hopefully this might save someone else some time too
2,415,297
Find the least positive integer $m$ such that $m^2 - m + 11$ is a product of at least four not necessarily distinct primes. I tried but not able to solve it. **Edit** : Please note that I am looking for mathematical solution not the programming one.
2017/09/03
[ "https://math.stackexchange.com/questions/2415297", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
Let the equality $$m(m-1)+11=N$$ It is clear that $N$ must be odd and that can be divisible by the prime $11$. However the following congruences have no solution as it is easy to prove directly checking the few possibilities with $m(m-1)$ not divisible by $3,5$ and $7$ respectively $$\begin{cases}m(m-1)+2\equiv 0\pmod3\\m(m-1)+1\equiv 0\pmod5\\m(m-1)+4\equiv 0\pmod7\end{cases}$$ Thus $N=\prod p\_i^{a\_i}$ with $p\_i\ge11$. A necessary condition is that (solving the quadratic in $m$) $$\sqrt{4N-43}=x^2$$ and from this we need that $$N\equiv 1,3,7\pmod{10}$$ By chance we find the minimum $N=11^3\cdot13$ which corresponds to $\color{red}{m=132}$ and that could have been calculated by direct trials but the next solution seems to be far from $132$.
69,152,784
I'm trying to create an HTML page with a footer sticking to the bottom, independently from the size of the browser window. I created the following HTML file: ```html <!doctype html> <html> <head> <meta charset="utf-8"> <title> Home </title> <link rel="stylesheet" href="./assets/css/styles.css"> </head> <body> <h1> Home </h1> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> <footer id="footer"> Foo Bar Baz </footer> </body> </html> ``` And my stylesheet is: ```css #footer { position: absolute; bottom: 0px; width: 100%; padding: 10px; border: 1px solid; } ``` I used the properties `position` and `bottom` following several guides. I get the footer at the expected vertical position, but it is shifted horizontally to the right, whatever the window width is. For example: [full screen](https://i.stack.imgur.com/sFPqK.png), [medium](https://i.stack.imgur.com/OpKkf.png), [small](https://i.stack.imgur.com/oBWvk.png). Where is the error? And how can I fix it?
2021/09/12
[ "https://Stackoverflow.com/questions/69152784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12293618/" ]
According to your requirement, if you don't want to show `right` and `left` border of the footer then you can only use `left:0px;` with your footer `CSS`. i.e. ``` #footer { position: fixed; bottom: 0px; width: 100%; padding: 10px; border: 1px solid; left: 0px; } ``` And also if you want to show `right` and `left` borders of footer then decrease the `width` of `footer` and increase value of `left` accordingly. Hopefully it will help you.
42,734,801
everyone! I'm using matplotlib and I have a field with randomly generated circles. Also I have button which has to generate new random circles in the field but every time I press it, circles are generated inside the BUTTON, but not in the field. Please show me what I'm doing wrong, I'm new to python(actually started learning it yesterday). Here is my code: ``` import numpy as np import matplotlib.pyplot as plt from matplotlib.widgets import Button plt.subplots_adjust(bottom=0.2) N = 10 x = np.random.rand(N) y = np.random.rand(N) colors = np.random.rand(N) area = np.pi * 0.2 l = plt.scatter(x, y, s=area, c=colors, alpha=0.8) def gen(event): N = 10 x = np.random.rand(N) y = np.random.rand(N) colors = np.random.rand(N) area = np.pi * 0.2 plt.scatter(x, y, s=area, c=colors, alpha=0.8) plt.draw() axgen = plt.axes([0.81, 0.05, 0.1, 0.075]) bgen = Button(axgen, 'Generate') bgen.on_clicked(gen) plt.show() ``` ![enter image description here](https://i.stack.imgur.com/LUXKT.png)
2017/03/11
[ "https://Stackoverflow.com/questions/42734801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What you have is efficient enough, really. In this context almost anything you could dream up is efficient enough, but for neatness? Well, I would've at least refactored the conversion into a function, and do you really need a long int to store the age levels? I doubt it as humans generally don't become *that* old. I would just go for a regular int. Something like this: ``` int ConvertFromMaturityConfig(string maturityConfig) { string ageString = maturityConfig.Split('=')[0]; return int.Parse(ageString); } ``` Usage: ``` string maturity = "0=Child|13=Teen|18=Adult"; string[] configuration = maturity.Split('|'); int childAgeMin = ConvertFromMaturityConfig(configuration[0]); int teenAgeMin = ConvertFromMaturityConfig(configuration[1]); int adultAgeMin = ConvertFromMaturityConfig(configuration[2]); ``` I would also consider trying to determine which configuration belongs to which value. As it is, you're expecting you get the child age, the teen age and the adult age, in that order. Personally, with the constraints you have, I would've put it into a dictionary so that you could look it up there. Then you could have something like this: ``` string maturity = "0=Child|13=Teen|18=Adult"; var config = maturity.Split('|') .Select(s => s.Split('=')) .ToDictionary( c => c[1], // key selector c => int.Parse(c[0])); ``` Then you can use it like this: ``` if (age >= config["Child"] && age < config["Teen"]) maturity = "Child"; else if (age >= config["Teen"] && age < config["Adult"]) maturity = "Teen"; else if (age >= config["Adult"]) maturity = "Adult"; ``` You would be wise to consider what happens if the age is below the minimum child age, by the way.
47,814,410
I have an array of numbers, for example (calendar days): 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 I want to highlight every three numbers after two. So it should looks like: **1** **2** **3** 4 5 **6** **7** **8** 9 10 **11** **12** **13** 14 15 **16** **17** **18** 19 20 **21** **22** **23** 24 25 **26** **27** **28** 29 30 **31** Or it can be two after two, or four after two or any other pair. I need some algorithm to make this work, help please.
2017/12/14
[ "https://Stackoverflow.com/questions/47814410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1379147/" ]
You can use modulo `%`. If modulo is less than or equal to 2 (0,1,2) highlight it. ``` $arr = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31); foreach( $arr as $key => $value ) { if ( ( $key % 5 ) <= 2 ) echo "<b>" . $value . "</b>"; else echo $value; echo "<br />"; } ```
1,337
When asking an "ID My Bike" question what information about the bike should I include? Would a good "ID My Bike" question need all of the following or are there a few key things that would offer the best chance of an ID? Maybe something like - if these three things are included the chance of ID is 50/50. If these two things are added to that the chance goes up to 80% **Pictures** (maybe some coaching on how to take good pictures) * every major frame joint * all decals/logos/stamped names * every component * Other **Words** * Serial number * Information about my current knowledge of the bike * Links to information I have found so far * Other
2019/05/28
[ "https://bicycles.meta.stackexchange.com/questions/1337", "https://bicycles.meta.stackexchange.com", "https://bicycles.meta.stackexchange.com/users/41662/" ]
In order to ID a bike a question **must have**: At least one clear picture. If there is no picture there is zero chance of providing an ID. The question will be closed. The picture should be high resolution (any modern smart-phone will work) In the picture the bike should be: - well lit - right side up (sitting on it's wheels) - of the whole bike - from the chain side of the bike flat on. Pictures of the following are helpful: - head badge ( on the front of the frame) - logos - decals - distinctive frame features (lug work, square tubing, etc.) Other helpful information: - Country in which the bike is located. - What has already learned or is known about the bike. Here is an example of a good picture. [![Required and Optional Pictures](https://i.stack.imgur.com/pXhFv.png)](https://i.stack.imgur.com/pXhFv.png) This answer is a summary of the excellent answers provided by Argenti Apparatus and Criggie
50,187,829
I want from `path="/users/:login/:repo"` to view login's repo detail page but it doesn't work and views UserProfile component. Here is the click: ``` <Link to={this.props.location.pathname+'/'+item.name}> <div> <h4>{item.name}</h4> <p>{item.description} </p> </div> </Link> <Switch> <Route exact path="/" component={Contributors}/> <Route path="/users/:login" component={UserProfile}/> <Route path="/users/:login/:repo" component={RepoPage}/> </Switch> ```
2018/05/05
[ "https://Stackoverflow.com/questions/50187829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4868320/" ]
You need to reverse the ordering of your routes, since `Switch` matches the first route ``` <Switch> <Route exact path="/" component={Contributors}/> <Route path="/users/:login/:repo" component={RepoPage}/> <Route path="/users/:login" component={UserProfile}/> </Switch> ``` With React-router the paths that are prefixes to the exactly matching path are also matched and hence `"/users/:login/:repo"` also matches `"/users/:login"`, and since you are using switch, RepoPage is getting rendered and not other Routes defined after this are getting checked.
57,588
I observed that dictators often appoint highly educated and qualified technocrats as advisors or spokespersons. For example, * Dr. Gowher Rizvi, advisor to Sheikh Hasina, Ph.D. from Oxford University. * Ibrahim Kalin, spokesperson of Erdogan, Ph.D. from George Washington University. * Bouthaina Shaaban, advisor to Bashar Al Assad, Ph.D. from the University of Warwick. * etc. My question is, Do dictators find such people, Or, those people find dictators?
2020/09/28
[ "https://politics.stackexchange.com/questions/57588", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/32479/" ]
> > Do dictators find such people, Or, those people find dictators? > > > It's mutual. Dictators need someone to "make the trains run on time" and operating a modern state is a complex enterprise beyond the capacity of the ambitious soldiers and politicians who usually end up as dictators to do without expert advice for very long. So, like any other executive leading a large organization, they hire people to fill these posts and look for people who can provide them with quality advice. In many cases, their view of what quality advice looks like is quite mainstream. Many dictators are not particularly ideologically pure and they often don't have well worked out policy doctrines themselves, instead seizing upon a historical moment to take power when it arises. Hitler and Mao's manifestos were the exception and not the rule among dictators. Ideologically driven and thought out agendas are more common among small "d" democratic politicians and revolutionaries (who often fail entirely or have short lived regimes) in order to persuade large numbers of mid-level elites to join their movement. In contrast, run of the mill dictators tend to be less ideological than political genius manifesto writers. They frequently step into a power vacuum marked by chaos, corruption and incompetence on the part of the democratically elected regimes that they replace, or the incompetence of their authoritarian predecessors whom they replace. Since dictators often rise to power based upon the gross incompetence of a predecessor, being able to show some level of competence is often a significant goal for the new dictator if the dictator wishes to hold onto power for long. Skilled professionals need jobs and also believe in their ideas and long to test out those ideas. Dictatorships allow intellectuals to implement their ideas rapidly and uncompromisingly in a way that democratic political processes which tend towards incrementalism and traditional solutions to social and economic problems rarely do. A famous historical example of this is the advice provided by famed democratic free market supporter and premier economist [Milton Friedman](https://en.wikipedia.org/wiki/Milton_Friedman#Chile) who provided economic guidance to military dictator President Augusto Pinochet in Chile the 1970s. Friedman was heavily criticized for this and later attempted to publicly justify his involvement as a voice for positive change from within the regime in the long run (from the same link). > > During the 2000 PBS documentary The Commanding Heights (based on the > book), Friedman continued to argue that "free markets would undermine > [Pinochet's] political centralization and political control.", and > that criticism over his role in Chile missed his main contention that > freer markets resulted in freer people, and that Chile's unfree > economy had caused the military government. Friedman advocated for > free markets which undermined "political centralization and political > control". > > >
43,998,352
I am using netCDF4 to store multidimensional data. The data has, for example, three dimensions, `time = [0, 1, 2]`, `height = [10, 20]`, `direction = [0, 120, 180, 240, 300]`, but not for all combinations (grid points) there is data. In our example, let this be limited to `height`/`direction`-combinations. Namely, suppose that at `height == 10` we have data only for `direction in {0, 120, 240}` and at `height == 20` only for `direction in {120, 180, 300}`. The approaches for dealing with this I see are: 1. Use a separate unidimensional `Variable` for each `height`/`direction`-combination. 2. Use a single three-dimensional `Variable` over the Cartesian product, i.e., all possible combinations, and live with the fact that for some combinations all values are masked. 3. Use different location dimension definitions for each height and a two-dimensional `Variable` for each height. Are there other approaches and what are reasons, both principled as well as practical, for preferring one approach over another?
2017/05/16
[ "https://Stackoverflow.com/questions/43998352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/671672/" ]
Basically your answer number 2 is the correct one. NETCDF files are gridded files, and so the natural structure for the data describe is to define three dimensions, time, height and direction. For the array entries for which data does not exist you need to set the data to equal the value defined by the metadata: ``` _FillValue ``` This means that any software such as R, python, ncview etc that is reading the data will assign these points as "missing". For more details on defining missing values see: <http://www.unidata.ucar.edu/software/netcdf/docs/fill_values.html>
2,559,314
I recently looked at the proof given for the fundamental theorem of calculus in this link: [Why is the area under a curve the integral?](https://math.stackexchange.com/questions/15294/why-is-the-area-under-a-curve-the-integral/15301#15301) It made perfect sense, except for one thing. The proof relies on creating a function $F(b)$ that gives the area under the curve $f(x)$ from $0$ to some real number $b$ so that in essence $F(b) = \int\_{0}^{b}f(x)dx $ and then proved that $F(b)$ is the anti derivative of $f(x)$. However, if we define the integral in this way, then it seems strange that when integrating a function from 0 to a value b we have to evaluate $F(b)-F(0)$ rather than just evaluate $F(b)$. Since the former would generally imply that if we want to find the area under the curve from a to b, then given the definition of an integral, we simply have to subtract the area from 0 to a from the area from 0 to b. Which in this case makes no sense, since we would be subtracting the area from 0 to 0, ie. 0 from the area from 0 to b. Which means we could just discard the first part of the evaluation, yet this would cause us problems if we wanted to evaluate something like $ \int\_{0}^{\pi/2}sin(x)dx $ which would be zero if we just evaluate the antiderivative of sin(x) at $\pi/2$.
2017/12/10
[ "https://math.stackexchange.com/questions/2559314", "https://math.stackexchange.com", "https://math.stackexchange.com/users/446153/" ]
In the notation of the post you linked to, you are confusing $\mathcal{M}$ and $F$. What you are calling $F(b)$, a function which measures the area under the curve from $0$ to $b$, is what the post calls $\mathcal{M}(b)$. The function $F$ is instead *any* antiderivative of $f$. That is, we know *nothing* about $F$ at all other than that it is *some* function whose derivative is $f$. This doesn't mean that $F$ is the same as $\mathcal{M}$, since a function can have more than one antiderivative! Indeed, for any constant $C$, $F(x)=\mathcal{M}(x)+C$ is another antiderivative of $f$, since adding a constant does not change the derivative. However, this is the only way to get another antiderivative: if $F$ is an antiderivative of $f$, then $F'(x)-\mathcal{M}'(x)=f(x)-f(x)=0$, so the function $F(x)-\mathcal{M}(x)$ has derivative $0$ and hence is a constant. So, we're starting with some function $F$ which is an antiderivative, but what we actually want is $\mathcal{M}$. To fix this, we have to subtract a constant from $F$, and that constant is exactly $F(0)$, since $\mathcal{M}(0)=0$.
36,386,358
I am trying to create UML Class Diagram for this problem: So, user is prompted to enter a password. It's a 9 digit number. System receives passwords and checks if it's correct or not by looking into database which has correct password stored inside. If the password is correct, System needs to show message "Correct". Otherwise, message "Error" is shown. If the user enters wrong password more than 5 times in a row, then System stops showing messages. I have 4 classes here, right? User, System, Database, Counter ``` ┌─────────────────────────┬ │ User │ ├─────────────────────────┬ │- pass: int | ├─────────────────────────┼ |+ EnterPass() | ├─────────────────────────┼ | * | | | | | 1 ┌─────────────────────────┬ │ System │ ├─────────────────────────┬ │ | ├─────────────────────────┼ |+ CheckPass() | |+ ShowSuccess() | |+ ShowError() | |+ ShowNothing() | |+ ChangeCategory() | ├─────────────────────────┼ | 1 | | | | | 1 ┌─────────────────────────┬ │ Database │ ├─────────────────────────┬ │- CorrectPass: int | ├─────────────────────────┼ |+ ValidatePass(): bool | |+ Increment1() | ├─────────────────────────┼ | 1 | | | | | 1 ┌─────────────────────────┬ │ Counter │ ├─────────────────────────┬ │- CounterState: int | ├─────────────────────────┼ |+ increment() | |+ GetState(): int | ├─────────────────────────┼ ``` Can someone tell me if this is correct? I am not quite sure if I should connect Counter and System somehow? Is there anything I should add?
2016/04/03
[ "https://Stackoverflow.com/questions/36386358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6108379/" ]
You generally do not want to model this much detail because you'll wind up with a stale, inert model. Users and counters are more of a concern for OOP, and are akin to modeling the sand and clay that make up the bricks to make a house. Who cares about that level of detail? Instead, you're better off modeling the problem domain, which is utterly absent here. You could model the system architecture, which would identify the components, responsibilities, and interactions. You might evolve your System and Database into an architecture. Is your model correct UML? Sure, but it's not particularly useful. BTW, when you see one to one multiplicity, that is almost always a red flag.
10,835,355
I have a ListView with 3 columns and would like to edit the third column, aka Subitem[1]. If I set ListView.ReadOnly to True, it allows me to edit the caption of the selected item. Is there an easy way to do the same thing for the subitem? I would like to stay away from adding a borderless control on top that does the editing.
2012/05/31
[ "https://Stackoverflow.com/questions/10835355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/981120/" ]
You can Edit a subitem of the listview (in report mode) using a TEdit, a custom message and handling the `OnClick` event of the ListView. Try this sample ``` Const USER_EDITLISTVIEW = WM_USER + 666; type TForm1 = class(TForm) ListView1: TListView; procedure FormCreate(Sender: TObject); procedure ListView1Click(Sender: TObject); private ListViewEditor: TEdit; LItem: TListitem; procedure UserEditListView( Var Message: TMessage ); message USER_EDITLISTVIEW; procedure ListViewEditorExit(Sender: TObject); public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} uses CommCtrl; const EDIT_COLUMN = 2; //Index of the column to Edit procedure TForm1.FormCreate(Sender: TObject); Var I : Integer; Item : TListItem; begin for I := 0 to 9 do begin Item:=ListView1.Items.Add; Item.Caption:=Format('%d.%d',[i,1]); Item.SubItems.Add(Format('%d.%d',[i,2])); Item.SubItems.Add(Format('%d.%d',[i,3])); end; //create the TEdit and assign the OnExit event ListViewEditor:=TEdit.Create(Self); ListViewEditor.Parent:=ListView1; ListViewEditor.OnExit:=ListViewEditorExit; ListViewEditor.Visible:=False; end; procedure TForm1.ListView1Click(Sender: TObject); var LPoint: TPoint; LVHitTestInfo: TLVHitTestInfo; begin LPoint:= listview1.ScreenToClient(Mouse.CursorPos); ZeroMemory( @LVHitTestInfo, SizeOf(LVHitTestInfo)); LVHitTestInfo.pt := LPoint; //Check if the click was made in the column to edit If (ListView1.perform( LVM_SUBITEMHITTEST, 0, LPARAM(@LVHitTestInfo))<>-1) and ( LVHitTestInfo.iSubItem = EDIT_COLUMN ) Then PostMessage( self.Handle, USER_EDITLISTVIEW, LVHitTestInfo.iItem, 0 ) else ListViewEditor.Visible:=False; //hide the TEdit end; procedure TForm1.ListViewEditorExit(Sender: TObject); begin If Assigned(LItem) Then Begin //assign the vslue of the TEdit to the Subitem LItem.SubItems[ EDIT_COLUMN-1 ] := ListViewEditor.Text; LItem := nil; End; end; procedure TForm1.UserEditListView(var Message: TMessage); var LRect: TRect; begin LRect.Top := EDIT_COLUMN; LRect.Left:= LVIR_BOUNDS; listview1.Perform( LVM_GETSUBITEMRECT, Message.wparam, LPARAM(@LRect) ); MapWindowPoints( listview1.Handle, ListViewEditor.Parent.Handle, LRect, 2 ); //get the current Item to edit LItem := listview1.Items[ Message.wparam ]; //set the text of the Edit ListViewEditor.Text := LItem.Subitems[ EDIT_COLUMN-1]; //set the bounds of the TEdit ListViewEditor.BoundsRect := LRect; //Show the TEdit ListViewEditor.Visible:=True; end; ```
58,320,581
Is there a way in xpath to select an element and than select children of the element? i.e. given a parent result, how can I find a child that is relative to `this` paraent suppose the following code: ```html <div class="product-general" prod-id="4407"> <img src="..."/> <div class="prod-name">Black Dog</div> </div> ``` in `jQuery` one can do: ```js parent = $('.product-general') id = parent.attr('prod-id') name = $('.prod-name', parent).text() ``` I have the following code (php): ``` $results = $xpath->query("//*[@class='product-general']"); for ($i = 0; $i < $results->length; $i++) { $parent = $results->item($i)->nodeValue; // todo: get prod-id and prod-name } ``` Is it possible to get the prod-id and prod-name that are relative to the parent? NOTE: I know I can do it as follow: ``` $results = $xpath->query("//*[@class='product-general']/@data-pid"); for ($i = 0; $i < $results->length; $i++) { $pid = $results->item($i)->nodeValue; $results2 = $xpath->query("//*[@class='product-general' and @data-pid='".$pid."']//*[contains(@class,'prod-name')]");// $name= $results2->item(0)->nodeValue; $this->products[] = ['pid' => $pid, 'name' => $name]; } ``` But I want to know if there is something more elegant, like the JQ example Also, this solution is painfully slow for a document with 1000 products 10x
2019/10/10
[ "https://Stackoverflow.com/questions/58320581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1406269/" ]
The second param to the `query` is a `$contextnode` that way you can use **relative XPath** like this: ``` foreach ($articles as $article) { $href = $xpath->query('./a/@href', $article)->item(0)->nodeValue; # $href = $xpath->evaluate('string(./a/@href)', $article); # using evaluate } ```
46,984,896
I'm trying to determine if a list `A` contains a value different from two other values, which make up list `B` (`0` and `1`): ``` [0, 1, 0, 1, 0] # False [0, 0, 0, 0, 0] # False [1, 1, 1, 1, 1] # False [0, 1, 0, 2, 0] # True ``` Here's what I have so far but I feel like there's a nice one-liner or a generally much more efficient way: ``` indicator = False A = [0, 1, 0, 2, 0] B = [0, 1] for i in A: if i not in B: indicator = True ```
2017/10/27
[ "https://Stackoverflow.com/questions/46984896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6611672/" ]
You can use `set.issubset()` for this purpose. ``` if not set(A).issubset(B): print("True") else: print("False") ``` Input: ``` A = [0, 1, 0, 2, 0] B = [0, 1] ``` Output: `True` Input: ``` A = [0, 1, 0, 1, 0] B = [0, 1] ``` Output: `False`
650,215
I came across the term "Particle Phenomenology", which is "the application of theoretical physics to experimental data by making quantitative predictions based upon known theories" (quote from Wikipedia). It appears to be a field between particle experiment and particle theory. My question is: who contributes to the field of "Particle Phenomenology", experimentalists or theorists?
2021/07/08
[ "https://physics.stackexchange.com/questions/650215", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/210948/" ]
I copy here from a [prominent US university.](https://phy.princeton.edu/research/research-areas/particle-phenomenology) > > Particle physics phenomenolog*y is the field of theoretical physics* that focuses on the observable consequences of the fundamental particles of Nature and their interactions. The recent discovery of the Higgs boson provides an exquisite confirmation of the Standard Model, but important mysteries remain, including the nature of dark matter, the origin of the matter-antimatter asymmetry in the Universe, the properties of the neutrino sector, and the lightness of the Higgs mass. The Princeton phenomenology group works at the interface between theory and experiment to tackle these many challenges. > > > Italics mine.
1,174,609
I'm trying to use this formula, but Excel keeps telling me there's an error. ``` =SI(NB.SI(A2;"*D*");"Data";"SI(NB.SI(A2;"*V*");"Voice";"Autres")") ``` (In English: ``` =IF(COUNTIF(A2;"*D*");"Data";"IF(COUNTIF(A2;"*V*");"Voice";"Autres")") ``` ) I don't understand where it is. SI Means IF, I am using a french version on Excel 2010 on Win7. As my English is not perfect, some things I'll say might sound weird. Here is a demo of what I am doing: ![Screeenshot](https://i.stack.imgur.com/A1PMi.png) * IF D*x* Type Data * IF V*x* Type Voice * IF anything else, Type Autres. *x* is a number. There are no other types, only “Data”, “Voice” and “Autres”. It may be my own formula that is incorrect, if you have another way to type this, feel free to do so.
2017/02/02
[ "https://superuser.com/questions/1174609", "https://superuser.com", "https://superuser.com/users/674711/" ]
I don't have the french version, so I can't rule out that SI and NB.SI are good or bad. Assuming they're good, here is the formula broken down: ``` =SI ( NB.SI ( A2; "D" ); * "Data"; "SI < ( NB.SI ( A2; "V" ); * "Voice"; "Autres" )" < ) ``` This tells me there are two " that are incorrect. These are highlighted above using the <. In addition the NB.SI formula is incomplete. NB.SI will return the amount of matches, but IF only checks for a true of false, so we need to change the amount of matches in a true or false by evaluating if they're more than 0. These are highlighted above using an \*. The correct formula would be ``` =SI ( NB.SI ( A2; "D" )>0; "Data"; SI ( NB.SI ( A2; "V" )>0; "Voice"; "Autres" ) ) ``` or: ``` =SI(NB.SI(A2;"D")>0;"Data";SI(NB.SI(A2;"V")>0;"Voice";"Autres")) ```
41,668,251
Given a list of non negative integers, I would like to arrange them such that they form the largest number. Given [1, 20, 23, 4, 8], the largest formed number is 8423201. But I want to figure how the order of the variables in compareTo method influences the result of Arrays.sort. e.g, what's the difference between (s2 + s1).compareTo(s1 + s2) and (s1 + s2).compareTo(s2 + s1). ``` enter code here private static class NumbersComparator implements Comparator<String> { @Override public int compare(String s1, String s2){ return (s2 + s1).compareTo(s1 + s2); } } String strs = {"1", "20", "23", "4", "8"}; Arrays.sort(strs, new NumbersComparator()); ```
2017/01/16
[ "https://Stackoverflow.com/questions/41668251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6939031/" ]
Sort the numbers with reverse (*descending*) [lexicographical order](https://en.wikipedia.org/wiki/Lexicographical_order), that is the numbers are sorted with `String`(s) in the default *reverse order*. Like, ``` String[] strs = { "1", "20", "23", "4", "8" }; Stream.of(strs).sorted(Comparator.reverseOrder()) // <-- sort in reverse order .forEachOrdered(System.out::print); System.out.println(); ``` Which outputs ``` 8423201 ``` Because `8` is greater than the first digit of all the other numbers, `4` is the next, and so on.
14,385,003
I have a database (on DB2 9.7) A in which suppose I have tables X,Y,Z...n Now I have created same tables X,Y,Z...n in database B. I want to provide same GRANTs to users in database B as it was in database A. So based on SYSCAT.TABAUTH I am trying to generate GRANT SQLs. I have written the following query for it: ``` db2 "select 'GRANT '|| case INSERTAUTH WHEN 'Y' THEN 'INSERT,' WHEN 'N' THEN ' ' END|| case ALTERAUTH WHEN 'Y' THEN 'ALTER,' WHEN 'N' THEN ' ' END|| case DELETEAUTH WHEN 'Y' THEN 'DELETE,' WHEN 'N' THEN ' ' END|| case SELECTAUTH WHEN 'Y' THEN 'SELECT,' WHEN 'N' THEN ' ' END|| case UPDATEAUTH WHEN 'Y' THEN 'UPDATE,' WHEN 'N' THEN ' ' END|| ' ON '||TABSCHEMA||'.'||TABNAME||' TO '||GRANTEE from SYSCAT.TABAUTH where INSERTAUTH='Y' OR ALTERAUTH='Y' OR DELETEAUTH='Y' OR SELECTAUTH='Y' OR UPDATEAUTH='Y'" ``` However, the problem I am facing is of the additional ',' at end. Suppose a user has only Insert auth, the above query will generate GRANT sql as: ``` GRANT INSERT, ON SCHEMA.TABLE TO GRANTEENAME or if user has insert and select grants then: GRANT INSERT,SELECT, ON SCHEMA.TABLE TO GRANTEENAME ``` How can I solve this? Please help..
2013/01/17
[ "https://Stackoverflow.com/questions/14385003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/969753/" ]
Add a function parameter and call it on success: ``` function myfunction(callback) { var value = "myvalue"; var post_url = "ajax.php"; $.post( post_url, { value: value, }, function(responseText){ var json = JSON.parse(responseText); if(json.success) { console.log('success'); //call callback callback(); } } ); } } ```
122,836
I am trying to search all input elements that starts with a partcular set of characters such as 'idAcc' where my VF page has two inputfields with id = idAccFN and id= idAccLN respectively. ``` <apex:inputField id="idAccFN" value="{!cr.FirstName__c}" /> <apex:inputField id="idAccLN" value="{!cr.LastName__c}" /> ``` I'm using the below JQuery syntax but thats working partially ... Explained in comments below .. Kindly help. ``` var j$ = jQuery.noConflict(); j$(document).ready(function(){ jQuery( 'input[id$=Name]' ).val('Foo'); // ID ending with Name working jQuery( 'input[id^=idAcc]' ).val('Apu') //Id starting with idAcc not working }); ```
2016/05/21
[ "https://salesforce.stackexchange.com/questions/122836", "https://salesforce.stackexchange.com", "https://salesforce.stackexchange.com/users/16234/" ]
the Id you set gets prepended by VF, so you need to do a "contains" selector. And if you want each element on the page, you need to use a ".each", like this: ``` j$(document).ready(function(){ jQuery( 'input[id*=Name]' ).each(function(el){ el.val('Foo'); // do something with the input here. }); ```
67,547,166
This is the **Home Page** Code ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>HZ Everything Business</title> <link rel="stylesheet" href="home.css" /> <style> .menu { height: 70px; width: 70px; right: 70px; top: 20px; text-align: center; position: absolute; background: #fff; overflow: hidden; transition: all 0.2s ease; z-index: 999; } .menu.active { width: calc(100% - 140px); } .menu.active .menuContent * { opacity: 1; } .menu.active span i:nth-child(1) { transform: rotate(-45deg) translate(-50%, -50%); top: 50%; } .menu.active span i:nth-child(2) { transform: translateX(-100px); opacity: 0; } .menu.active span i:nth-child(3) { transform: rotate(45deg) translate(-50%, -50%); top: 50%; } .menu span { width: 70px; height: 70px; position: absolute; right: 0; cursor: pointer; background: #fff; z-index: 1; } .menu span i { position: absolute; transform-origin: 50% 50%; width: 45%; height: 2px; left: 0; right: 0; margin: auto; background-color: #ccc; transition: transform 0.3s ease, opacity 0.1s ease 0.1s; } .menu span i:nth-child(1) { top: 40%; } .menu span i:nth-child(2) { top: 50%; } .menu span i:nth-child(3) { top: 60%; } .menu .menuContent { position: absolute; width: 100%; height: 100%; line-height: 40px; right: 0px; text-align: center; } .menu .menuContent * { opacity: 0; } .menu .menuContent ul li { display: inline-block; margin-left: 50px; margin-right: 50px; color: #2d3235; transition: opacity 0.3s ease 0.3s; cursor: pointer; position: relative; } .menu .menuContent ul li:hover:before { opacity: 0.8; top: 13px; left: 20px; } .menu .menuContent ul li:hover:after { opacity: 0.8; bottom: 13px; left: -20px; } .menu .menuContent ul li:before, .menu .menuContent ul li:after { content: ""; position: absolute; width: 20px; height: 2px; background: #ccc; transition: all 0.3s ease; } .menu .menuContent ul li:before { transform: rotate(-55deg); left: 60px; top: -30px; opacity: 0; right: 0; margin: auto; } .menu .menuContent ul li:after { transform: rotate(-55deg); left: -60px; bottom: -30px; opacity: 0; right: 0; margin: auto; } </style> </head> <body> <div class='menu'> <span class='toggle'> <i></i> <i></i> <i></i> </span> <div class='menuContent'> <ul> <li>HZ Social Media Agency</li> <li>HZ WEBSITE & APP DEV</li> <li>HZ PHOTO & VIDEO EDITING</li> <li>OUR WORK</li> </ul> </div> </div> <script src="https://code.jquery.com/jquery-3.3.1.js" ></script> <script> $('.toggle').on('click', function() { $('.menu').toggleClass('active'); }); </script> <div class="bg"></div> </body> </html> ``` **CSS** ``` bg { height: 100%; width: 100%; background-color: blue; clip-path: polygon(100% 0, 100% 25%, 0 90%, 0 61%, 0 0); position: absolute; z-index: -1; } ``` I have tried everything I can do but it does not work , I tried changing the name of the CSS file even but it is still not working, any idea how I can fix that ? I have also tried putting it in the "styling tag as bg {} but still did not work , could it have something to do with where I typed the link ? under the title tags ?
2021/05/15
[ "https://Stackoverflow.com/questions/67547166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13097698/" ]
try this ``` foreach( $terms_arg as $display_term ){ if( $display_term->term_id != $queried_object->term_id ) { printf( '<div class="cat-list"><h3><a href="%s">%s</a></h3></div>', esc_url(get_term_link($display_term->term_id)), $display_term->name, ); } } ```
10,521
I just want to know whether both the usages are right or not. Also, do these usages depend on geography?
2011/01/29
[ "https://english.stackexchange.com/questions/10521", "https://english.stackexchange.com", "https://english.stackexchange.com/users/1749/" ]
It's a noun so it's necessary to specify the quantity. "One hundred" is the same as saying "a hundred," just like if you had six hundred it would be necessary to say "six hundred." The same rule applies to other nouns; you don't say "I have dollar" you say "I have one dollar" and you don't say "I have car" you say "I have a car." (or, of course, "I have six cars").
223,731
I have one store (base) and I need to create another root category to test a new strucutre out so my plan was to create a new `Root Category` and then tell magmi to import into that... No such luck. I've created a new root category called Testing. Here is a sample of the Data. ``` sku,categories 12345, [Testing]/Level1;;[Testing]/Level1/Level2;;[Testing]/Level1/Level2/Level3 ``` Every time I try and import this, I get this error: `On the fly category creator/importer v0.2.5 - Cannot find site root with names : Testing,Testing,Testing` Can anyone help me out with this one?
2018/04/25
[ "https://magento.stackexchange.com/questions/223731", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/50626/" ]
Can you please add the following to the index.php of your website ``` ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); ```
1,302,927
### Background By default, Microsoft [BitLocker](https://en.wikipedia.org/wiki/BitLocker) does not allow the user to enable full disk encryption (FDE) of the system disk, unless the PC has a compatible [TPM](https://en.wikipedia.org/wiki/Trusted_Platform_Module). However, if the "Allow BitLocker without a compatible TPM" option is turned on (under *Computer Configuration -> Administrative Templates -> Windows Components -> BitLocker Drive Encryption -> Operating System Drives -> Require additional authentication at startup*), then the BitLocker [wizard](https://en.wikipedia.org/wiki/Wizard_(software)) will permit FDE of the system disk. If this is done, then one of the wizard's dialogue boxes, headed "Choose how to unlock your drive at startup", will require the user to choose between two alternative authentication mechanisms: * Insert a USB flash drive; * Enter a password. If the user picks "Insert a USB flash drive", then typically the wizard will generate a "**startup key**" and will ask for a USB flash drive on which to write it. (The idea is that when wanting to boot the PC in the future, the user will *first* insert that USB flash drive into the PC and *then* switch on the PC. The Windows bootloader will then read the **startup key** from the flash drive in order to decrypt the system disk before booting Windows. I know people who do this in practice, and it works well. For more background, see e.g. [this](https://blogs.msdn.microsoft.com/mvpawardprogram/2016/01/12/securing-windows-10-with-bitlocker-drive-encryption/) and [this](https://superuser.com/questions/1075220/what-is-the-difference-between-a-bitlocker-startup-and-recovery-key).) ### My question When encrypting a drive with BitLocker, so as to require a **startup key**, can the user specify *her own custom* **startup key** (e.g. if she has previously generated one with the wizard and wants to use it on additional PCs), or must she accept the key generated by the BitLocker wizard? Alternatively, if she must accept the key created by the BitLocker wizard (at least while the wizard is running) then as a workaround, can she *later* replace this with her preferred **startup key**? Via the BitLocker Manage Keys interface, perhaps?
2018/03/13
[ "https://superuser.com/questions/1302927", "https://superuser.com", "https://superuser.com/users/-1/" ]
You cannot make your own startup key or import startup keys, BUT: > > When encrypting a drive with BitLocker, so as to require a startup > key, can the user specify her own custom startup key (e.g. if she has > previously generated one with the wizard and wants to use it on > additional PCs), or must she accept the key generated by the BitLocker > wizard? > > > In this example, if she is wishing to use the *same* startup key on multiple computers, it cannot be done. But, she CAN have the startup keys from different computers on the same USB. I do want to add that you may think that manage-bde -add could be used to "add" your own startup key as a protector, but it just creates a new startup key and adds it as a protector.
22,726,562
I cannot understand the difference between `interleaving` and `concatenation` Interleaving ``` proc sort data=ds1 out=ds1; by var1; run; proc sort data=ds2 out=ds2; by var1; run; data testInterleaving ; set ds1 ds2 ; run ; ``` Concatenation ``` data testConcatenation; set ds1 ds2; run; ``` I tested these and the resulting datasets were exactly the same except for the order of observations which I think does not really matter. The two resulting datasets contain exactly the same observations. So, what is the difference, except for order?
2014/03/29
[ "https://Stackoverflow.com/questions/22726562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2178635/" ]
Interleaving, as CarolinaJay notes, is combining `SET` with `BY`. It is not merging, and it is not just sorting prior to setting. For example, let's create a pair of datasets, the female and the male members of `sashelp.class`. ``` data male female; set sashelp.class; if sex='F' then output female; else output male; run; proc sort data=male; by name; run; proc sort data=female; by name; run; data concatenated; set male female; run; data interleaved; set male female; by name; run; ``` Now, look at the datasets. `Concatenated` is all of the males, then all of the females - it processes the `set` statements in order, exhausting the first before moving onto the second. `Interleaved` is in name order, not in order by sex. That's because it traverses the two (in this case) `set` datasets by name, keeping track of where it is in the `name` ordering. You can add debugging statements (Either use the data step debugger, or add a `put _all_;` to the datastep) to see how it works.
61,399,681
I am new to jQuery and I am appending some paragraphs dynamically with a socket inside a div, so I want to know if the number of paragraphs exceeds certain number. If the number of paragraphs exceed, say 10, I would like to stay with the last 10 and remove the other ones. This is how I am appending the paragraphs: ``` socket.on("response", function (text) { $("div.paragraphs").append( '<p>' + text + '</p>' ); }); ``` This is what I am trying: ``` $("div.paragraphs").change(function () { const matched = $("p"); console.log("Number of paragraphs in div = " + matched.length); }); ``` However, nothing shows in the console. I would like to do something like this, but don't know if I am correct: ``` $("div.paragraphs").change(function () { const matched = $("p"); if(matched.length){ $('p:lt(matched.length-10)', 'div.paragraphs').remove() } }); ``` Is this the correct approach?
2020/04/24
[ "https://Stackoverflow.com/questions/61399681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6719765/" ]
Why are you Getting a 503 Error? -------------------------------- GoDaddy hosting throws a `503 ERROR` if either: **a)** Your website met its maximum concurrent connection limit or **b)** If your hosting account uses up all of its available resources (which is probably the case here since you mention having to load large video files exceeding 1 GB Resolution ---------- ### Depending on your hosting account type the solution is as follows: **Linux Hosting (cPanel):** End the PHP processes in your Linux Hosting account (for more info click [here](https://www.godaddy.com/help/end-php-processes-in-my-linux-hosting-account-16119)) **Windows Hosting (Plesk):** Try [recycling your application pool](https://www.godaddy.com/help/recycle-your-application-pool-16131) **Web Hosting (Linux):** End processes using [Manage system process (Linux) in my Web & Classic Hosting account](https://www.godaddy.com/help/manage-system-process-linux-in-my-web-and-classic-hosting-account-5980) **Web Hosting (Windows):** Try [Recycle your application pool(windows)](https://img4.wsimg.com/support/pdf/WebHosting/webhostingguide-041420.pdf) Another Possible Issue ---------------------- **If you use WordPress** along with your website one of your plugins may be causing the issue. Try disabling and enabling all of them and enable them one at a time to see if they are causing the issue. Troubleshooting and prevention: ------------------------------- Make sure you have enough hard drive space whenever you load large videos so you don't get the `503 ERROR`! **Hope this was helpful and I hope this solved your issue.** *Note: Nothing showed in your error log since in essence there was no real error. Nothing went wrong in the code as you can see in the solutions above.*
6,045,317
I have a small database with several hundred resources of varying types (medical, education and research, for example). Each resource will need to be identified by its region. Some of the resources serve multiple regions. I need to be able to define each resource by its type, and it's region. Since one region will have many resources, and one resource can serve many counties I figure I should have a junction table between them, right? My question is, should I have a junction / linking table for each resource type? Should I have a table of education\_resources, regions and link them with a junction table education\_regions? And do the same thing for the rest of the categories?
2011/05/18
[ "https://Stackoverflow.com/questions/6045317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/619741/" ]
I don't know if need to use CSV only, but a good plugin/function that I use is this one: <http://codeigniter.com/wiki/Excel_Plugin/> It's works with CodeIgniter Query system for exporting stuff to Excel. I use it a lot and never have problems with it.
43,923
The following problem is homework of a sort -- but homework I can't do! The following problem is in Problem 1.F in *Van Lint and Wilson*: > > Let $G$ be a graph where every vertex > has degree $d$. Suppose that $G$ has > no loops, multiple edges, $3$-cycles > or $4$-cycles. Then $G$ has at least > $d^2+1$ vertices. When can equality > occur? > > > I assigned the lower bound early on in my graph theory course. Solutions for $d=2$ and $d=3$ are easy to find. Then, last week, when I covered eigenvalue methods, I had people use them to show that there were no solutions for $d=4$, $5$, $6$, $8$, $9$ or $10$. (Problem 2 [here](http://www.math.lsa.umich.edu/~speyer/PSet6.pdf).) I can go beyond this and show that the only possible values are $d \in \{ 2,3,7,57 \}$, and I wrote this up in a [handout](http://www.math.lsa.umich.edu/~speyer/Solution6.pdf) for my students. Does anyone know if the last two exist? I'd like to tell my class the complete story.
2010/10/28
[ "https://mathoverflow.net/questions/43923", "https://mathoverflow.net", "https://mathoverflow.net/users/297/" ]
This is the [Moore graph](http://en.wikipedia.org/wiki/Moore_graph), which is a regular graph of degree $d$ with diameter $k$, with maximum possible nodes. A calculation shows that the number of nodes $n$ is at most $$ 1+d \sum\_{i=0}^{k-1} (d-1)^i $$ and as you mentioned it can be shown by spectral techniques that the only possible values for $d$ are $$ d = 2,3,7,57. $$ Example for $d=7$ is the [Hoffman–Singleton graph](http://en.wikipedia.org/wiki/Hoffman-Singleton_graph), but for the case $d=57$ it is still open. See Theorem 8.1.5 in the book "[Spectra of graphs](http://homepages.cwi.nl/~aeb/math/ipm.pdf)" by Brouwer and Haemers for reference.
31,533,155
I am using Zotero as a plugin in Firefox on a Ubuntu12.4 machine. Since last week, the BibTex format for export seems to have disappeared from the options in the preferences. I have absolutely no idea why and I don't really care why. I simply want to get it back since it worked before. So I am looking for explanation on how to reinstall this option and eventually on where to get the format. I tried to desactivate and reactivate the zotero plug-in but it did not work. Thanks for any help
2015/07/21
[ "https://Stackoverflow.com/questions/31533155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4799951/" ]
Use a parameterized query and set the parameter type to [`Datetime`](https://msdn.microsoft.com/en-us/library/system.data.sqldbtype(v=vs.110).aspx): ``` SqlCommand cmd = new SqlCommand( "INSERT INTO ... (..., datetimecolumn, ...) VALUES (..,@datetimeparameter,...", connection); SqlParameter datetimeParameter = new SqlParameter( "@datetimeparameter", SqlDbType.Datetime); datetimeParameter.Value = <your C# variable of type Date>; ... cmd.ExecuteNonQuery(); ``` Using a framework like Entity Framework would take care of a lot of the boilerplate coding. Using [`SqlBulkCopy`](https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy(v=vs.110).aspx) is another viable approach. What does **not** work is passing in values as hard coded strings in T-SQL. Aside from SQL injection prone, slow and unperformant, there are countless issues around the combination of client (app) locale, server locale and SQL Server locale settings ([`SET DATEFORMAT`](https://msdn.microsoft.com/en-us/library/ms189491.aspx)). For the record: there is a locale independent datetime format in SQL Server, namely the `YYYYMMDD hh:mm:ss` format. Whenever you *must* use a T-SQL string to represent a date, use this format as is locale agnostic. Also you might want to learn a bit about [SSIS](https://msdn.microsoft.com/en-us/library/ms141026.aspx) as it does what you're trying to achieve out-of-the-box (there is an [SSIS Excel source](https://msdn.microsoft.com/en-us/library/ms141683.aspx)).
5,853,804
I am working on a camera application. For first time if I capture image its working fine but if I take a picture again its throwing a error > > ERROR/dalvikvm-heap(2398): 10077696-byte external allocation too large for this process." VM won't let us allocate 10077696 bytes" and finally"05-02 05:35:38.390: ERROR/AndroidRuntime(2398): FATAL EXCEPTION: main > 05-02 05:35:38.390: ERROR/AndroidRuntime(2398): java.lang.OutOfMemoryError: bitmap size exceeds VM budget > > > and application force closes..how to handle this how to clear heap and vm? please help.. Thanks in advance..
2011/05/02
[ "https://Stackoverflow.com/questions/5853804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/707942/" ]
I found the answer. I used the following code: ``` BitmapFactory.Options bfOptions=new BitmapFactory.Options(); bfOptions.inDither=false; //Disable Dithering mode bfOptions.inPurgeable=true; //Tell to gc that whether it needs free memory, the Bitmap can be cleared bfOptions.inInputShareable=true; //Which kind of reference will be used to recover the Bitmap data after being clear, when it will be used in the future bfOptions.inTempStorage=new byte[32 * 1024]; CameraTricks.SdCardImage= BitmapFactory.decodeFile(CameraTricks.yu,bfOptions); CameraTricks.yu is my path to bitmap ```
91,635
I work in an office with 8 people. We have no allocated seating. Which I am quite cool with. However, recently the tidiness has gotten quite out of hand. Papers, coffee stains, and some brochures scatter over the tables. It's quite a rude shock when I almost put my laptop down on someone's old coffee stain in the morning. Now my daily ritual is to wipe away all leftover hairs and dirt and choose an area that has less clutter. We have introduced individual shelf compartment for us to store our personal goods. However, most of them still do not have the habit to clear up after themselves when they leave at the end of the work day. I am quite concerned about how to keep the cleanliness, and would like to know if anyone has any experience in maintaining cleanliness in a free seating plan office?
2017/05/26
[ "https://workplace.stackexchange.com/questions/91635", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/70574/" ]
The answer would be either: 1. To hire a cleaner 2. Have allocated desks
46,986,793
I'm trying to create a default value in Sequel: ``` create_table(:my_table) do primary_key :id # .......... Timestamp :created_at, default: "now()" ``` After running a migration, it generates a table with this column definition: ``` --........ created_at timestamp without time zone DEFAULT '2017-10-28 12:26:00.129157'::timestamp without time zone, ``` But what I want is the value "now()" to be set when I'm inserting a new value.
2017/10/28
[ "https://Stackoverflow.com/questions/46986793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8841042/" ]
I know this was asked a while ago but I had a similar problem that I solved by using `Sequal.lit` `Timestamp :created_at, default: Sequel.lit("now()")`
60,295,386
I am trying to delete a row in my table. Here is my sample code ``` String DBDate = new String(); Long date = new Date().getTime(); String dateToday = date.toString(); dbobj.clear(); dbobj.put(LAST_TIME_ANSWERED, ""); int hasDB = dbobj.getFromDB(tableName,column key, primary key); if(hasDB != 0) { DBDate = dbobj.get(LAST_TIME_ANSWERED); if(DBDate != dateToday) { dbobj.deleteClientDB(tableName, column key, primary key); } } ``` How could I change the date of a timer? Any help would be nice. Thanks in advance!
2020/02/19
[ "https://Stackoverflow.com/questions/60295386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12923933/" ]
This is awkward to achieve in java, because you need to run a job on a schedule to achieve this. You should strongly consider using the mysql event scheduler. See [this answer](https://stackoverflow.com/a/14806127/2051454) for an example of this. When you insert the row in the db you should set up an event that is triggered exactly once, 24-hours later, with the necessary sql to delete the row. You would end up with one event per row. Alternatively, with java and a properly configured server, after each row insert you could add a cron or quartz job that would trigger once, 24-hours later, that would invoke a java function to remove the row. This is harder than using the db's built-in event scheduler. Depending on your JEE version (>6) you could use an EJB 3.1 timer, as detailed in [this blog post](http://www.adam-bien.com/roller/abien/entry/simplest_possible_ejb_3_16). Of these options, the db event scheduler is probably the best, because the others can go wrong if the JEE sever is down.
33,081,669
I'm taking a Udacity course on making a site responsive and I tried applying `<meta name="viewport" content="width=device-width, initial-scale=1.0">` on a non-responsive site. The result was that page did not try to fit the device's width. Am I misunderstanding something? [![enter image description here](https://i.stack.imgur.com/MBqE8.png)](https://i.stack.imgur.com/MBqE8.png)
2015/10/12
[ "https://Stackoverflow.com/questions/33081669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1242842/" ]
Your html page probably has a wrapping container that has a fixed width in pixel. `<meta name="viewport" content="width=device-width, initial-scale=1.0">` will not make your webpage responsive, but rather has an effect on the ratio sizes that i.e. fonts will be rendered with. Try giving the container a width of `100%` and go from there.
10,330,598
I'm using Netbeans, SWING to get data from mysql table to jTable. I done it, but headers of table. Headers are the same like in mysql table. How to change headers of jTable after getting data from DB? P.S. Default headers don't works in this issue. This is auto-generated code: @SuppressWarnings("unchecked") // private void initComponents() { bindingGroup = new org.jdesktop.beansbinding.BindingGroup(); ``` progressjournalPUEntityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("progressjournalPU").createEntityManager(); pupilsQuery = java.beans.Beans.isDesignTime() ? null : progressjournalPUEntityManager.createQuery("SELECT p FROM Pupils p"); pupilsList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : pupilsQuery.getResultList(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Журнал успеваемости"); setResizable(false); jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { }, new String [] { "#", "ФИО", "Курс", "Предмет", "Оценка" } ) { Class[] types = new Class [] { java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } }); org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, pupilsList, jTable1); org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${pupilMark}")); columnBinding.setColumnName("Pupil Mark"); columnBinding.setColumnClass(String.class); columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${pupilSubject}")); columnBinding.setColumnName("Pupil Subject"); columnBinding.setColumnClass(String.class); columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${pupilCourse}")); columnBinding.setColumnName("Pupil Course"); columnBinding.setColumnClass(String.class); columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${pupilName}")); columnBinding.setColumnName("Pupil Name"); columnBinding.setColumnClass(String.class); columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${pupilId}")); columnBinding.setColumnName("Pupil Id"); columnBinding.setColumnClass(Integer.class); bindingGroup.addBinding(jTableBinding); jTableBinding.bind(); jScrollPane1.setViewportView(jTable1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(15, 15, 15) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 616, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(14, Short.MAX_VALUE)) ); bindingGroup.bind(); pack(); ``` }// And this code is locked for editing.
2012/04/26
[ "https://Stackoverflow.com/questions/10330598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/568975/" ]
I used poi with version 3.12. The following dependency is also required: `compile 'org.apache.poi:ooxml-schemas:1.1'` see also <http://poi.apache.org/faq.html#faq-N10025>
21,536,218
Alright, so I'm trying to compare two columns, in two tables, in separate databases. I am going to warn you, I quite new to SQL. I am trying to write a query to do something like this: ``` If a field in tableA column2 contains a field from tableB column1 at least once, increment a counter ``` I want to know the value of the counter. Also, when I same "contains" I mean in a `substr()` kind of way (fe. "marketplace" contains the word "market"). Can anyone help me out with this, or at least point me in the right direction?
2014/02/03
[ "https://Stackoverflow.com/questions/21536218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/989859/" ]
I think this is what you are after. it will obviously not loop, but it accomplishes what you are trying to do. ``` select a.c2, count(case when a.c2 = b.c1 then 1 else 0 end) as c1count from table1 as a left join table2 as b on a.key = b.key group by a.c2 ``` or something like that. that join will probably need some work, but it is hard to say without more information. good luck.
50,644,513
I have a scenario where I need to identify a result. Below is a sample excel cells with three columns `Prod Name, Qty and Result`. ``` Prod Name Qty Result abc 10 zyz 9 test1 5 ``` If the product name is `abc or zyz` and its qty is 10, then I need to add text `Refill` in Column Result. For any other product. in this case `test1` and its qty is 5, then I need to add the same text `Refill` in Column Result. Else it will always be `Don't Refill`
2018/06/01
[ "https://Stackoverflow.com/questions/50644513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7468305/" ]
Try this formula: ``` =IF(OR(AND(OR(A1="abc", A1="xyz"), B1=10), AND(AND(A1<>"abc", A1<>"xyz"), B1=5)), "Refill", "Don't Refill") ```
856,665
I basically have something like this: ``` void Foo(Type ty) { var result = serializer.Deserialize<ty>(inputContent); } Foo(typeof(Person)); ``` The `Deserialize<ty>` doesn't work because it expects `Deserialize<Person>` instead. How do I work around this? I'd also like to understand how generics work and why it won't accept `ty` which is `typeof(Person)`. EDIT: I ought to have mentioned that this is a contrived example. I cannot actually change the signature of the function because it implements an interface. EDIT: serializer is a JavascriptSerializer and implemented as an action filter here. It is called thusly: ``` [JsonFilter(Param="test", JsonDataType=typeof(Person))] ``` Solution -------- Based on Marc and Anton's answers: ``` var result = typeof(JavaScriptSerializer).GetMethod("Deserialize") .MakeGenericMethod(JsonDataType) .Invoke(serializer, new object[] { inputContent }); ```
2009/05/13
[ "https://Stackoverflow.com/questions/856665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50475/" ]
If `ty` is known at compile-time, why don't just ``` void Foo<T>() { var result = serializer.Deserialize<T>(inputContext); } ``` Otherwise, ``` MethodInfo genericDeserializeMethod = serializer.GetType().GetMethod("Deserialize"); MethodInfo closedDeserializeMethod = genericDeserializeMethod.MakeGenericMethod(ty); closedDeserializeMethod.Invoke(serializer, new object[] { inputContext }); ```
53,452,226
In C++, if I try to do this: ``` std::function<void(bool,void)> ``` then the compiler will throw errors. Why is this? It's useful in many cases. One example: ``` //g++ -std=c++17 prblm.cpp #include <cstdio> #include <functional> template<class type_t> class some_callback { public: using callback_t = std::function<void(bool,type_t)>; some_callback(callback_t _myfunc) { this->myfunc = _myfunc; } callback_t myfunc; }; using callback_with_just_bool = some_callback<void>; using callback_with_an_int_too = some_callback<int>; int main() { auto my_callback_with_int = callback_with_an_int_too([](bool x, int y) { }); //OK auto my_callback_just_bool = callback_with_just_bool([](bool x) { }); //Error auto my_callback_just_bool = callback_with_just_bool([](bool x,void z) { }); //Error return 0; } ``` This allows for a very clean syntax if the user would like to optionally have additional data in their callback, but not have to. However, the compiler will reject code that tries to initialize an object of `callback_with_just_bool` Why is it like this, and is there a clean way around it? Thanks. Edit: The specific reason I'm trying to do this, in real world code, is in an event system. There is data provided to the event system about an individual object that wishes to *conditionally* receive events (e.x. "if you're close enough to the source, you'll receive a sound event") as well as data provided to a callback *about* the event (e.x. "a 10khz noise at X200 Y200"). Most of the time, the data needed to check the requirements will exist inside the data provided to the callback *about* the event, but I wanted to provided an optional additional data structure if that was not the case. Hence, the user would specify "void" if they didn't need this additional data structure.
2018/11/23
[ "https://Stackoverflow.com/questions/53452226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10438811/" ]
*"Why is this?"* Because the only permitted usage of `void` in a parameter list is to show that the function doesn't accept any parameters. From [[function]](https://en.cppreference.com/w/cpp/language/function): > > `void` > > > Indicates that the function takes no parameters, it is the exact synonym for an empty parameter list: `int f(void);` and `int f();` declare the same function. Note that the type void (possibly cv-qualified) cannot be used in a parameter list otherwise: `int f(void, int);` and `int f(const void);` are errors (although derived types, such as `void*` can be used) > > > *"Is there a clean way around it?"* I would suggest to specialize for `void`: ``` template<class type_t> class some_callback { std::function<void(bool,type_t)> myfunc; }; template<> class some_callback<void> { std::function<void(bool)> myfunc; }; ```
1,782,545
How / where do I store settings in a windows mobile 6 application (targeting compact framework 3.5)? Is there some mechanism like the properties.settings for desktop?
2009/11/23
[ "https://Stackoverflow.com/questions/1782545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7021/" ]
Unfortunately, the System.Configuration is missing from .NET Compact Framework. You can use the [Smart Device Framework](http://www.opennetcf.com/Products/SmartDeviceFramework/tabid/65/Default.aspx) or you can just create a class that stores your settings and the save it and load it using a [XmlSerializer](http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx).
115,147
Every time I go to break a block in Minecraft it opens the in-game menu. I don't know how to stop this from happening, any ideas?
2013/04/25
[ "https://gaming.stackexchange.com/questions/115147", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/47528/" ]
Try looking at your controls, I think that you have it so that if you left-click it opens the menu instead of Esc.