INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
instantiation class before defined in php.net the following is written: Classes should be defined before instantiation (and in some cases this is a requirement). can anyone give an example when it is required? because a typical use of it doesn't require, like in this example that works ok: <?php $class = "a" ; $ob = new $class() ; class a { var $city = "new york" ; } echo $ob->city ; ?>
This won't work: new Foo; if (true) { class Foo { } } Conditionally declared classes must come first. Basically, anything that's at the "top level" of the file is handled directly by the parser while parsing the file, which is the step before the runtime environment executes the code (including `new Foo`). However, if a class declaration is nested inside a statement like `if`, this needs to be evaluated by the runtime environment. Even if that statement is guaranteed to be true, the parser cannot evaluate `if (true)`, so the actual declaration of the class is deferred until runtime. And at runtime, if you try to run `new Foo` before `class Foo { }`, it will fail.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "php, class, instantiation" }
Meaning of "Angeln von Unbefugten" From the _Hohlspiegel_ column of Der Spiegel, which is intended for funny/interesting sentences from other sources: > Schild an einem Fischweiher in Saarbrücken-Ensheim: > > Baden, Verunreinigen, Einlassen von Hunden, Angeln von Unbefugten ist verboten! I guess the reason this is funny is the notion of unauthorized people being fished (instead of them doing the fishing.) In that sense, "Angeln von Unbefugten" is ambiguous. How can we make it clear? Would it be "Angeln **für** Unbefugten"?
First: You are right. The reason this is funny is the notion of unauthorized people being fished (instead of them doing the fishing.) Beside the other already posted possibilities I would also use: > Angeln durch Unbefugte ist verboten! or you could use > unbefugtes Angeln ist verboten! A remark from my subjective feeling: To fish in Germany you need two things: an official license (Fischereischein or Angelschein) and a permission to fish in this specific river/lake. If you use `widerrechtlich` I think there is a missing `Fischereischein`, with `unbefugt` I think, you have the Fischereischein, but not the permission to fish here. So in this case I would prefer `unbefugt`, because the owner of the tarn wants to protect his own rights. But that's my subjective view (I'm no fisher and no lawywer).
stackexchange-german
{ "answer_score": 3, "question_score": 3, "tags": "meaning, preposition" }
Has SHA256 but why is it not used? After performing an upgrade on Apache and modssl, I get a security warning in the security logo of the URL bar in Chrome when visiting my website on Apache server: > The site is using outdated security settings that may prevent future versions of Chrome from being able to safely access it. I have checked that the certificate contains both SHA1 and SHA256 fingerprints and is not expired. When viewed with Firefox, there is no issue. However, a check with Qualys shows the signature algorithm as SHA1 with RSA instead of SHA256. Also, the connection is using TLS 1.2. What could be the cause of such warning and how to solve it? Sorry, I just realize: This site which is using SHA1 has no such warning, but this site does.
A _fingerprint_ (sometimes _thumbprint_ ) is not something that is in the certificate, instead it's a hash calculated after the fact and shown to facilitate easier manual comparison of certificates. It's important not to confuse this with the certificate's signature, which is an actual value in the certificate. From the question it sounds like the signature of this certificate is indeed based on SHA-1.
stackexchange-serverfault
{ "answer_score": 4, "question_score": 3, "tags": "https, apache 2.4, mod ssl" }
Accessing the front facing camera. iPhone/iPod 4 Hey I was wondering how I can access the front facing camera. Maybe there's some guide for it? But I don't want all buttons etc. I just want to access the from facing camera, I don't ant the button to take a photo or anything like that.
You can access the front facing camera like: picker.cameraDevice = UIImagePickerControllerCameraDeviceFront; Check out the UIImagePickerController Class Reference
stackexchange-stackoverflow
{ "answer_score": 17, "question_score": 5, "tags": "iphone, objective c, camera" }
Difference between "my whole life" and "all my life"? Is there any difference between both expressions? I'd say that _my whole life_ is better suited for use it in the middle or at the end of a sentence, whilst _all my life_ is better for start a sentence. Is that correct? Or are there any other differences?
"My whole life" is used as a noun. Let's look at the example above. My whole life has been filled with disappointments. The subject of this sentence is the noun phrase "my whole life". "All my life" is an adverbial phrase and functions as an adverb in a sentence and answers the question how long: How long have you been disappointed? I have been disappointed all my life. But in spoken English, these rules are not fixed in stone and these expressions are sometimes used interchangeably.
stackexchange-english
{ "answer_score": 2, "question_score": 3, "tags": "meaning, word choice" }
Laravel. Sort by user role, relations I want to sort the users by role and I would like the user to have another role disappear. **Controller** $users = User::with(['roles' => function($query) { $query->where('name','=','Admin'); }])->get(); **View** @foreach($users as $user) <tr> <td>{{$user->id}}</td> <td>{{$user->name}}</td> <td>{{$user->email}}</td> <td> @foreach ($user->roles as $role) {{$role->name}} @endforeach </td> </tr> @endforeach It does not pass the role, but displays the user data. I only want user data from the `Admin` role. I don't want to display `John Doe`. Thx for help.
You can filter by relation using `whereHas` Try the following $users = User::with('roles')->whereHas('roles', function($query) { $query->where('name', 'Admin'); })->get();
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "php, laravel" }
Description of Floor Function Correct? Is my description of the floor function correct? $$ f = \begin{cases} \mathbb{R} \rightarrow \mathbb{Z} \\\ x \mapsto z = \inf(x) \end{cases} $$ Explanation: The floor function maps a real number $x$ to the smallest whole number less than or equal to $x$. The infimum of is the largest lower bound of a set. The above stated function $f$ maps a real number $x$ to the largest whole number $z$ for which $z \leq x$, which is the definition of the floor function. Hence $f = \operatorname{floor}$.
Inf should be defined on a set, not one real number. Furthermore, the floor function maps a real number $x$ to the **largest** integer less than or equal to $x$, so it could be defined as floor$(x)=\sup\\{z\in\mathbb Z|z\le x\\}$.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "functions, discrete mathematics, ceiling and floor functions" }
leading space with regex match A newbie to regex, I'm trying to skip the first set of brackets `[word1]`, and match any remaining text bracketed with the open bracket and closing brace `[...}` Text: `[word1] This is a [word2]bk{not2} sentence [word3]bk{not3}` Pattern: `[^\]]\[.*?\}` So what I want is to match `[word2]bk{not2}` and `[word3]bk{not3}`, and it works, kind of, but I'm ending up with a leading space on each of the matches. Been playing with this for a couple of days (and doing a lot of reading), but I'm obviously still missing something.
\[[^} ]*} Try this.See demo . <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "regex, vba" }
Move data from multiple rows to a single row in SQL Server I have a table as show below- F1 F2 F3 F4 A AB NA NA A NA BC NA A NA NA CD B UV NA NA B NA WX NA B NA NA YZ C ABC NA NA C NA BCD NA C NA NA XYZ I need to group by column F1 and choose values for consecutive columns not equal to 'NA'. F1 F2 F3 F4 A AB BC CD B UV WX YZ C ABC BCD XYZ I am using the following code but it is not working correctly. SELECT F1 ,MAX(ISNULL(F2 ,'')) as F2 ,MAX(ISNULL(F3 ,'')) as F3 ,MAX(ISNULL(F4 ,'')) as F4 FROM test group by F1; Please help.
Try this: SELECT F1 ,MAX(ISNULL(NULLIF(F2, 'NA') ,'')) as F2 ,MAX(ISNULL(NULLIF(F3, 'NA') ,'')) as F3 ,MAX(ISNULL(NULLIF(F4, 'NA') ,'')) as F4 FROM test group by F1; Note that the NULLIF will return NULL if the value of the first parameter is the same as the value of the second parameter.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "sql, sql server" }
Open HDMV PGS subtitles in GNU/Linux I wanted to know if there's any software in GNU/Linux which can read BluRay subtitles (HDMV PGS). I'm not talking about making an OCR to convert them to SRT like everyone asks, but just reading them to see the timing of each line, and open the image representing the writings in each line. I want to read their content without having to play the whole film, I don't care about being able to edit the lines or converting the subtitle in any other format. According to `mkvextract` the extension should be `.sup`, but when extracting some HDMV PGS subtitles with that extension, neither GNOME Subtitles Edit nor Gaupol seem able to read it. Does anyone know of any software which is able to read them?
Turns out subtitleedit does the work just fine. It has an option to import various graphic subtitles in the Menu context. Arch Linux has an AUR package for it.
stackexchange-unix
{ "answer_score": 2, "question_score": 4, "tags": "linux, video subtitles, blu ray" }
How to not allow the user to enter a value more than 190 in uitextfield? I have to allow values less than 190 in `uitextfield` while entering itself.we should not allow user to enter `1` to `9` digits after `19`. Can anyone please provide me some info regarding this. I tried the below code.But it's allowing more than `190`. if countElements(textField.text!) + countElements(string) - range.length < 4 { var floatValue : Float = NSString(string: toString(textField.text)).floatValue return floatValue < 190.0 }
How i would do it is set the the uiviewcontroller containing the uitextfield as the delegate of the text field. Then add this: //If number of characters needs to be less than 190 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string]; if([newString length]>190){ return NO; } return YES; } //If value needs to be less than 190 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string]; if([newString intValue]>190){ return NO; } return YES; }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "ios, swift, uitextfield" }
what are the APIs used by various programming languages to develop Web Services based on WS-I organization standards For developing our application to communicate on network irrespective of platform or language we are using Web Services technology. The standards to develop these applications is given by WS-I (Web Services Interoperability Organization). So, what languages provided what API's to develop these Applications.
As of my Knowledge, for **JAVA** _Network Communication(HTTP)_ \- Servlet/EJB API _XML_ \- JAXP (Java API for XML Processing), JAXB (Java Architecture for XML Binding) _UDDI_ \- JAXR (Java API for XML Registries) _SOAP_ \- SAAJ (SOAP with Attachments API for Java) _WSDL_ \- WSDL4j WS-I released two versions. 1. BP 1.0 2. BP 1.1 Java released JAX-RPC API for BP 1.0, JAX-WS API for BP 1.1 **NOTE** : Correct me, if I am wrong
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "xml, web services, soap, programming languages, uddi" }
Get Flat File Schema as CSV output when input data has newlines Consider my input data as below: <xmlnode>line1 line2 line3 </xmlnode> Right now, I have a map which maps input data to a flatfile schema. I am saving the flatfile as CSV. **Issue is :if input data is having newlines, then the csv format is getting corrupted. The content of 'xmlnode' should go to one single csv column.** Is there is any setting I need to handle this at flat file schema?
Create a functoid with code like the following: return input.Replace("\r", "").Replace("\n", " "); The idea is to replace any `\r\n` with a single space (and handle cases where there's a newline with no carriage return). Should fix your problem. If this is a problem that will occur routinely on multiple/all nodes from your input, then you might consider running that as a regular expression on the entire message as a string after mapping (rather than having every node pass through your scripting functoid). As Dan suggessted in Comments, double quotes is also required to save data with \n (new line) in one cell of a csv.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "csv, biztalk, flat file" }
Shapely: Polygon from String? I have saved string representations of some Shapely Polygons: 'POLYGON ((51.0 3.0, 51.3 3.61, 51.3 3.0, 51.0 3.0))' Is there some fast way of directly converting it back to the Polygon type? Or do I need to manually parse the strings to create Polygon objects?
Shapely can directly parse this: import shapely.wkt P = shapely.wkt.loads('POLYGON ((51.0 3.0, 51.3 3.61, 51.3 3.0, 51.0 3.0))') print(P)
stackexchange-stackoverflow
{ "answer_score": 78, "question_score": 44, "tags": "python, shapely" }
How to refer to those fully-equipped houses people let to university students? I have a friend who rents in an one-story house. Just your common house: there's a living room, a kitchen, and three rooms (all of them occupied by university students). It something like this from the outside: !A tropical-style house with a wraparound porch supported by rough tree-trunk pillars. A small dormer window is just visible at the back of the house. The house is surrounded with palm trees and eucalyptus trees, and there's a brick-paved driveway or walkway visible in the foreground. All you can see of the house itself is one big picture window; there's no way to tell how large the house is, or what sort of layout it has. \(In other words, it doesn't seem to illustrate the question at all.\) How would you call this kind of building?
In the UK, it is most common for any premises rented out to students to be referred to as as "student-lets".
stackexchange-english
{ "answer_score": 1, "question_score": 0, "tags": "single word requests" }
Creating a Sliding Menu I need to create a sliding menu. The case is, this is not like the day to day sliding menus we find, this is bit different. !enter image description here As in the above image, the menu "opener" should be at the bottom of the screen. This is always visible. You can see this "menu opener" in grey colour. When the user touches on this grey colour bar and slides up, it should open themenu like following. !enter image description here I visited SlidingMenu project and this does not contains what I am seeking for, because, the menu is invisible until you slide. But in my case, the "menu opener(grey colour bar") is always visible. How can I do something like this?
check SlidingDrawer tutorial. you can adjust the drawer as you desire as well.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "java, android, user interface, android menu, slidingmenu" }
301 http response without Location header If I create an application that sends a 301 response to the browser without sending a Location header how would the browser respond to the response. When I tried a POC using nodejs looks like the browser is redirecting the request to / Is it browser depended or a documented spec?
Browsers should just render the HTML body. `Location` is optional.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "apache, http, web" }
How to fix error: "The package lists or status file could not be parsed or opened."? What does this error message mean? E:Type '‫‪ppa:kiwixteam/ppa‬‬' is not known on line 52 in source list /etc/apt/sources.list, E:The list of sources could not be read., E:The package lists or status file could not be parsed or opened.
The problem seems to be the `ppa` in your `sources` Try removing it by using the following steps. 1. Use the following command to edit the `sources.list` file: `sudo nano /etc/apt/sources.list` 2. Then remove the `‫‪ppa:kiwixteam/ppa‬‬` located at the line `52` 3. Save the file: Press and hold `Ctrl`. While holding `Ctrl` press `X`. Let go of `Ctrl` and press `Y` 4. Then run the following command to re-synchronize the package index files: `sudo apt-get update`
stackexchange-askubuntu
{ "answer_score": 2, "question_score": 3, "tags": "software center, software sources" }
Add a random number or date code to a import url? I need some help adding a number to an import URL to prevent caching in Google app scripts, here is my current script: function myFunction() { SpreadsheetApp.getActive().getRange('A1').setValue('=importdata(" } I want to add a random number at the end of the URL, something like: function myFunction() { SpreadsheetApp.getActive().getRange('A1').setValue('=importdata(" } I have tried creating a var with a random number generator but it just doesn't seem to want to play ball! Thanks in advance!
Try this function myFunction() { const rand = 1000 + Math.floor(Math.random() * 10000) // Make Random Number from 1000 to 11000 const url = `=importdata(" // Put it into the url SpreadsheetApp.getActive().getRange('A1').setValue(url) } OR as suggested by @Reyno: function myFunction() { const rand = Date.now() // Make Random Number by sampling current date in ms, will always be different const url = `=importdata(" // Put it into the url SpreadsheetApp.getActive().getRange('A1').setValue(url) }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "javascript, google apps script" }
How to add a link to each node of d3 radar chart? I have integrated radar-chart-d3 in my project and i want to add a link to each node of it so that onclick of it i can display the record details.please help. you can see the demo here!enter image description here
Since the radar chart implementation you are using is black boxed, I'd add the links after it renders: // this "circles" are where you want your links svg.selectAll('.circle').each(function(d,i){ // get the parent of each circle, we'll append the link to this var par = d3.select(this.parentNode); // create the link and text par.append("a") .attr("xlink:href", " .attr("target","_blank") .append("text") .attr("transform", "translate("+ (d[0].x) +","+ (d[0].y) +")") // where to place it! .text("this is a link"); }); Example here.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "html, d3.js" }
Python script to get all users from ps -eaf command I need to get all the users from ps -eaf command and add them to array I prefer to do it with python.
You can do something like: #! /usr/bin/env python3.6 import subprocess result = subprocess.check_output(['ps','-eaf']).decode('utf-8') users = [] for line in result.splitlines(): name = line.split()[0] if name not in users: users.append(name) print(users) For a more comprehensive answer see this stackoverflow answer Although as @jdwolf has posted using shell script might be more appropriate in this case.
stackexchange-unix
{ "answer_score": 0, "question_score": -8, "tags": "linux, python" }
Why does using void keyword before synchronized throws an error in Java, but the reverse works fine? import java.util.*; public class Deadlock extends Thread{ private String name; public static void main(String[] args) { } public class MyObject{ public void synchronized foo(String name) { //throws error saying 'Syntax error on token "void", volatile expected' } } } But if, `public void synchronized` is changed to `public synchronized void`, everything is fine. Why is that?
Look at the Java Specification 8.4.3. Method modifiers which says: MethodModifier: (one of) Annotation public protected private abstract static final synchronized native strictfp Those must precede the return type, which comes as the last. The modifiers order does really not matter since they respect the return type comes as the last. That's why `public synchronized void` is valid.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "java, multithreading, keyword, synchronized" }
Visual Studio DLL project with DLL dependencies, unresolved external symbols I'm new to Windows concepts. I'm trying to develop a DLL that also dynamically links against other DLL's. I'm using Visual Studio 2010. At linking time Visual studio tells me it's trying to link against a bunch of .lib files. I don't think Visual Studio should attempt to read any .LIB files if I want my code to perform dynamic linking is that correct? Or do I not understand the use of .LIB files enough? thank you
As I recall, Visual Studio's compiler resolves .DLL files by linking against stub .LIB files. Check, one of them should be kernel32.lib.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "visual studio 2010, dll" }
How to convert string into an IP Address? I am using a function to adding . after every three characters inside the string. But how can i remove "0" in front of number. -(NSString *)formatStringAsIpAddress:(NSString*)MacAddressWithoutColon { NSMutableString *macAddressWithColon = [NSMutableString new]; for (NSUInteger i = 0; i < [MacAddressWithoutColon length]; i++) { if (i > 0 && i % 3 == 0) [macAddressWithColon appendString:@"."]; unichar c = [MacAddressWithoutColon characterAtIndex:i]; [macAddressWithColon appendString:[[NSString alloc] initWithCharacters:&c length:1]]; } return macAddressWithColon; } If i have ip address 010.000.001.016 How can i set it up like 10.0.1.16? and if i have ip address 192.168.001.001? how to remove front 0's from IP address ?
What I would suggest: NSString *ipAddress = @"010.000.001.016"; 1. **Split** string into array of substrings: NSArray *ipAddressComponents = [myString componentsSeparatedByString:@"."]; 2. Run through the array with for loop and **convert** each to a int representation: for(int i = 0; i < ipAddressComponents.count;i++) { [ipAddressComponents objectAtIndex:i] = [NSString stringWithFormat:@"%d",[[ipAddressComponents objectAtIndex:i]intValue]]; } 3. **Join** the array back into a string NSString *newIpAddress = [ipAddressComponents componentsJoinedByString:@"."]; This should result into getting an IP address: 10.0.1.16
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "ios, objective c, nsstring" }
Solving problem using recursive functions Attached below is a question posed by the Canadian Mathematical Society, and I have my code and answer. Is there a better way of writing the code, and will the answer be different as a result? ![enter image description here]( My code and possible answer (edited): jk[0] = 0; jk[1] = 0; jk[2] = 1; jk[3] = 2; tr[n_] := If[n > 3, LengthWhile[Range[3, 20], Divisible[n, #1] & ] + 3, jk[n]] Sum[tr[tr[tr[m]]], {m, 1, 2006}] (* 2672 *) Let me know if you get an answer that differs.
You made a few mistakes. `jk[0]` should be 0 in your code and your function `tr` is wrong. Corrected version: t[0] = 0; t[1] = 0; t[2] = 1; t[n_] := t[n] = LengthWhile[Range[1, 11], Divisible[n, #1] &] + 1 Sum[Nest[t, m, 3], {m, 1, 2006}] > 1171 10x faster version: t[n_] := t[n] = Module[{i = 1}, While[MemberQ[Divisors[n], i], i++]; i];
stackexchange-mathematica
{ "answer_score": 6, "question_score": 2, "tags": "recursion, code review, number theory, education" }
What to use instead of UIScreen.mainScreen().applicationFrame for swift in ios 9.1? This might be a simple question but since I'm a beginner, it is best to ask. As the title says what should I use instead of `UIScreen.mainScreen().applicationFrame` since it's deprecated in 9.0. If possible it would be great if you can provide me with a sample or example ,since I find Apples document difficult. Currently I use the code below but I wish to change it to the new version. I would love to hear from you! let sizeRect = UIScreen.mainScreen().applicationFrame let posX = arc4random_uniform(UInt32(sizeRect.size.width)) let posY = arc4random_uniform(UInt32(sizeRect.size.height)) Enemy.position = CGPoint(x: CGFloat(posX), y: CGFloat(posY))
Use let rect1 = UIScreen.mainScreen().bounds // Returns CGRect let rect2 = UIScreen.mainScreen().bounds.size // Returns CGSize **Swift 3+ :** let rect1 = UIScreen.main.bounds // Returns CGRect let rect2 = UIScreen.main.bounds.size // Returns CGSize
stackexchange-stackoverflow
{ "answer_score": 20, "question_score": 18, "tags": "ios, iphone, xcode, swift" }
Can we get AWS EC2 status 1/2 or 2/2 status in terraform output? Can we get AWS EC2 status 1/2 or 2/2 status in terraform output ? and can we run terraform destroy via cron ?
The data source aws_instance does not provide such information. Thus, you could create **custom data source** by means of external. The custom/external data source would call **your own program or script** that would query the EC2 instance status, e.g. using describe-instance-status and return to TF for further use. And yes, you can run TF through cron.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "amazon web services, terraform, terraform provider aws" }
Add colour frame to image onClick I want, when something happens (Ex: Click a button), that my image creates a frame around. Something like this: Image before, without the frame Image after click, with the frame Can I do that with CSS? I don't want to have two links nor two images. I want that "transformation" happens to the original image. **EDIT:** I know I don't have any code, but that's because I don't have any function or idea from CSS functions. So you don't need to write code, only to tell me what to use. Hope you understand
You should use javascript `onClick` event handler and css `border` property. Your html image and button tag. <img src='yourimage.jpg' id='myimg'> <button onclick="add_frame()">add frame</button> The javascript function add_frame(){ document.getElementById('myimg').style.border = "2px solid red"; }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, html, css" }
PHP: Why are some people naming functions with '_' in the beginning? Why do some people call their functions e.g. '__makethis()' and '_makethat()'? Is this any special feature or is this just in fashion? thx for your answers ;)
The double underscore can sometimes be magic functions used by the PHP classes. The single underscore can be part of their own naming convention for functions. But usually it means that a function is private, back in PHP4 classes didn't support private (or protected) functions, so people fake a private function that way (tho the function is not private in reality).
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 8, "tags": "php" }
Ito Representation for Integral of Brownian Motion By Ito's representation theorem because the integral of Brownian Motion is mean zero we should have some random function $\phi$ such that $$\int_0^T W_t dt = \int_0^T\phi(\omega,t)dW_t$$ I'm a little uncomfortable about the left hand side being finite variation and the right a local martingale even for fixed $T$, I just can't get any closer to the form above than the obvious Ito formula result $$\int_0^T W_t dt = TW_T-\int_0^TtdW_t$$ Thanks
The identity $$\int_0^T W_t \, dt = T W_T - \int_0^T t \, dW_t$$ is a good start. Now note that $$T W_T = \int_0^T T \, dW_t$$ which implies that $$\int_0^T W_t \, dt = \int_0^T (T-t) \, dW_t.$$ This is exactly the representation you are looking for.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "probability theory, brownian motion, stochastic integrals" }
What is the syntax for the HTML5 media attribute value with an expression? I was wondering what is the syntax for the media attributes value with an expression?
The standard for HTML5 says: > The media attribute gives the intended media type of the media resource, to help the user agent determine if this media resource is useful to the user before fetching it. Its value must be a valid media query. Follow that second link for the full syntax details.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "html" }
Windows Background randomly updates to green If my desktop somehow updates, the wallpaper gets replaced with green color. That looks like this: ![enter image description here]( If I right-click and do “Refresh”, the whole background gets green. I think that has something to do with the second monitor connected to my Laptop. Also, all my drivers are up-to-date, and I run the latest Windows version. The bug happens at random intervals and I have no idea why. _More information on request._
Sounds like the icon cache got corrupted somehow. Navigate to `C:\Users\%username%\AppData\Local\Microsoft\Windows\Explorer ` replace %username% with your username. Here you will see a lot of files like iconcache_32.db, iconcache_48.db, iconcache_96.db, iconcache_256.db, iconcache_1024.db, iconcache_1280.db, iconcache_1600.db, iconcache_1920.db, iconcache_2560.db, iconcache_exif.db, iconcache_idx.db, iconcache_sr.db, iconcache_wide.dd, iconcache_wide_alternate.db, etc. Delete them all to purge and rebuild your icon cache in Windows 10. If you were to be able to delete some of them, you would now be able to see a new folder created named IconcacheToDelete, which will disappear when you reboot your computer or restart Windows File Explorer. source (note it also includes a DOS method if the above does not work.
stackexchange-superuser
{ "answer_score": 0, "question_score": 0, "tags": "windows, windows 10, multiple monitors, desktop, external display" }
How to override css cursor property of a hovered button? I have a `<button>`, when the user hover it, the cursor become pointer (via CSS). When the user click on the `<button>`, the cursor of all the page should become `wait` (via jQuery). However, if the user keeps the cursor inside `<button>`, it will stay as `pointer`. How can I fix this ? Live example : < Tested with Chrome 36.0.1985.125 (last version)
Add a class for html that sets the cursor and sets all elements to also have the wait cursor when html has that class CSS html.wait, html.wait * { cursor:wait; } then instead of doing $('html').css("cursor","wait"); use addClass to add the **wait** class to html $('html').addClass("wait"); JSFiddle Demo Then when done just use removeClass to remove the class
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 1, "tags": "javascript, jquery, html, css, cursor" }
How do I root Android Lollipop developer preview? How can I best root the new Android Lollipop developer preview? Chainfire's original SuperSU binaries don't seem to work: (Click image to enlarge) ![IMG: screenshot of issue]( > There is no SU binary installed, and SuperSU cannot install it. This is a problem! > > If you just upgraded to Android 4.3, you need to manually re-root - consult the relevant forums for your device!
Right now the only officially supported devices for the developer preview are the Nexus 5 & Nexus 7 (2013). Chainfire has issued updated SuperSU binaries that allow rooting, but the recently updated developer previews seem to have broken this, resulting in the SuperSU binaries not being recognised. Fortunately, Chainfire has responded with a quick fix: flashing a custom android kernel. Simply flash the modified kernel in fastboot then the SuperSU binaries zip and your device should be rooted. **EDIT** : Some users have reported issues with the kernel Chainfire provided. Try flashing this one instead.
stackexchange-android
{ "answer_score": 2, "question_score": 1, "tags": "5.0 lollipop, rooting, nexus 5, developer preview" }
why i'm getting void type not allowed when I'm trying to print the method I get an error on second line saying void type not allowed here public static void main(String[] args) { System.out.println(printMenu()); } public static void printMenu(){ System.out.println("***** Welcome to KAU Flight Reservation System *****"+ "\n 1. Add Flight Details in the System"+ "\n 2. Add Passenger Details in the System"+ "\n 3. Make a new Booking"+ "\n 4. Search and Print a Booking"+ "\n 5. List Flight Status"+ "\n 6. Exit from the System "); }
there are two kinds of functions in java. Procedures which They don't return any value and Functions which return value. when you adding the word void in the method declaration it means that this is a Procedures method and it doesn't return any values however the `System.out.print()` method require a parameter of `Object` kind. your printMenu() method should be like this. public static String printMenu(){ String menu = "***** Welcome to KAU Flight Reservation System *****"+ "\n 1. Add Flight Details in the System"+ "\n 2. Add Passenger Details in the System"+ "\n 3. Make a new Booking"+ "\n 4. Search and Print a Booking"+ "\n 5. List Flight Status"+ "\n 6. Exit from the System "; return menu; }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, printing" }
Using induction to show existence of reals $|a_i|\leq 1$ such that $\sin(x_1+x_2+\cdots+x_n)=a_1\sin x_1+a_2\sin x_2+\cdots+a_n\sin x_n$ > Use mathematical induction to show that there exists real numbers $a_1, a_2, a_3, \cdots, a_n$ such that $|a_i|\le 1$ for $i=1, 2, 3, ..., n$ and such that $$\sin (x_1+x_2+x_3+\cdots+x_n)= a_1\sin x_1 + a_2\sin x_2 + a_3\sin x_3 + \cdots+a_n\sin x_n$$
1. For $n= 1$ $\sin(x_1) = (1) \sin(x_1)$ 2. Assume that $\sin(x_1 + x_2 + ... + x_k) = a_1 \sin(x_1) + a_2 \sin(x_2) + ...+a_k \sin(x_k)$ 3. For $n = k + 1$ $\sin(x_1 + x_2 + ...+x_k + x_{k+1} ) = \sin(x_1 + x_2 + ... + x_k) \cos (x_{k+1}) + \cos(x_1 + x_2 + ... + x_k) \sin(x_{k+1}) $ Substituting step 2. and using $| \cos(\cdot) | \le 1 $, we deduce that, $\sin(x_1 + x_2 + .... + x_{k+1}) = a_1 \sin(x_1) + a_2 \sin(x_2) + ... + a_{k+1}\sin(x_{k+1})$ This completes the proof by induction.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "trigonometry, induction" }
How can I reset the password on a PostgreSQL database on my machine? I installed PostgreSQL on my Windows 7 machine a few weeks ago. Now I would like to create a database with `createdb mydb` but I don't remember the password. Is there anyway to reset the password? I have access to the Administrator account on my machine. Or do I have to uninstall PostgreSQL and then reinstall it again? How can I reset the password on a PostgreSQL database on my machine?
Edit pg_hba.conf to allow access without a password, use "trust". Restart postgresql and you can access PostgreSQL without the usage of a password. Alter your password to something you can remember :) , edit pg_hba.conf again and reload pg_hba.conf. The Ubuntu-manual has a description about this issue as well.
stackexchange-serverfault
{ "answer_score": 2, "question_score": 2, "tags": "postgresql, password" }
How to select multiple values from a filter in Google Sheets? I've got lots of data in a Google sheet (I do not have Excel or Windows as I am on a Chromebook) and I want to use one column to filter out cells which contain two different words. The column of data might contain various values. ## Example Cell 1 **Acme - Main - Location** Cell 2 **Acme - Secondary - Location** Cell 3 **Acme - Location - Main** Sticking with the above example, I would like to use my data filters set at the column headers to only show me cells where it matches **Acme** and **Main**. What is the best way of doing this, please? I tried using the _Text Contains_ option in the data filter but I'm not sure how to insert both words as something to filter by, it seems to only filter the words exactly how they are typed. So if I type in **Acme Main** into the filter it will work for some cells which are in that exact order.
if the order of "acme main" combo does not matter you could use: =REGEXMATCH(A1:A, "Acme(.+)Main|Main(.+)Acme") ![0]( if you also want it by any chance case-insensitive use: =REGEXMATCH(LOWER(A1:A), "acme(.+)main|main(.+)acme") ![0](
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "regex, filter, google sheets, contains, google sheets formula" }
PHP: How to check if variable is a "large integer" I need to check if a parameter (either string or int or float) is a "large" integer. By "large integer" I mean that it doesn't have decimal places and can exceed `PHP_INT_MAX`. It's used as msec timestamp, internally represented as float. `ctype_digit` comes to mind but enforces string type. `is_int` as secondary check is limited to `PHP_INT_MAX` range and `is_numeric` will accept floats with decimal places which is what I don't want. Is it safe to rely on something like this or is there a better method: if (is_numeric($val) && $val == floor($val)) { return (double) $val; } else ...
So basically you want to check if a particular variable is integer-like? function isInteger($var) { if (is_int($var)) { // the most obvious test return true; } elseif (is_numeric($var)) { // cast to string first return ctype_digit((string)$var); } return false; } Note that using a floating point variable to keep large integers will lose precision and when big enough will turn into a fraction, e.g. `9.9999999999991E+36`, which will obviously fail the above tests. If the value exceeds INT_MAX on the given environment (32-bit or 64-bit), I would recommend using gmp instead and persist the numbers in a string format.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 12, "tags": "php" }
Are there any tools to help with monitoring TFS status? I would like a tool to help with ensuring our TFS (Microsoft Team Foundation Server) instance is running and accessible and monitor the appropriate parties if something goes wrong. Does something like this exist? If not it shouldn't be too hard to write since the TFS object model is pretty well exposed in .Net. Is this a task that is better handled by generic server monitoring software? Do people normally worry about monitoring specific apps within a server?
Grant Holliday's reporting services pack is quite useful for eyeballing server health. To get the most out of it you'll need to have upgraded your TFS database to SQL Server 2008, but the 2005 reports can give a general idea of use.
stackexchange-serverfault
{ "answer_score": 2, "question_score": 1, "tags": "monitoring, team foundation server" }
Best practice for setting configuration settings I have some Game Objects with public properties that are set in the editor. Now, I want to change it so some of these are loaded from a configuration file. For example: userForm script has public string uploadURL. What is the best practice. I could have a script at Start() that reads the configuration and sets the properties of each game object. But, how could I guarantee my settings runs before the other objects? Is there an alternative? Peter
Well, the `Awake()` method runs before `Start()`, which might help you somewhat. You can also edit the order that particular scripts run in from the Unity IDE (guaranteeing that a particular component runs first in a given update cycle). However, if you're loading configuration from files, you might find it easier (and more efficient) to have a single overarching "Configuration Loader" that sets up all of your GameObjects from one configuration file, rather than having each component read from a file separately.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "unity3d" }
Are the following 2 code snippets equivalent in javascript var search = function(name) { for(var prop in friends) { if(friends[prop].firstName === name) { console.log(friends[prop]); return friends[prop]; } } }; code snippet 2: var search = function(name){ for(var prop in friends) { if(prop.firstName === name) { console.log(prop); return prop; } } }; here friends is an object and firstName is one of the keys.
No they'are not the same - for `friends` as an object in the second one `prop` is a property name and in first example iteration `friends[prop]` returns a values of the properties of the `friends` object. With array it would be indexes - 0,1,2,3... for the second one and values for the first one.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -3, "tags": "javascript" }
Cannot replace string when reading from a dataframe in Python When I try to read each element in a column of Dataframe, I cannot use replace to change a old substring into a new substring, the text will have the same value after using replace. for index, row in df.iterrows(): text = row['r.name'] print(type(text)) for token in row['main_ingreds'].split(','): text.replace(token, " ")
You don't have to iterate but use `apply(function, axis=1)` import pandas as pd df = pd.DataFrame({ 'r.name': ['ABCD', 'DEFG', 'OMNP'], 'main_ingreds': ['A', 'FG', 'NP'] }) def func(row): for token in row['main_ingreds'].split(','): row['r.name'] = row['r.name'].replace(token, " ") return row df = df.apply(func, axis=1) print( df['r.name'] )
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "python, pandas, dataframe, replace" }
MySql, InnoDB & Null Values Formerly I was using MyISAM storage engine for MySql and I had defined the combination of three fields to be unique. Now I have switched to InnoDB, which I assume caused this problem, and now NULL != NULL. So for the following table: ID (Auto) | Field_A | Field_B | Field_C I can insert (Field_A,Field_B,Field_C) Values(1,2,NULL) (1,2,NULL) (1,2,NULL) infinitely many times. How can I prevent this behavior?
Depends on the business rules, but the first idea would be to set `field_a` and `field_b` as the primary key for the table. An AUTO_INCREMENT column can be used for a non-primary key column, but the key attribute has to be associated with the auto_increment column: CREATE TABLE your_table ( ID int auto_increment not null, Field_A VARCHAR(45), Field_B VARCHAR(45), Field_C VARCHAR(45), key(ID), --without this, you'll get MySQL ERROR #1075 primary key(field_a, field_b) ); The other alternative is to add a unique constraint (MySQL implements them as an index): CREATE UNIQUE INDEX blah_ind USING BTREE ON your_table(field_a, field_b)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "mysql, database, innodb, myisam, storage engines" }
WM_TOUCH vs WM_POINTER Which one should I use? I'm only using Windows 8.x, so I don't care about the fact that WM_POINTER is not backwards compatible with Windows 7 etc. I also don't care about gestures; only about raw touches. WM_POINTER's only clear advantage seems to be that it unifies touch and mouse input (but that's easy to work around with WM_TOUCH because mouse events can be checked with GetMessageExtraInfo()). Ease of use is also not an issue; I've been using WM_TOUCH already and I'm just wondering if I should switch to WM_POINTER. My overriding concern is latency and efficiency (game-related application). I can't tell whether WM_POINTER is a wrapper over WM_TOUCH that has extra overhead. Any comments?
`WM_TOUCH` is obsolete. Use `WM_POINTER` exclusively. (`WM_TOUCH` is actually a wrapper over `WM_POINTER`.) `GetMessageExtraInfo` is also notoriously fragile. You have to call it _immediately_ after calling GetMessage, or else you run the risk of intermediate function calls making a COM call or doing something else that results in calling GetMessage.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 6, "tags": "winapi, touch, multi touch, windows messages, wm touch" }
Oracle SQL IN-Clause throws Error with Subselect so here's my Problem: I got this SQL-Statement SELECT a.ID,a.CONTENTOF FROM MLMDATA.PV_STORAGE a WHERE 1=1 AND ID IN (113312,114583,114581,113472,114585,114580,113314) AND a.SEQ = (SELECT MAX(b.SEQ) FROM MLMDATA.PV_STORAGE b where a.ID = b.ID) But my Problem is now, that I'm getting an Error: ORA-00600: Internal Error Code, Arguments: [qernsRowP], [1], [], [], [], [], [], [], [], [], [], [] I can't seem to find a way to select these ID's where only the highest SEQUENZE is selected.... I already created a View, showing only the highest SEQ, but that doesn't work eighter... I'm kinda frustrated, because as far as I know that SQL Worked before and suddenly doesn't work. Anyone got an Idea on what the Problem could be?
Please try this query : SELECT a.ID,a.CONTENTOF FROM MLMDATA.PV_STORAGE a INNER JOIN (SELECT ID, CONTENTOF, MAX(SEQ) AS SEQ FROM MLMDATA.PV_STORAGE where ID IN (113312,114583,114581,113472,114585,114580,113314) GROUP BY ID, CONTENTOF) b ON a.id = b.id AND a.SEQ = b.SEQ
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "sql, oracle, greatest n per group, in clause, ora 00600" }
unchecking radio button is buggy check out this fiddle: < the goal is to uncheck the radio button when the user clicks it if it is checked and check it if it's not checked but then it appears that the click event triggers twice, making the checking/unchecking highly buggy.... I tried a combination of the e.stopPropagation(); e.preventDefault(); commands but each of them result in different bugs... how would I accomplish this goal and fix that code accordingly?
I agree with everyone else that a check box would be better. However, that being said, here is something that may work for you. First off, the checked attribute being on the radio button marks it checked. So, to remove the check, you have to remove the attribute. However, when clicking on the radio button, it wants to put the attribute back. My solution is really more of a hack. I am adding another attribute and using that as a flag to determine whether to remove or add the checked attribute. HTH $('input[type=radio]').each(function(){ var input = $(this); input.click(function(e){ if(input.attr('cval')==='1'){ input.attr('cval', '0'); input.removeAttr('checked'); } else{ input.attr('cval', '1'); input.attr('checked', 'checked'); } }); });​
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "javascript, jquery, forms, radio button" }
How can I fill a small gap in a sink drain pipe? I'm replacing a bathroom sink. I messed up (long story, I already forgot the ugly details) by grinding out the piece that the P trap slides into, messing up the threads on the inside of the pipe coming out of the wall. I keep making trips to hardware stores thinking I'm finally getting something that will fit just right but nothing produces anything close to a tight fit, not even the soft adapter with a hose clamp (which would also require a bigger hole in the drywall for tightening the clamp). I have something that fits loosely over the pipe coming out of the wall. My question is if there is a filler I can use in there to make it a snug fit that can hold up over time? I'm guessing regular plumber's putty would erode? If not, I'm open to other ideas. The pipe only sticks out of the wall about 1/2".
No to fillers. Also no to epoxy. Hire a plumber and get it fixed right. Small leaks, especially those at a sink, turn into rotten cabinets, rotten sub floor, smelly mildew, possibly mold and an unhappy spouse. Don't go cheap and regret it forever.
stackexchange-diy
{ "answer_score": 3, "question_score": 1, "tags": "plumbing" }
Use Azure Powershell to execute a .sql file I've seen examples of running a SQL command from Azure Powershell e.g. $connectionString = "Data Source=MyDataSource;Initial Catalog=MyDB;User ID=user1;Password=pass1;Connection Timeout=90" $connection = New-Object -TypeName System.Data.SqlClient.SqlConnection($connectionString) $query = "CREATE TABLE...." $command = New-Object -TypeName System.Data.SqlClient.SqlCommand($query, $connection) $connection.Open() $command.ExecuteNonQuery() $connection.Close() Is there a way to replace the $query with a reference to an external file that contains an entire SQL script? Thanks.
20 more mins of searching and I found it. $connectionString = "Data Source=MyDataSource;Initial Catalog=MyDB;User ID=user1;Password=pass1;Connection Timeout=90" $connection = New-Object -TypeName System.Data.SqlClient.SqlConnection($connectionString) $query = [IO.File]::ReadAllText("C:\...\TestSQL.sql") $command = New-Object -TypeName System.Data.SqlClient.SqlCommand($query, $connection) $connection.Open() $command.ExecuteNonQuery() $connection.Close()
stackexchange-stackoverflow
{ "answer_score": 17, "question_score": 10, "tags": "powershell, azure sql database" }
Finding all the indexes of some elements on a given list. Can it be done in less than O(n^2) without arrays in Haskell? Given 2 lists of unique, orderable, non-contiguous elements, say: ['d', 'a', 'z', 'b'] I want to find their index in another list, say: ['a', 'b', 'z', 'd'] The result would be a list with their positions: [3, 0, 2, 1] -- element at 0 is at 3, -- element at 1 is at 0, etc.
This can be also done in `O(n log n)` time with a couple of sorts. I assume that the second list is a permutation of the first one. import Data.List import Data.Ord import Data.Function correspIx :: Ord a => [a] -> [a] -> [(Int, Int)] correspIx = zip `on` map fst . sortBy (comparing snd) . zip [0..] `correspIx` returns a list of pairs with the indices corresponding to each other: correspIx "dazb" "abzd" == [(1,0),(3,1),(0,3),(2,2)] We need another sort to get the result indicated in the question: correspIx' :: Ord a => [a] -> [a] -> [Int] correspIx' xs ys = map snd $ sortBy (comparing fst) $ correspIx xs ys Now `correspIx' "dazb" "abzd" == [3,0,2,1]`.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "arrays, list, haskell, array algorithms" }
Find number of substrings in binary string having equal 1's and 0's I came across the following question, Find the total number of substrings in a string which contain equal number of 1's and 0's. Also the substring should have consecutive 0's followed by consecutive 1's or vice versa. For example, 1010 - 10,01,10 1100110- 1100,10,0011,01,10. My initial idea was to use a n^2 loop to find all substrings and then check if the condition is satisfied. Obviously there must be a better solution to this as I could not pass all cases. Please suggest ideas to improve on this. Thanks.
I’d suggest the following - iterating over you sequence for each consecutive sequence of 0’s or 1’s of length L(k) (except for the first one) add to the counter min(L(k), L(k-1)). The final value of the counter will be the number you’re looking for. For your example 1100110 L = (2, 2, 2, 1) And the sum is 2+2+1=5
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "algorithm" }
Redirecting mobile visitors to a subdomain I have an Asp.net MVC website and for that I will making a lighter mobile version and install it on < subdomain. Please tell me what code I can use to redirect the mobile visitors and where should it be placed ? Also, tell me if this is a better approach or there is an alternative which simply uses CSS to scale down the website ?
Yes there is a better approach - a responsive build means you only have one code base and one set of content for all devices. Redirecting to a mobile area is the old approach, doesn't always cater for new devices and usually means either duplicate code, duplicate content, or both. This is probably the best introduction to responsive design I have come across
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 4, "tags": "c#, asp.net mvc 3, mobile website" }
Constituents of S&P 500 Top 50? Try as I might I can't find the current constituents of the S&P 500 Top 50 index: < That link only lists the top 10 constituents by weighting. And there is a Guggenheim fund that tracks it which lists all 50 constituents but I'd like to get the list from an official source/S&P 500.
Here is a list of all S&P 500 constituents by weighting: < However, the S&P 500 Top 50 constituents are only changed once per year, in June. Furthermore, they use an algorithm intended to reduce volatility, which could in theory (it seems to me) prevent a stock that shot from nothing into the top 50, from ever appearing in the index. < The Guggenheim fund was the only one I could find that tracks this particular index, so that might be your best bet. Given that it only changes once a year, the Guggenheim fund shouldn't have any tracking errors.
stackexchange-money
{ "answer_score": 6, "question_score": 5, "tags": "index fund" }
document get element by id возвращает null html <p id="encode-span">aaaaaaaaaaaa</p> js const encode = document.getElementById('encode-span').value; console.log(encode);
Во-первых у вас возможно ещё не прогрузился DOM и поэтому на момент срабатывания метода такого элемента ещё нет на странице. Поэтому надо попробовать сделать это **после** загрузки страницы. Во-вторых у `p` нет атрибута `value`, но есть `textContent` и `innerHTML` document.addEventListener("DOMContentLoaded", ready); function ready() { const encode = document.getElementById('encode-span').textContent; console.log(encode); } <p id="encode-span">aaaaaaaaaaaa</p>
stackexchange-ru_stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "javascript, html, css" }
Remove empty array from start of multidimensional array I've been unable to find an elegant solution to what is a simple problem. Basically an API call I'm making is outputting one empty array before my main set of data. What would be the fastest way of removing this from the data set? Array structure... $example = Array ( ) Array ( [aaa] => Array ( [aa] => aa [aa] => aa [aa] => aa [aa] => aa ) Therefore the first array() needs to be removed to be: $fixed = Array ( [aaa] => Array ( [aa] => aa [aa] => aa [aa] => aa [aa] => aa ) Thanks, Phil
$fixed = array_filter($example); Remove empty array elements
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, arrays, multidimensional array" }
Puzzling price of a bond I was asked to solve this question: given a bond which grants the following cash flow (year $t$, return): * (0, not reported) * (1, 10) * (2, 10) * (3, 20) * (4, 20) * (5, 100) What is the bond price in $t=3$ with flat rate of 3% per year for the entire financial operation? Four possible choices: * 90.71 * 113.68 * 120 * 130.23 I tried to solve with the formula of the Discounted Cash Flow but I obtained: $$ -x+\frac{10}{1.03}+\frac{10}{1.03^2}+\frac{20}{1.03^3}=0 $$ i.e. $$ x=37.43$$ Can someone tell me where I am wrong? Thanks in advance.
_What is the bond price in $t=3$?_ Try the cash flows in years $4$ and $5$ discounted back to year $3$, which in your terms means $$-x+\frac{20}{1.03}+\frac{100}{1.03^2}=0$$
stackexchange-math
{ "answer_score": 4, "question_score": 1, "tags": "finance" }
Read uncommitted when using Rob Conery's Massive Is there a way to do a read uncommitted when using Rob Conery's Massive without writing your own query? It is for a site that is mostly read-only. A CMS type of a site.
The cheat way to do this is when you are doing your declaration for the table. Pass in a (nolock) hint: var dirtytbl = new DynamicModel("northwind", tableName:"dbo.Products (nolock)", primaryKeyField:"ProductID"); If you don't want to have established dirty models and clean models, for the what I hope to be rare times you are doing this, you can just go straight to SQL: var dirtyresult = tbl.Fetch("set transaction isolation level read uncommitted; SELECT * FROM Categories c INNER JOIN things t on c.id = t.id "); I use the above code for system objects and some other behind the scenes stuff where I know it won't matter, but you should always be very cautious and know what you are getting into when you drop to that isolation level. See blog post _How dirty are your reads?_
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "isolation level, massive, nolock, read uncommitted" }
Combining boolean operations over multiple columns among different dataframes using reduce I have two Dataframes as below af=pd.DataFrame({'A':[3,7]}) bf=pd.DataFrame({'B': [5, 2], 'C': [1, 4],'D':[6,8]}) I want to perform this operation (af['A']>bf['B'])|(af['A']>bf['C'])|(af['A']>bf['D']) I believe there would be an easier way to this using **reduce** higher order function, iterating over columns of bf and folding the individual results into a single column, but I am not sure how to proceed Thanks for the help
You can first calculate the minimum for the `bf` over the `B`, `C` and `D` columns: af['A'] > **bf[['B', 'C', 'D']].min(axis=1)** Indeed, given that `af['A']` is greater than the minimum of the other columns for that row, we know that at least one element in these columns is less than the value for `af['A']`.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "python, pandas" }
Find years where 22nd March will be a Tuesday I need to find out in which years between 2017 and 2100 (both inclusive) will the 22nd March be a Tuesday. I tried using the `datetime` module but I couldn't figure out how...
Use the **calendar** module instead: >>> import calendar >>> [year for year in range(2017, 2101) if calendar.weekday(year, 3, 22) == calendar.TUESDAY] [2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095]
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "python, python 3.x, datetime" }
Using JQuery Key press to grab textarea data and display in a span I want to grab what a user is typing and display in a span above the textarea. But how do I grab the enter/return key (keyCode 13), and insert it correctly into the span so that a line break in the textarea, is a line break ( ) in the span. $('#InviteMessage').keyup(function(event) { var enter = ""; //if(event.keyCode = '13') //enter = 'br />'; var text = $(this).val() + enter; //replace all the less than/greater than characters if(text == '') $('#message').html('[Your personal message]'); else $('#message').html(text); } ); The #InputMessage is the textarea and #message is the span above it.
You could simply do... text = text.replace(/\n/g, '<br />'); Or use `white-space: pre` on the `span`, in which case the `span` should probably be a `div`.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "html, jquery, keypress" }
Given an entire function which is real on the real axis and imaginary on the imaginary axis, prove that it is an odd function. Given an entire function which is real on the real axis and imaginary on the imaginary axis, prove that it is an odd function. By a Corollary: If $f$ analytic in a region symmetric with respect to the real axis and if $f$ is real for real $z$, then $f(z) = \overline{f(\bar z)} $. So that, $f(z) = u(x+iy) + iv(x+iy) = u(x-iy) - iv(x-iy)$ $f(-z) = u(-x-iy) + iv(-x-iy) = u(-x+iy) - iv(-x+iy)$ $-f(-z) = -u(-x+iy) + iv(-x+iy)$ It looks close to the answer but what else can I do by using Schwartz reflection principle??
Consider the Taylor series of $f(z)$ $$ f(z)=\sum_{n=0}^{\infty}a_nz^n $$ Since $f(z)= \overline{f(\bar z)}$, all $a_n$ are real. Since $f$ maps imaginary on the imaginary axis \begin{align} f(iy)=\sum_{n=0}^{\infty}a_ni^ny^n&=\sum_{n=0}^{\infty}a_{2n}i^{2n}y^{2n}+\sum_{n=1}^{\infty}a_{2n+1}i^{2n+1}y^{2n+1} \\\ &=\sum_{n=0}^{\infty}(-1)^{n}a_{2n}\:y^{2n}+i\sum_{n=1}^{\infty}(-1)^{n}a_{2n+1}\:y^{2n+1} \end{align} is imaginary. So $$ \sum_{n=0}^{\infty}(-1)^{n}a_{2n}\:y^{2n}=0 $$ which means $a_{2n}=0$ for all $n$. So $f(z)$ is odd.
stackexchange-math
{ "answer_score": 6, "question_score": 8, "tags": "complex analysis" }
Add a reputation and achievements pane to iOS app It'd be nice to see reputation updates in the app, as we get on both the desktop and mobile sites. **Mock-up of how this would look:** > !mock up for how this would look **Other possible icon states:** > !inbox only!reputation only!badge While I understand reputation is shown in the feed, it's a bit unwieldy, and has no notification. With this feature implemented, the feed could arguably lose both reputation and inbox items, and be left with the interesting questions that fill it up. This would make for a much more consistent UX across app and desktop.
The beta version of the app now has an achievements button that can be used to access our shiny new achievements screen: !Screenshot of the achievements button
stackexchange-meta
{ "answer_score": 6, "question_score": 34, "tags": "feature request, status completed, reputation, ios app, achievements dialog" }
Django Form ChoiceField range(): 'int' object not iterable from django import forms class SignUpForm(forms.Form): birth_day = forms.ChoiceField(choices=range(1,32)) I'm getting "Caught TypeError while rendering: 'int' object is not iterable". < says the choices argument takes iterables such as a list or tuple. < says range() creates a list. Why am I getting an error? I tried converting the list to str using map() but received different errors.
> ... says the choices argument takes iterables such as a list or tuple. No, it says it takes an iterable _of 2-tuples_. > An iterable (e.g., a list or tuple) of 2-tuples to use as choices for this field. birth_day = forms.ChoiceField(choices=((str(x), x) for x in range(1,32)))
stackexchange-stackoverflow
{ "answer_score": 18, "question_score": 7, "tags": "django, forms, range, choicefield" }
How come I don't need to pass params to article_params? How does the `article_params` method get access to `params` without it being passed as a parameter? Thanks in advance. class ArticlesController < ApplicationController private def article_params params.require(:article).permit(:title, :text) end def create @article = Article.new(article_params) if @article.save redirect_to @article else render 'new' end end
Because `params` is not a variable, it's a method in `ActionController::Base` which returns the parameters passed in by the call, and, being a method, is available to be called by any method in any controller. In fact you can reference `params` in views, so it's not only a method, it's a helper method. As described in < > All request parameters, whether they come from a query string in the URL or form data submitted through a POST request are available through the params method which returns a hash.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "ruby on rails, ruby" }
sharepoint 2010 permissions on a page It seems that sp has the following ootb behaviour when a user/group's persmission is removed from a page - SP hides the navigation link to that page. I am looking for the following behaviour (if possible). 1. User navigates to a page for which he does not have permission to view. 2. User receives a message (instead of the page content) that they should contact the helpdesk if they wish access. Is there a way to stop sharepoint from hiding the links and to redirect to a default "access denied" page?? thanks, KS
Sharepoint security trims things people don't have access to automatically. To work around that, you have to provide a hard coded navigation structure so that a user can see the links they do not have access to so that when they click on it, they'll receive the access denied screen.
stackexchange-sharepoint
{ "answer_score": 2, "question_score": 1, "tags": "permissions, navigation" }
How to prevent a javascript function from evaluating an argument assigned to a string variable? Edited for clarification: function Num(str) { return str; } which returns when the input is 2^15 > 13 I want to know how I can keep it from evaluating str and just return 2^15 instead of returning 13.
var string = "2^15"; // wrap in double quotes to treat it as a string As a sidenote, avoid calling your variables 'string', since it is a reserved keyword in a lot of languages and reduces readability.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "javascript, variables, syntax, console.log" }
A weird modular identity I came up with the following modular identity which looks a bit weird but can be checked numerically for (almost) arbitrary choices of $n$ and $N > n$ when $N = k\,n + r$ with $r < n$. We have $k = \lfloor N/n \rfloor$ and $r = N\%n$. My claim is that for $n < 2\,r$ it holds that $$(n-r)\cdot\Big( \lfloor r/(n-r) \rfloor \cdot\big( k + 1\big) + k\Big) + \big(r\%(n-r)\big)\cdot\big( k + 1 \big) = N$$ How do I prove this? Is it trivial or only elementary?
Let $r=t(n-r)+s,s<n-r.$ Then the LHS of your expression is $(n-r)(t(k+1)+k)+s(k+1)$ $=((n-r)t+s)(k+1)+k(n-r)$ $=r(k+1)+k(n-r)=kn+r=N.$
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "modular arithmetic" }
How to Retrive all fields after getting acess token in facebook? How to get all the fields after getting the access-token? I am not able to get all the fields but age,email,name and id. If i am passing work,education in parameters then nothing is displaying please help me out. "access_token":"...","token_type":"bearer","expires_in":5162400} Please help me out
NEVER post Access Tokens on Stackoverflow. That being said, the debugger says that you only authorized the user with the email permissions: < For other fields, you may need additional permissions: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "facebook, facebook graph api" }
How to hide wrapped element using v-if How to hide radio-group element on my code using v-if? i gave v-if to radio tag it's work, but the radio-group tag is still there, i also gave v-if to radio-group tag but property of size is not found, <radio-group v-model="selectedsize"> <radio v-bind:value="s" v-for="s in size" :key="s.id" v-if="s.size"> {{ s.size }} </radio> </radio-group> the problem is i dont want to lose radio-group i want to hide the wrapper from radio-group if size is null on my property
I guess you could determine if any of the elements in `size` have a corresponding `size` and then show it if any exist, or hide if none exist. v-if="size.filter((s) => s.size).length">
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, vue.js" }
How can I open up chrome programatically from the bash shell? I've learned how to kill it by simply using `pkill Chrome` but how do I open it in bash in OS X ?
You should not need the full path of open as bash already knows where to find this. It also knows where to find Chrome. However you do need the full path of Chrome: open -a "Google Chrome" --args 'gmail.com'
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "macos, bash, google chrome" }
match a string using all the strings in array Hello, I'm trying to make a simple matching game in javascript. If the the user inserts the text `president goes crazy` in any way that contains every strings in word_tmp, then the word_tmp becomes true, and if he misses one string then it becomes false. word_tmp = ['president', 'goes', 'crazy']; // string 1 contains the president, goes and crazy at one string string1 = 'president goes very crazy'; // should output true // string 2 doesn't contain president so its false. string2 = 'other people goes crazy'; // should output false How can I accomplish this?
Try this: var word_tmp = ['president', 'goes', 'crazy']; var string1 = 'president goes very crazy'; var isMatch = true; for(var i = 0; i < word_tmp.length; i++){ if (string1.indexOf(word_tmp[i]) == -1){ isMatch = false; break; } } return isMatch //will be true in this case
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "javascript, arrays, string, compare" }
Simple way to send an html/text email using sendgrid & python? I'm trying to use sendgrid to send email from my Python application. It's sending fine using the mail helper and the following syntax: sgmessage = mail.Mail(from_email, message.subject, to_email, content) sg.client.mail.send.post(request_body=sgmessage.get()) But I can't find the way to send an email which has a multipart/alternative content type with text & html versions? I've tried things like this: sgmessage = mail.Mail(from_email, message.subject, to_email) sgmessage.add_content(content) sgmessage.add_content(htmlcontent) But that gives me Bad Request when I try to send. Could someone point me to the documentation or other tip for achieving this? Also attachments -- I can't find docs for that handy mail helper which would help me add attachments ability to my code.
Have you looked at the SendGrid Python Library? The basic example only shows one content type, but the "kitchen sink" example shows setting both contents.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 4, "tags": "python, email, sendgrid" }
Converting Culture into Locale or LCID using C# I have culture given as "en-GB" or "NL-nl" but I want to get locale for it, I can't use current thread it has to be converted from culture to locale or lcid. Not really sure what to look for on Google as nothing relevant coming up.
You can try with this: CultureInfo myCI = new CultureInfo("en-GB"); int lcid = myCI.LCID; See System.Globalization.CultureInfo
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "c#, web services, .net 2.0" }
Get out edges with properties I have a Digraph G with some nodes and some edges: G.add_edges_from([ ... ('X', 'Y', {'property': 85}), ... ('X', 'T', {'property': 104}), ... ...]) However, when I run `G.out_edges('X')`, it returns `OutEdgeDataView([('X', 'Y'), ('X', 'T')])`. Instead, I want to get a list of tuples with the edges (with the **property** ), like this: `[('X', 'Y', {'property': 85}), ('X', 'T', {'property': 104})]` How should I get these results? Thanks!
You can use networkx.DiGraph.out_edges(data=True). import networkx as nx G = nx.DiGraph() G.add_edges_from([ ('X', 'Y', {'property': 85}), ('X', 'T', {'property': 104}), ('Z', 'X', {'property': 104}), ]) print(G.out_edges('X', data=True)) [('X', 'Y', {'property': 85}), ('X', 'T', {'property': 104})]
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "networkx" }
How to capture the markdown from a WMD-Editor server side in a ASP.NET website? I'm using an `asp:TextBox` as the `wmd-input`. As the user clicks the submit button I wan't to capture the markdown at server side as the `Text` property of my `asp:TextBox` control. However, instead of the expected markdown, my TextBox at server-side contains the HTML formatted version of the markdown: `<h1>testing</h1>` **How do I get the pure markdown?** PS: At client side I see markdown on the `asp:TextBox`. It's not clear for me when it's getting converted to HTML before post-back.
Figured it out myself. WMD-Editor supports a configuration that determines the output of the editor. Check out the file optionsExample.html that comes with the downloadable version. In my case I just needed to add this before the showdown.js reference: <script type="text/javascript"> window['wmd_options'] = { output: "Markdown", buttons: "bold italic | link blockquote image | ol ul heading hr" }; </script>
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": ".net, asp.net, wmd" }
Where we can find ddl script of external table in oracle(any system table) I tried with below code but unable to get the DDL script, SELECT DBMS_METADATA.get_ddl ('TABLE', 'TABLE_NAME', 'OWNER') FROM dual Is there any oracle system table where we can see definition of External table.
DBMS_METADATA.GET_DDL will work for external tables just fine, eg SQL> select dbms_metadata.get_ddl('TABLE','SALES_EXT') from dual; DBMS_METADATA.GET_DDL('TABLE','SALES_EXT') ---------------------------------------------------------------------------- CREATE TABLE "MCDONAC"."SALES_EXT" ( "CUST_ID" VARCHAR2(10) COLLATE "USING_NLS_COMP" NOT NULL ENABLE, "PRODUCT_ID" NUMBER(*,0) NOT NULL ENABLE, "AMT" NUMBER, "DTE" DATE, "AMT10" NUMBER(*,0) GENERATED ALWAYS AS ("AMT"*10) VIRTUAL ) DEFAULT COLLATION "USING_NLS_COMP" ORGANIZATION EXTERNAL ( TYPE ORACLE_LOADER DEFAULT DIRECTORY "TEMP" ACCESS PARAMETERS ( records delimited by newline ... ... You can also get additional information from xxx_EXTERNAL_TABLES
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "oracle, external tables" }
jQuery and Firebug I am using jQuery's cycle plugin, and found that I can call up the default for "speed" by typing this into Firebug's console: > $.fn.cycle.defaults.speed > >> >>> 1000 I would like to know how to call up the override I have for speed (I would like to reuse it later): > $('.xxx').cycle({ > speed: 1700 }); If you have the answer, please let me know the steps taken to figure it out so I can understand Firebug better. Thanks a bunch!
I looked through the code and it doesn't appear that the calculated options are exposed anywhere. They're captured as a local variable in several functions after they are built, but I don't know how you would get at them. You could set breakpoints in the relevant parts of the (unminified) cycle code with Firebug and inspect the values, but I don't think you can get at them programmatically. In any event it would be easier to store them in a variable, then use that variable in the options that you provide. var cycleSpeed = 1700; $('.klass').cycle({ speed: cycleSpeed });
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "jquery, firebug" }
using memcpy to copy a structure > **Possible Duplicate:** > Copying one structure to another struct node { int n; struct classifier keys[M-1]; struct node *p[M]; }*root=NULL; i have created newnode which is of type node (*newnode)->keys[i] i want to copy data to keys structure from structure clsf_ptr which is also of same type can i do it like this,i don't want to initialize each member function memcpy((*newnode)->keys[i], clsf_ptr)
For a start, that should probably be: memcpy(&(newnode->keys[i]), &clsf_ptr, sizeof(struct classifier)); (assuming `newnode` is a pointer-to-`node`, and `clsf_ptr` is a classifier`). Also, struct assignment is legal in C, so you could just do: newnode->keys[i] = clsf_ptr; Note that both of these approaches only do a _shallow copy_. So if `struct classifier` has pointers to memory, the pointers themselves will be copied, rather than creating new copies of the memory.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": -1, "tags": "c" }
WSO2IS/APIM: How to assign user role in a custom authenticator I am trying to implement a custom authenticator for using with WSO2-IS and WSO2-APIM. However, I can not find a way to assign a role to the authenticated user. I want the authenticated user to have role "customer". Below is the code I used in method processAuthenticationResponse. Map<ClaimMapping, String> claims = new HashMap<ClaimMapping, String>(); claims.put(ClaimMapping.build(" " null, false), "customer"); AuthenticatedUser user = AuthenticatedUser.createLocalAuthenticatedUserFromSubjectIdentifier("xxxxxx"); context.setSubject(user); Any guide to implement this correctly is very appreciated. Thank you very much.
I have found a solution to my problem. In addition to my code in custom federated authenticator to assign the role to ` claim, I also need to enable Just-In-Time provisioning then the user authenticated by my custom federated authenticator will be created in WSO2 with the specified role. PS. I still can not make the user authenticated by the custom authenticator having specific role without having to have the user created first in WSO2 via Just-In-Time Provisioning.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "wso2, wso2 api manager, wso2 identity server" }
Why do I have two different permission get dialogues in Facebook API? I have two sites in my Apps account and I've got them working for Facebook OAuth, why almost same FB login buttons lead to different permissions asking page. First, not pretty page with permissions request from user and buttons **LogIn Cancel**. www.facebook.com/dialog/oauth?scope=email,user_birthday&client_id=299921333363453&redirect_uri= Second, the one I like more and want to have on my first site has pretty dialog page and buttons **Allow Don't Allow** : www.facebook.com/dialog/oauth?scope=email,user_birthday&client_id=202378033138565&redirect_uri= The only reason I assume is different App settings in FB but they look same to me. What could be a reason?
It seems that the first one has enabled the new auth dialog Check your app settings. For more information, please refer to this doc: <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "facebook, api, oauth" }
Redirect all non www HTTPS request to www HTTPS I want to redirect all requests from < to < I can able to access the application without www and with www. wwww.example.com is an ALIAS for an application Load Balancer also configured ACM certificate for an application. Currently, DNS entities configured in Route53. please find the Network Loadbalancer rule has defined below. But if someone has enter like that < it doesn't direct to < **Rules :** Redirect to Status code:HTTP_301 please suggest me how to achieve this scenario.
In the Application Load Balancer you should set up a listener rule on your https listener, i.e. the one listening on port 443, that has a redirect action to change the host from the root to the www subdomain. #{host} is the original host, example.com, www.#{host} would therefore be www.example.com Redirect to: * Protocol: #{protocol} * Port: #{port} * Custom host: www.#{host} * Original path: #{path} * Original query: #{query} * 301 - Permanently moved <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "amazon web services, amazon route53, aws application load balancer" }
Access Active Record Object Attributes in Rails Model I have a model with the following associations: class Car < ActiveRecord::Base belongs_to :transportation_vehicle belongs_to :owner has_many :parts def scrap(buyer, part) ... end end How would I access owner and parts in the scrap method?
`owner` or `self.owner`.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ruby on rails" }
leaving oil on a frying pan for use later I live alone, so I cook for myself. And often times I cook steaks/burgers on a pan, and later in the same day would return to use the same pan/oil without washing/using new oil. Is this safe, or should one wash and use a new pan before cooking every steak/burger patties? I've actually done this for more than a day once (cooked burgers in the morning, steaks later that afternoon, and then burgers for the next morning).
If you preheat the pan then you should be perfectly safe as the high heat should kill anything 'dangerous' before you add your meat for the second meal. That said, I would point out that those oils left out are likely to begin to degrade immediately, causing your steak to take on some potentially undesirable FLAVORS.
stackexchange-cooking
{ "answer_score": 5, "question_score": 3, "tags": "food safety, oil, frying pan" }
Magento 2 files to keep in repository I started a new Magento 2 project and i always keep my projects in bitbucket... When i added the files to push i got like 200Mb of files is it really necessary to keep a Magento 2 project in a repository? I am using this .gitignore file
What is necessary to keep in a repository in the context of Development System Setup of Pipeline Deployment is the default .gitignore that you are using. There are also build and production system setup documented for pipeline deployment that are to include additional folders in source control. The Development System Setup documentation lays out the recommendation for _"for anyone with a large site who does not want downtime during deployment"_ There is also _"a single machine and can tolerate some downtime during deployment, seeSingle-machine deployment"_
stackexchange-magento
{ "answer_score": 2, "question_score": 1, "tags": "magento2, git" }
Entity Framework Code First On Insert method hooks I'm trying to attach an audit log to an entity I've written, I'm wondering if there are hooks into a context that I can override to provide the desired functionality. What I'm looking to do is: * On Insert run method A * On Update run method B * On Delete run method C I could manually add this in a controller but I'd rather a more concrete solution, the desired effect is that no method can insert into the table without also inserting into the audit log.
This project shows how you can add pre- and post-action hooks into an Entity Framework 4.1 DbContext. You can either extend its `HooksDbContext` class or see how it implements the hooks in the code and change it to suit your purposes.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 7, "tags": "c#, entity framework" }
Any ideas why I'm getting this error in sprite kit when adding sound? override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) { if (gameOver == 0) { //Player End Jump. player.physicsBody?.applyImpulse(CGVectorMake(0, -40)) player.runAction(SKAction.playSoundFileNamed("sounds/jump.caf", waitForCompletion: false)) } } > > *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Resource sounds/jump.caf cannot be found in the main bundle' *** First throw call stack:
Your sound file `sounds/jump.caf` could not be found by your app. Where and how did you add it to your Xcode project?
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "swift, sprite kit" }
lenovo ideapad gaming 3-ad linux support is lenovo ideapad gaming 3-ad with core i 7 - 11 gen 16gig ddr 4 ram and nvidia GeForce rtx 3050 ti supports ubuntu 21 and another linux distros?
Short answer : high probability Real answer: I guess here is a semi-gaming like setup of your PC. Until, you don't give enough details about motherboard & BIOS setup and so on, the probability of Linux X86_64 will run on it is very very high. You choose Ubuntu, so here again I can confirm that. If you have limited performances on the Graphical card for your recent games, just install the proprietary version of the Nvidia driver to increase performances. I can also confirm you just have to choose a X86_64 linux distro to run it on your machine. If you doubt, you can use a Linux USBstick to test the distribution before choosing and installing it.
stackexchange-unix
{ "answer_score": 0, "question_score": 0, "tags": "linux, ubuntu, nvidia, laptop, intel" }
Redirect mysite.com to www.mysite.com with SSL wildcard before security warning I have an SSL wildcard for my rails site through DNSimple, and have deployed to Heroku. I have smoothly functioning full-site SSL for all subdomains of my site, except for when I enter my site name without a subdomain into a browser for the first time. Although my Heroku settings redirects ` to ` the browser pops up a security warning first, because the SSL certificate for `*mysite.com` requires a subdomain. Is there a way to redirect from no subdomain to with subdomain before checking for the security certificate? This is a substantial issue, as it's unreasonable to require/expect first time visitors to type in `www` before the site name.
you can use subdomain redirection: < but I think only with the www form, as it warns: > Requests made directly to naked domains via SSL (i.e. < will encounter a warning when using subdomain redirection. This is expected and can be avoided by only circulating and publicizing the subdomain format of your secure URL.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ruby on rails, ssl" }
Rewrite equation to solve for $x$, not $y$ I am doing calculus integration, and need to show my work for Horizontal slicing (even though Vertical slicing is far easier). The equation is $$y= x/\sqrt{2x^2+1}$$ I need to rewrite the equation so that it is $x=\;...$ in order to horizontally slice it (in other words, it should be rewritten so that it is dependent on $y$). This isn't exactly a calculus question, although it is being used for calculus. I'm probably missing something that is pretty obvious. Any help would be greatly appreciated!
Heres a tip: Take reciprocals. Notice $$\left( \frac{1}{y}\right)^2=\left( \frac{\sqrt{2x^2+1}}{x}\right)^2=\frac{2x^2+1}{x^2}=2+\frac{1}{x^2}$$ Then we get $$\frac{1}{x^2}=\frac{1}{y^2}-2$$ Take reciprocals again and we find $$x^2=\frac{1}{\frac{1}{y^2}-2}$$ Take square roots, and we are finished. Hope that helps Edit: Just to make things complete I decided to add the final line: $$x=\pm \sqrt{\frac{y^2}{1-2y^2}}$$
stackexchange-math
{ "answer_score": 6, "question_score": 5, "tags": "calculus, algebra precalculus" }
Setting text color in a StyleableTextField Please advise me, how to set the text color in a StyleableTextField. The following doesn't work for me (the color stays black): tf.setStyle('color', 0xFF0000); And this too: tf.setStyle('color', 'red');
`StyleableTextField` has a `textColor` property. Try using that. (`tf.textColor = 0xFF0000;`). However, I found that in my ItemRenderers I sometimes need to use both the `textColor` property and the setStyle to properly change colors of StylableTextFields. Don't really know why, yet.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "apache flex, flex4, flex4.5, flex4.6, flex mobile" }
Detect MSI Installed Features By MSI Upgrade Code I need to detect what features of MSI package are currently installed on the computer but I know only MSI upgrade code guid. Any ideas how to do this some nice way? Thanks, Marek
If you're just migrating feature states from a previous version of the same install, you can do this by authoring the Upgrade table - fill in your Upgrade Code and version range, then set Attributes to '771' and it will copy over the feature states without removing the other installation. If you need to do this in an unrelated app, you can do this with the Automation Interface \- Use the MsiEnumRelatedProducts call to get a Product code from your Upgrade code, then use that product code with MsiEnumFeatures to get a list of features, and then with MsiQueryFeatureState to read the feature status.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "windows installer, installshield" }
Is defined by vs. is contained Say I have a definition and I am trying to find an English word that represents it, and I provide an example of said word (think word=fruit, example=apple). Someone gives me a word whose definition is a superset of mine (think food). How would I go about expressing "My example is _contained_ within the definition of the word you suggested."? _contained_ does not seem very sound here. I am looking for a word that is used commonly.
"Contained by" is a reasonable enough choice. A more precise usage would be > My example is a hyponym of yours. Or conversely: > Your example is a hypernym of mine. These each have precisely the meaning you are seeking, that a word defines something that is contained within the definition of another. Neither are particularly common words though. If this distinction comes up often for you, they are worth learning, but if it's important, as you say, to use a common word, then I'd say keep with _contained_ ; it's not as precise but that's the cost of keeping to more common words.
stackexchange-english
{ "answer_score": 3, "question_score": 0, "tags": "word choice, synonyms, vocabulary" }
How to calculate mouse position relative to drawing area when it hovers over element being drawn Imagine simple ms paint application written in react and you are trying to implement rectangle drawing. It's something I currently have but if I drag my mouse over rectangle I am currently drawing it starts to flicker because it fires event with position relative to rectangle and not drawing area (in my case `div`) depending over which element (drawing area/rectangle) my mouse is currently over. I have extracted the problem into this simple app < I feel like I could solve the problem with hacky calculations but I would appreciate some elegant solution/advice as this functionality is going to be base stone of bigger application.
The actual problem is that the blue box you are drawing eats up the mouse events. You can just add `pointer-events:none` to it so that it is ignored. ( _`pointerEvents` when used from inside React_) style={{ width: item.w, height: item.h, top: item.y, left: item.x, border: "solid blue", position: "absolute", pointerEvents:"none" }} Updated demo at <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, reactjs, dom, dom events" }
Completeness axiom to find a least and greatest element I have a solution for the following question. _Let $L$ and $U$ be nonempty subsets of $\mathbb{R}$ with $\mathbb{R}=L\cup U$ and such that for each $l$ in $L$ and each $u$ in $U$, we have $l <u$. Then, either $L$ has a greatest element or $U$ has a least element._ The solution is as follows. _$L$ is bounded above so it has a least upper bound $l_0$. Similarly, $U$ is bounded below so it has a greatest lower bound $u_0$. If $l_0 \in L$, then it is the greatest element in $L$. Otherwise, $l_0 \in U$ and $u_0 \leq l_0$. If $u_0 < l_0$, then there exists $l \in L$ with $u_0 < l$. Thus $l$ is a lower bound for $U$ and is greater than $u_0$. Contradiction. Hence $u_0 = l_0$ so $u_0 \in U$ and it is the least element in $U$._ My question is, how do we conclude that _If $u_0 < l_0$, then there exists $l \in L$ with $u_0 < l$_?
Since $l_0$ is the least upper bound of $L,$ then by definition, any number $x$ strictly less than $l_0$ fails to be an upper bound of $L.$ In particular, if $u_0<l_0,$ then $u_0$ is not an upper bound of $L,$ and so there is some $l\in L$ such that $u_0<l.$
stackexchange-math
{ "answer_score": 3, "question_score": 1, "tags": "real analysis" }
Time complexity of contains(Object o), in an ArrayList of Objects As the title says, I was wondering what the time complexity of the `contains()` method of an `ArrayList` is.
O(n) > The `size`, `isEmpty`, `get`, `set`, `iterator`, and `listIterator` operations run in constant time. The `add` operation runs in amortized _constant time_ , that is, adding n elements requires O(n) time. All of the other operations run in linear time (roughly speaking). The constant factor is low compared to that for the LinkedList implementation. <
stackexchange-stackoverflow
{ "answer_score": 58, "question_score": 48, "tags": "java, arraylist, time complexity" }
How to determine use of "ever" word at this question? Native speakers sometime use **ever** word and I cannot understand why it is used in the question. For instance: > When am I ever going to use this? I wonder that what does the speaker specify with using of **ever** word in the questions above?
* I am **never ever** going to use this. Never ever is an intensifier * Question form: When **am I ever** going to use this? In the background of this particular interrogative usage, _there is always this idea of the declarative with **never ever**._ Please note: The expectation of this type of question is a negative answer. These types of question can also be somewhat rhetorical. Let's say that for some reason someone gives you an item of clothing that you really dislike. If you ask the question: **When am I ever going to wear this?** It is really a kind of rhetorical question because it's obvious from your tone that you hate it. So, your friends who are with you might say: NEVER [shouting]. For example.
stackexchange-ell
{ "answer_score": 2, "question_score": 0, "tags": "word usage, word meaning" }
why 64 is equal to 65 here? how is this possible? I know there is some trick, should someone please explain?! !enter image description here
This is a very well known optical illusion. Count the number of squares in each triangle (or at least in each non-vertical or non-horizontal line) and you'll see that they don't have the same slope. Therefore the triangles cannot magically ''fit'' as they seem to do so. The slope of green and red is 3/8 (0.375), where as the slope of blue and orange is 2/5 (0.4). These numbers are quite close so it's easy to hide one square unit. But the slopes cannot fit the way they look like they do. Hope that helps,
stackexchange-math
{ "answer_score": 16, "question_score": 7, "tags": "geometry, puzzle, fake proofs" }
Blackberry10 Developer Certificate not generated I am developing a game for Blackberry 10 using "Runtime for Android apps".I have completed the development, but when i am going to create development certificate to create.bar file, it is throwing exception as " **Exception in thread "main" java.lang.NoSuchMethodError: sun.security.x509.CertAndKeyGen.getSelfCertificate** ". !enter image description here My barsigner.csk and barsigner.db are already created.What could be the possible solution for this.I am using only simulator for testing.Please help!
I have able to solve my problem using command line tool. I have downloaded "CommandLineTools_1.5.2" and copied "blackberry.tools.SDK" into "C:\Eclipse\plugins\net.rim.ejde". after that write a simple command in cmd "blackberry-keytool -genkeypair -storepass -dname "cn=" *.It will generate author.p12 file and after that you can generate debug token. :)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "android, certificate, blackberry 10, code signing" }
(Umschreibender) Terminus für eine Person, die immer ihre Termine einhält Gibt es im Deutschen einen (umschreibenden) Terminus für eine Person, die immer ihre Termine einhält und Sachen immer fristgerecht erledigt? Ziemlich oberflächlich wäre sicherlich das Nomen "Perfektionist". Hier stört mich leider, dass das Nomen für viel zu viele verschiedene Bedeutungen verwendet wird und daher nicht präzise genug ist. Ich hoffe, dass die Community mir hierbei helfen kann :)
Will man kennzeichnen, das jemand die personifizierte Termineinhaltungsmaschine ist, dann sagt man > Er ist die Pünktlichkeit in Person oder > Er ist die Pünktlichkeit selbst
stackexchange-german
{ "answer_score": 9, "question_score": 4, "tags": "single word request" }
Checking if subspace I'm struggling a bit with this problem: Is the following set a subspace of ${R}^3$? $V_3={(a_1,a_2,a_3): (a_2)^2=a_1-a_3}$ So I see that we have the zero-vector. But I'm having a hard time finding out if the subspace is closed under addition due to the square that confuses me. Because if I had two vectors a and b, I would do the following: $(a_1+b_1), (a_2+b_2), (a_3+b_3)$ But I cant add $(a_2+b_2)$ because the expression I have for them both are squared. What should I do?
This space is not a subspace. Consider the two vectors $a=(2,1,1)$ and $b=( 2,-1,1)$ both are in $v_3$ But their sum is the vector $ (4,0,2)$ is not in $V_3$ which proves that $V_3$ is not a subspace of $R^3$
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "linear algebra" }