INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
How to get the average monthly percent excess returns for portfolios formed? I'm replicating the Fama-French five factor model. I have formed factor portfolios. I'm not sure how to calculate the average monthly percent excess returns for portfolios. In other words, I want to get the Table 1 in their paper. Thanks in advance
If you have a Bloomberg terminal, you have several options including writing a few Excel functions to dump the data you need to produce these calculations (see =BDH() ). Based on what I can glean from the question, you do not have that option. I'd try Yahoo finance for historical asset price data -- should be able to pull down the TBill rate AND the stock returns of your portfolio. Once you have that historical pricing data, you'll have to compute the returns by comparing the increase in asset price of your portfolio with the increase in the TBill index (or the current annual yield of the TBill adjusted for the holding period or something). If you have any updates or clarifications to the question that may redirect our answers, feel free to call that out.
stackexchange-quant
{ "answer_score": 0, "question_score": 0, "tags": "portfolio, fama french" }
Compile LaTeX source file in the background without any plugin I am new to Vim and I would like to make a key binding to compile my LaTeX source. I have the following autocmd FileType tex :nnoremap <buffer> <F5> :!pdflatex %<CR> which is working very well but **I would like it to run in the background**. I know there are options with `<silent>` but I can't make them work.
If you just want a non-disruptive process to run, consider tpope's Dispatch plugin: if you have a `makeprg` setup well for LaTex, you could use it's `:Make`; otherwise, you'll want to `:Start pdflatex ...`. To silence a _mapping_ , use `nnoremap <silent> ...`. But note that this just prevents echoing of the simulated characters being typed. To silence a command, do `:silent[!] command`. With `!`, all error messages are suppressed.
stackexchange-vi
{ "answer_score": 2, "question_score": 2, "tags": "key bindings" }
Qt: How to set a date with time, to a QDateTimeEdit? I'm getting dates formatted like this: "2011-04-14 15:00:00", and want to set them to a QDateTimeEdit object. This is what i do: void MainWindow::setUIDateAndTime(QString &date) { QDateTime dateTime; dateTime.fromString(date, "yyyy-MM-dd hh:mm:ss"); QString sDatetime = dateTime.toString("yyyy-MM-dd hh:mm:ss"); // For debug testing // Create the datetime picker QDateTimeEdit *dateTimePicker = new QDateTimeEdit(dateTime); dateTimePicker->setObjectName("dateTimePicker"); ui->frameCommentHolderLayout->addWidget(dateTimePicker); } But it never get's set. The debug variable "sDateTime" is always set to "". Does Anybody see what i do wrong? Thanks in advance.
fromString function is `static` in QDateTime class. That means it _doesn't_ modify state of your `dateTime` object. Try this: QDateTime dateTime(QDateTime::fromString(date, "yyyy-MM-dd hh:mm:ss"));
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "qt, datetime, format" }
Easily reference a Scala class using a String? I have a relatively simple object with a method that makes an HTTP request. The request automatically extracts the data according to class type and spits out the necessary object. The problem is that I can't seem to reference the class dynamically. The code: object abstractObject extends APIResource { def retrieve(clazz: String, key: String) = { request("GET", instanceURL(key)).extract[clazz] } } `clazz` defines a type that is to be passed on to `extract` which allows the request to parse a JSON hash on-the-fly into an object. I need to somehow use that String to dynamically reference the class type and pass it to `extract`. Any ideas or will I need to re-architect this?
Types only exist at compile time, so you can't go from a run-time value to a type. Well, you can with Scala 2.10's reflection, which would essentially get the code you need generated at run time, and then executed. You'd need to bundle both compiler and reflection jar files with the application. However, none of that should be required for what you are proposing. A `Class` or `Manifest` object is enough -- though, of course, maybe the API you are using doesn't provide such alternative.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "scala" }
Token questions 1. When a company has a token that appears on ether-scan, and someone decides to buy the token on ether-scan using eth, will that eth they used to buy the token go to the company? Or does it only just increase the value of the token. 2. Once a person decides to exchange there tokens into eth, will the company have to pay anything for that exchange? Thank you to anyone who can help me. I am new to this.
Normally you cannot buy a token via etherscan. If you are referring to a vanilla ERC20 token, you can only purchase them via an exchange (decentralized or decentralized), peer-to-peer, or through crowdfunding. The eth spent to acquire the token will go to liquidity provider (in case of dencetralized exchanges) or other traders, which could be members of the company that issued the token. Only in the case of crowdfunding the ETH will go directly to the issuing company.
stackexchange-ethereum
{ "answer_score": 0, "question_score": 0, "tags": "tokens, ether, etherscan" }
How to attach a database using a program deployed by C#? i wanna to attach a Database from a dynamic path to a MSSQL server by coding a project to do this ,, what is the code i should write and will it be a Windows Application or Console Application ,, or there is no difference ??
In the connection string you can attach a database if the database has not already been attached. To do this in C# you should be able to do the following (this is untested): SQLConnection conn; try { conn = new SQLConnection(String.Format("Server={0};AttachDbFilename={1};Database=dbname; Trusted_Connection=Yes;", "Server Address", @"Path To Database")); conn.Open(); conn.Close(); } catch (Exception ex) { throw; } finally { conn.Dispose(); } Let me know how you get on. Regards, Stu
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, sql server" }
Windows GDI Context - Displaying Bitmaps I want to catch a Desktop frame and store it in a HBITMAP struct. Then, after creating a proper memory device context out of my application main window's device context, I would select the HBITMAP into it and the use StretchBlt to display the bitmap. But this doesn't work as expected, because it just shows a black frame. Both hdc and mem_hdc are respectively the device context and memory device context of main window initialized before. Here's the code: ... hDC desk_hdc, desk_mem_hdc; BITMAP bitmap; HBITMAP hbitmap; desk_hdc = GetDC(NULL); hbitmap = CreateCompatibleBitmap(desk_hdc, GetDeviceCaps(desk_hdc, HORZRES), GetDeviceCaps(desk_hdc, VERTRES)); GetObject(hbitmap, sizeof(BITMAP), &bitmap); SelectObject(mem_hdc, hbitmap); StretchBlt(hdc, 0, 0, 1024, 768, mem_hdc, 0, 0, bitmap.bmWidth, bitmap.bmHeight, SRCCOPY|CAPTUREBLT|NOMIRRORBITMAP); ...
The source dc of your `StretchBlt` operation is `mem_hdc`, which has a compatible uninitialized bitmap. That's why you get a black frame. If you want to capture the desktop contents, you have to first copy it to the bitmap in your `mem_hdc`. Just after `SelectObject` do: BitBlt( mem_hdc, 0, 0, bitmap.bmWidth, bitmap.bmHeight, desk_hdc, 0, 0, SRCCOPY );
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "c++, bitmap, gdi" }
Random password functionality I am having requirement to give my users a function to generate a safe password... I have the algo in my mind but don't know how to process with it.. 1. I will have a set of characters to provide in the password 2. I will have control over size of password that means select length 3. Select random indices from the array to get passsword of my selcected length... Last part is what I can't implement.. Any help will be appreciated... function randompassword() { // Declaring the function //Config Start $salt = "abchefghjkmnpqrstuvwxyz0123456789"; // Your characters bank $n = "8"; // Number of character to return //end config //Logic for password generation.. return $pass; }
$v = strlen($salt); $pass=''; srand((double)microtime()*1000000); $i = 1; while ($i <= $n) { $num = rand() % $v; $tmp = substr($salt, $num, 1); $pass = $pass . $tmp; $i++; } You can try this code..
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "php, passwords" }
How to extract the DOI sub-string from a URL string? [python] I have a list of urls of the following format: I want to extract the values after "doi.org".Here in the example my expected output is: 10.1145/2883851 I could do it on single url but to apply how get the values from a list of URLs.
If you have a list of urls with the same domain name and want to return a list of values in 10.1145/2883851 format : def replace_url(urls): result = [] for url in urls: result.append(url[16:]) # len of " is 16 return result
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -1, "tags": "python, python 3.x" }
What is the best way to work with a partner who misunderstands the drill? Regardless of the two-person drill, sometimes you have a partner who's certain he understands the drill, particularly when he's been doing it a while. Unfortunately, that's ... Not always true. In my eyes, the absolute best things to do are: * Ask the teacher for clarification on the drill * Talk to the student about how the drill works * Practice more until you understand the drill better as well Sometimes, the teacher or the student aren't readily available, and the pace of the class doesn't always allow for questions. While these are issues that probably require addressing in their own right, I don't want to focus on these here. Note - here we're talking about classes where there is minimal talking happening, and the juniors do not talk back to the seniors. So - what is the best way to handle a partner who misunderstands the drill?
if teacher or the student aren't available and the pace of the class doesn't allow for questions (and your partner doesn't want to listen to you) - just do the drill the best you can (if there are no safety concerns); consider this to be one more challenge; later (after the class) ask sensei what to do if this happens again.
stackexchange-martialarts
{ "answer_score": 7, "question_score": 12, "tags": "drills" }
Is it possible to create a fuzzy controller with micropython? I need to create a fuzzy controller with skfuzzy. Is it possible to use skfuzzy to develop a fuzzy controller with Micropython? <
In general you're not going to be able to run any significant Python 3 code under MicroPython. While it's "pretty close" to standard Python, the differences are enough to trip up anything other than the simplest code. The skfuzzy project to which you've linked depends on NumPy and SciPy, both of which are complex Python modules that depend extensively on compiled code to enhance performance. There's no chance those modules will (ever) run under MicroPython.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -2, "tags": "python 3.x, microcontroller, micropython, fuzzy logic, skfuzzy" }
Firebug: open console during debugging in script tab When I'm debugging javascript in Firebug I have to switch frequently between the console and the script tab, whereas in Webkit Inspector I can just open a console from the bottom. I think it's easier to inspect variables and object using the console (or to test methods), instead of the graphical tools. Is there a way to have both the console and the debugging window opened at the same time in firebug, like in Chrome or Safari?
I found the solution. In the script tab, press `CTRL`+`SHIFT`+`L`, and the console ( _Command Line Popup_ , as the doc says) will appear at the bottom (as in Chrome). To turn it off, press `ESC`.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 3, "tags": "javascript, debugging, firefox, console, firebug" }
Replacing = with '\x' and then decoding in python I fetched the subject of an email message using python modules and received string '=D8=B3=D9=84=D8=A7=D9=85_=DA=A9=D8=AC=D8=A7=D8=A6=DB=8C?=' I know the string is encoded in 'utf-8'. Python has a method called on strings to decode such strings. But to use the method I needed to replace `=` sign with `\x` string. By manual interchange and then printing the decoded resulting string, I get the string سلام_کجائی which is exactly what I want. The question is how I can do the interchange automatically? The answer seems harder than just simple usage of functions on strings like replace function. Below I brought the code I used after manual operation? r='\xD8\xB3\xD9\x84\xD8\xA7\xD9\x85_\xDA\xA9\xD8\xAC\xD8\xA7\xD8\xA6\xDB\x8C' print r.decode('utf-8') I would appreciate any workable idea.
Just decode it from quoted-printable to get utf8-encoded bytestring: In [35]: s = '=D8=B3=D9=84=D8=A7=D9=85_=DA=A9=D8=AC=D8=A7=D8=A6=DB=8C?=' In [36]: s.decode('quoted-printable') Out[36]: '\xd8\xb3\xd9\x84\xd8\xa7\xd9\x85_\xda\xa9\xd8\xac\xd8\xa7\xd8\xa6\xdb\x8c?' Then, if needed, from utf-8 to unicode: In [37]: s.decode('quoted-printable').decode('utf8') Out[37]: u'\u0633\u0644\u0627\u0645_\u06a9\u062c\u0627\u0626\u06cc?' In [39]: print s.decode('quoted-printable') سلام_کجائی?
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 7, "tags": "python, utf 8, decode, backslash" }
Proof by induction that $1^2 + 3^2 + 5^2 + ... + (2n-1)^2 = \frac{n(2n-1)(2n+1))}{3}$ I need to know if I am doing this right. I have to prove that $1^2 + 3^2 + 5^2 + ... + (2n-1)^2 = \frac{n(2n-1)(2n+1))}{3}$ So first I did the base case which would be $1$. $1^2 = (1(2(1)-1)(2(1)+1)) / 3 1 = 3/3 1 = 1$ Which is right. Then I assumed true for k so $1^2 + 3^2 + 5^2 + ... + ((2k-1)^2 = k(2k-1)(2k+1)) / 3$ This is where I get lost. I know that the next step is to prove its true for k+1, but I am lost on what to do here. Do I actually simplify down what I assumed true for k? Am I right so far?
**Hypothesis:** $$\sum \limits_{k=1}^n (2k-1)^2 = \dfrac{n(2n-1)(2n+1)}{3} $$ **For $n+1$:** $$\sum \limits_{k=1}^{n+1} (2k-1)^2 = \dfrac{(n+1)(2n+1)(2n+3)}{3} = \dfrac{4n^3 - n}{3} + (2n+1)^2 = \dfrac{n(2n-1)(2n+1)}{3} + (2n+1)^2$$ which is exactly what we wanted.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "discrete mathematics, summation, induction, proof explanation" }
How to download a file from server with a button click Let's say I have this file on my server: server/myFile.txt How can I make the user download it with a button click? Am I missing a simple solution? I am using jQuery & PHP if there is a solution for that. thanks, Alon
If you want to force a "save-as" dialog box to open for a file type that your web server is configured to output as a readable document (and you don't want to change that configuration), you need to create a file that modifies the headers so that the browser creates such a dialog. See the very first example in the php documentation for readfile. You would then create a PHP file that could be accessed through a normal `a href` link, which would send the appropriate headers and output `myFile.txt`.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 3, "tags": "php, javascript, jquery, html, download" }
Failed to connect to SDP server on FF:FF:FF:00:00:00: No such file or directory I am trying to configure Bluetooth PAN on raspberry in order to be able to access it over bluetooth from android ssh client. I was following tutorial. All works fine until the command `sdptool get Lan` that gives me `Failed to connect to SDP server on FF:FF:FF:00:00:00: No such file or directory`. How to solve it?
This might help sdptool is broken in Bluez 5 You need to run the blue tooth daemon in compatibility mode to provide deprecated command line interfaces. You're running Bluez5 and you need some Bluez4 functions. You can do this by editing this file /etc/systemd/system/dbus-org.bluez.service and changing this line ExecStart=/usr/lib/bluetooth/bluetoothd to this `ExecStart=/usr/lib/bluetooth/bluetoothd --compat` and then restarting bluetooth like this sudo systemctl daemon-reload sudo systemctl restart bluetooth and you'll also have to change permissions on `/var/run/sdp` sudo chmod 777 /var/run/sdp
stackexchange-raspberrypi
{ "answer_score": 28, "question_score": 10, "tags": "raspbian, bluetooth" }
Is it possible to run a gradle plugin without android studio? To use firebase I need to use the The Google Services Gradle Plugin however I m not under android studio. I already downloaded from maven the google-services-3.0.0.jar but what to do with it? is their any way to make it running outside android studio ? else what exactly this plugin do ? is it possible to do it manually ?
It is possible. Gradle is just a build tool. Android studio uses Gradle to describe, build and run your project. Gradle plugin is something you add to your `build.gradle` script. While it's theoretically possible to use it outside Gradle, it's not meant to be used that way. You can still use the Gradle script in any IDE that supports Gradle, or simply run it from the command line. The only thing you need in your Gradle project is the following line: apply plugin: 'com.google.gms.google-services'
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "android studio, firebase, gradle, android gradle plugin, gradle plugin" }
python library to find outline of image I am working with Python and PyQt4. I am looking a library with which I can find the outline path of an image (bitmap). With "outline path" I mean a polygon, which separates filled (non-transparent) pixels in the middle of the image from transparent pixels surrounding them. I can not find anything via google, which kind of makes me wonder if I am using the correct search terms. Thanks!
OpenCV has a function called FindContours which does what I want.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "python, image" }
UITabelView Won't Scroll At All I have a UItableView at the bottom of a UIView and I have a button on top of the table that drags it up. After it is dragged up though, the table doesn't respond to any touch. Any support? I have tried bringing it to the front of the view. My table is created programmatically. I can see it perfectly and there are 30 cells. !enter image description here !enter image description here songTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 460, 320, 440)]; [self.view addSubview:songTable]; songTable.dataSource = self; songTable.delegate = self; [self.view bringSubviewToFront:songTable];
Responding to your comment as an answer. Looking at your application screenshots (nice UI by the way!) I'm inferring that the design consists of two views that slide vertically. The issue with the table view scrolling lies in the fact that your table view is being added outside of the bounds of its superview and is therefore not receiving touch events. Here's how I would setup the view hierarchy to fix this: [self view] [container view] [current song album art view] [song playing view] [song controls view] [table view] To achieve the sliding effect, you could just alter the y-origin of "container view" or also apply vertical transforms to it. Just make "container view" have a height of 900 points or whatever the height of your elements totals up to, and you're set, since every subview is laid out within the bounds of its superview.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "iphone, objective c, uitableview" }
angular example for Multi-Column ListView - nativescript this may be a really simple question from ur view but I didn't find a simple example anywhere I found this already but it is not in angular and I am quite a beginner in nativescript (working about 6 months with it) so I couldn't use it or port it to angular. so all I need is a basic sample or even plugin for multi-column listview in angular
With Angular, you have to 1. Import the `NativeScriptUIListViewModule` in your module 2. Replace self closing tags with closing tags 3. Use directives instead of XML properties Learn more at the official docs, here is a Playground Sample.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "angular, listview, nativescript, angular2 nativescript, nativescript angular" }
Azure Devops deploying to IIS Site Application What **Website name** is needed to be set in Release deployment stages in case I want to deploy to IIS application? Example: ![]( ![]( ![]( ![](
At the end it was simple enough just to put Website name in azure as: {Website Name}\\{Application Name} as for my example is TestSite\Subsite
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "azure devops" }
what is mean by the following statement in java (MY_CLASSPATH=lib/*:properties:.) I want to understand the following statement, could you please share your knowledge on this.(MY_CLASSPATH=lib/*:properties:.)
It means that your classpath would be made from: * The lib folder and all its files (lib/*) * The properties folder and all its files (properties) * The current dir (.) The ":" its the separator used in unix systems, ";" would be for windows systems So if you run your java class from /user/mydir then all this would be available in your classpath: java MyClass.class * /user/mydir/lib/xalan.jar * /user/mydir/lib/xerces.jar * /user/mydir/lib/xyz.jar * /user/mydir/properties/config.properties * /user/mydir/MyClass.class
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java" }
Automatically refresh div content and immediately scroll down? The thing is, I can do both, but I can't make them work immediately one after another, it does the first in the 1st clock, and the second in the 2nd clock. I've also tried with 1 div inside another but it's the same. Here's the code: the script: $(document).ready(function() { $("#chatRoomSub").load("chatUpdate.php"); refreshId = setInterval(function() { $("#chatRoomSub").load('chatUpdate.php'); var object = document.getElementById('chatRoom'); object.scrollTop = object.scrollHeight; }, 5000); $.ajaxSetup({ cache: false }); }); the body: <div class='chatRoom' id="chatRoom"> <div class='chatRoomSub' id="chatRoomSub"> ainda nada foi escrito... </div> </div>
You need to use a callback function on the `.load()` which does the scrolling. $("#chatRoomSub").load("chatUpdate.php", function() { // scroll down }); This way, the scrolling will occur immediately after the content is loaded.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "php, javascript, jquery, chat" }
Details About: ReadonlySet? Is `ReadonlySet` means set of `ReadOnly` properties as same as ReadOnlyCollection in C#.aspx)? I am not able to find out any document for it from anywhere. Could you please let me know what is the use of `ReadonlySet` and How can we do implementation of it? let readonly: Readonly<number> = 1; let readonlySet: ReadonlySet<number> = ???//
`ReadonlySet` is a type similar to `Set`, but it does not have a `add` / `delete` method, so elements can only be added during construction: const regular: Set<number> = new Set([1,2,3]); regular.add(4); const readonly: ReadonlySet<number> = new Set([1,2,3]); readonly.add(4) //fails, add not a function Reference Unlike the readonlySet in C# you referenced, typescripts ReadonlySet is not actually a class/constructor. Its just a type. As typescript has duck typing, the `Set` is kind of a superclass to `ReadonlySet`, so the type can be "typecasted". This is actually only for typechecking, it has no runtime influence.At runtime, it's just a JavaScript `Set`.
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 7, "tags": "javascript, angular, typescript, ecmascript 6, readonly" }
Name Error when running a Python Script My code is class GuessPassword(object): def generate_Parent(self,length): genes= [] while len(genes) < length: sampleSize = min(length - len(genes),len(self.__class__.geneSet)) genes.extend(random.sample(self.__class__.geneSet, sampleSize)) return ''.join(genes) In My main method if __name__ == '__main__': random.seed() bestparent = self.generate_Parent( len(target)) and it's giving the error "NameError: name 'self' is not defined". And when I ran it without "self" it gave the error "NameError: name 'generate_Parent' is not defined". I know it's a small issue. But I searched and couldn't find a solution. Any help would be great.
You use `self` out of the class, also you need to make an `object` of the `GuessPassword` class, if you want to use class methods. if __name__ == '__main__': random.seed() # bestparent = self.generate_Parent( len(target)) # here is error # make object of a class guess = GuessPassword() # remove `self` because you are not in a class, and use object instance bestparent = guess.generate_Parent( len(target))
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "python, program entry point" }
Extend people search with custom contacts list I'm trying to extend the default people search (that crawls the user profiles) with contacts I've put in a custom SharePoint list (a kind of external contacts list). My goal is that when people search for a name, results from the people search (my user profiles) and from the external contacts list appear in the search results. I know you have to create query rules and/or results sources but this sound confusing for me. Ofcourse i've searched on it on the internet, but a lot of solutions are for SP2010 and since search in 2013 is changed a lot, I'm looking for a clear solution for this. Anyone who has any information about this?
Assuming you use SP2013 The search you do on "people" is basically a standard search with an extra filter parameter that indicates only to return people results. Create a custom content type and make the search return: people results **or** items with your custom contenttype. The difficulty will be mapping the properties correctly (reuse existig columns!). Then create a custom display template (start with a copy of an existing one) Then configure the search page (or create a new one, copy an existing one). In the properties of the core results webpart, edit the query to the correct filters and set your custom display template. This tool might come in handy to test your query results <
stackexchange-sharepoint
{ "answer_score": 0, "question_score": 0, "tags": "2013, search, search results, people search" }
How to load namespace System classes? I have little question. I found this on internet: Type t = typeof(MyClass); MethodInfo[] mi = t.GetMethods(); Is there any way how to do same thing with namespaces? Or is there any another way to get all classes with names and System.Type instances? Long time ago I found something about listing the library. Please anybody help me.
You can get all classes from the `mscorlib` assembly using this little hack: `typeof(string).Assembly.GetTypes()`. You can further filter on it by `FullName` or `Namespace` property.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "c#, oop, class, namespaces, system" }
Strange class array issue - can't show it in jsp I'm creating an array in my class and then, I'm returning it back to a jsp. The array code is: private String[] appNames = new String[50]; public String[] getAppNames() { return appNames; } public void setAppNames(String[] appNames) { this.appNames = appNames; } In my jsp I'm trying to show it like this: <% String username = session.getAttribute("username").toString(); Menu val = new Menu(username); System.out.println(val.getAppNames()); %> and what I'm getting is: [Ljava.lang.String;@7022c24e I'm pretty sure that I'm missing something small. I guess that I can not create getters and setters for an array in the class, but I'm still a java beginner. Is it possible to get the value of the array in my jsp, or I have to call a servlet by ajax?
You are getting the correct `array` the only problem is that you are printing the array, hence you are getting that output. If you want it to be printed in a beautified way then you need to override the toString method in your Menu class. As far as the usage of `array`, you have not shared any code but you can put a loop to iterate over that array and confirm that you are getting the values at the desired indices.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "java, class, jsp" }
Can not logout correctly since upgrade to 14.04 After I upgrade to 14.04, I cannot logout correctly, the system will hang on in black screen(while the cursor is still visible), and I have to run killall -u $USERNAME to get back to lightdm interface. I find the exactly process hanged my system on is "init", after kill it the system logout correctly. Anyone get any idea what might cause this issue, or which log file should I look into?
Nevermind, I've already found out the system was suspended from logging out by fcitx-qimpanel, which get a segment fault after I install sougoupinyin. So if any other chinese user installed that package find this topic, you might have an answer.
stackexchange-askubuntu
{ "answer_score": 0, "question_score": 0, "tags": "14.04, logout" }
Is this sentence "Sign up for class" correct? Someone told me that the verb `sign up` isn't used to mean class registration. Instead, I should use `to enroll`.
> **Sign up:** the action of enrolling for something or of enrolling or employing someone. > > * A sign-up fee of £29.95. > * He signed up 50 employees this year alone. > * The signing up process is too long. > If you Google search for the definition of **sign up** , you would find similar meanings. So, there is not much difference between the two (sing up and enroll). Plus, as others have already pointed out, **enroll** is more formal than **sign up**.
stackexchange-english
{ "answer_score": 2, "question_score": 1, "tags": "meaning" }
Why are my tactics ratings on chesstempo and puzzle rush different? I just started chess.com puzzle rush today for the first time. My chesstempo blitz puzzle rating is 1567, but I can only get to 16-17 on puzzle rush, which is about 1000-1100. My mouse is bit slow, but still, shouldn't I be reaching 25-27? What am I doing wrong?
After reading the comments, now I understand the question. The answer is simple: **time**. On ChessTempo you don't have a time limit, while on Puzzle Rush you have to answer within a few seconds if you want to make it to problem #25 or above. You also get a 1500 ChessTempo rating by getting right a certain amount of problems at that level (if you get them every single time your rating will go above that), but on Puzzle Rush you can only fail twice, so you'll need an effectiveness bigger than 90%... while answering within a few seconds!!! There's also the difference in rating systems (each site could assign different ratings to problems of similar difficulty), so, as I wrote in the comments, if two numbers mean different things, you shouldn't expect them to match, despite looking related in appearence
stackexchange-chess
{ "answer_score": 4, "question_score": 1, "tags": "tactics" }
controller to view array transfer error i have a array in my controller and i am loading a view and transferring array to it my controller function is this public function do_search() { $exp=$this->input->post('expert'); $records=$this->do_search_md->search($exp); //debug($records);die; if (!empty($records)) { $this->load->view('new',$records); //$this->load->view('header'); //$this->load->view('getdr1',$records); } else echo "error"; } $records is my array.. i have a function in my debugger helper debug($records); its working fine giving result like this ![enter image description here]( but when i am loading getdr1 view... it says $records is UNDEFIND!!!
In your controller $records['record']=$this->do_search_md->search($exp); In your view print_r($record);
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "php, codeigniter" }
Bitwise shift returns unexpected value in Python I'm performing `55 << 30` in C# and Python 3. C# returns `-1073741824`, which is what I want, but Python returns `59055800320`. Can someone explain why exactly this happens, and what I can do to fix it?
python ints are arbitrarily large ... you can force it sort of import numpy numpy.int32(55) << 30
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, python 3.x, bit manipulation, bitwise operators" }
Hashing web user password in ASP.NET vs SQL CLR Are there any security concerns in choosing to hash a user password at the application level in ASP.NET vs at the database level in SQL CLR? I'm seen it done both ways. My thinking is that in the application level, the password is only sent once from the browser to the webserver. In a database implementation, the password is sent a second time to the database for hashing. In the latter case, someone running SQL Server Profiler would be able to see the password sent to the procedure or function in plaintext. I'm not too familiar with SQL Server Auditing, but if it had the ability to capture similar information it would pose a risk as well.
You should hash the password in your application, not in you database. This means that: * Browser to application -> password is send in plain text protected by ssl * application to database -> password is allways hashed Now you have no problem with someone running a profiler, because the passwords are hashed. Besides that if someone can run a profiler, he can probably do much more damage then reading the passwords...
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "asp.net, sql server, sqlclr" }
Issues with pthreads compling It seems I'm having issues with the pthread when I try compiling with a Makefile: /csapp.c:462: undefined reference to `pthread_create' I think it might have something to do with the -lpthread? Here is my Makefile (yes they are tabbed once): CC = gcc CFLAGS = -Wall -g LDFLAGS = -lpthread OBJS = proxy.o csapp.o all: proxy proxy: $(OBJS) csapp.o: csapp.c $(CC) $(CFLAGS) -c csapp.c proxy.o: proxy.c $(CC) $(CFLAGS) -c proxy.c clean: rm -f *~ *.o proxy
I believe your problem is with `LDFLAGS`. From **10.3 Variables Used by Implicit Rules**: > `LDFLAGS` Extra flags to give to compilers when they are supposed to invoke the linker, `ld`, such as `-L`. Libraries (`-lfoo`) should be added to the `LDLIBS` variable instead. > > `LDLIBS` Library flags or names given to compilers when they are supposed to invoke the linker, `ld`. `LOADLIBES` is a deprecated (but still supported) alternative to `LDLIBS`. Non-library linker flags, such as `-L`, should go in the `LDFLAGS` variable. So try: LDLIBS = -lpthread
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "c, linux, makefile, pthreads, gnu" }
Return indexes of list in same order as input I have the following list: inputList = [5, 2, 1] which corresponds to the indexes in another dataframe [4,1,0] However, to get the indexes I always get the sorted indexes (`[0,1,4]`), not the `inputList` index order: idx = [df['id'].isin(map(str,sorted(inputList)))].index.tolist() How can I get it?
If `inputList = [5, 2, 1]` matches the indexes `[4, 1, 0]`, it is not surprising that `sorted(inputList)` (which is `[1, 2, 5]`) matches the indexes `[0, 1, 4]`. Try without `sorted`: idx = [df['id'].isin(map(str, inputList))].index.tolist()
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, pandas, dataframe" }
I am struggling with my header in CSS not resizing correctly. I am struggling making my mobile first design work as my header doesn't resize in mobile view. I am fairly happy with how it looks in full-screen. I couldn't make any media query work. the files can be downloaded and view on my git-hub account at: < If anyone can take a look and help me out, I would appreciate it. Thank you in advance. The image shows what I want in small to mobile browsers.
I guess you might need `max-width:100%` Which will not let your carousel overflow You might want to remove the unwanted space as well, which is created while resizing. Please check **this pen** , thank you for putting it in Codepen it helps us a lot.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "javascript, html, css" }
SharePoint Foundation 2013, branding search results page? How I can brand search results page in SharePoint Foundation 2013? I have brand other sites using custom.css file, however it dosen't work in search result page at all. What am I missing here? How I can change background etc?
The search results page exist in a search template/web part. You can edit these and even create your own based on the standard templates. To see all the default search display templates, `go to Site settings --> Master pages and page layouts. In the Master Page Gallery, click Display Templates --> Search.` The following diagram is how it all hangs together. !enter image description here The following blog post explains it all in full detail. The 2nd link is how to specifically create your own. Understanding how search results are displayed in SharePoint Server 2013 Customizing SharePoint 2013 Search Display Templates
stackexchange-sharepoint
{ "answer_score": 1, "question_score": 0, "tags": "sharepoint foundation, css, search results, branding" }
How to find the MLE for $P(X>a)$ for $n$ iid normal random variables I am given that $X_i \stackrel {iid}\sim N(\theta,\sigma^2)$ for $i=1,\cdots,n$, with known $\sigma$ and given $a$. Where $p=\mathbb P(X_1>a)$, I am asked to find the MLE of $p$. So far, I have tried to put the joint likelihood of the $X_i$ in terms containing $p$. I have not succeeded in doing this. I know that $$L(\mathbf{\vec{X}})=(2\pi\sigma^2)^{-n/2}\exp\left\\{-\frac1{2\sigma^2} \sum_{i=1}^n (X_i-\theta)^2\right\\}$$ and that $p=1-\Phi(\frac{a-\theta}\sigma)$, with $\Phi$ the cdf of $N(0,1)$. But I can't find a way to put $p$ into the expression for $L(\mathbf{\vec{X}})$. **Edit:** after reading this question on Cross Validated, I have a possible answer, which I will put below. Comments would be appreciated.
After reading this related question on Cross Validated, I used the following reasoning. (Any comments as to the validity of this reasoning would be appreciated.) Recall that the MLE of $\theta$ is $\bar X$. Notice $p=\mathbb P(\frac {X-\theta}\sigma>\frac{a-\theta}\sigma)=1-\Phi(\frac{a-\theta}\sigma)$. Thus, by the invariance property of MLEs, where $\delta$ is the MLE of $p$ we have $$\delta=1-\Phi\left(\frac{a-\bar X}\sigma\right).$$
stackexchange-math
{ "answer_score": 1, "question_score": 2, "tags": "probability, statistics, statistical inference, maximum likelihood" }
How do I count these comparisons in selection sort? Here is my code count = 0 def selectionSort(data): for index in range(len(data)): min = index count += 1 # Find the index'th smallest element for scan in range(index + 1, len(data)): if (data[scan] < data[min]): min = scan if min != index: # swap the elements data[index], data[min] = data[min], data[index] return data data = selectionSort([3,4,5,2,6]) print(count, data)
Your code as-is should not run. You should get `local variable 'count' referenced before assignment`. To fix this, add the following to the top of `selectionSort(data)`: global count A better way is to scrap the global variable and return `count` alongside the sorted data: def selectionSort(data): count = 0 for index in range(len(data)): min = index count += 1 # Find the index'th smallest element for scan in range(index + 1, len(data)): if (data[scan] < data[min]): min = scan if min != index: # swap the elements data[index], data[min] = data[min], data[index] return count, data count, data = selectionSort([3,4,5,2,6]) print(count, data) Last but not least, you are counting something other than comparisons. I leave fixing that as an exercise for the reader.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "python" }
Android: Upload image to a specific album on Facebook I was looking at the examples in the facebook SDK for Android and I was unable to figure out how to upload an image to a specific album for a user. I have already done authentication so the user can upload to private albums if necessary. Here is my upload code: public void uploadFacebookPhoto(String description) { Bundle params = new Bundle(); params.putString("method", "photos.upload"); params.putByteArray("picture", picData); params.putString("description", description); params.putString(SOME_IDENTIFIER, MY_ALBUM); AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(mFacebook); mAsyncRunner.request(null, params, "POST", new SampleUploadListener(), null); }
Try this Snippet : Bundle params = new Bundle(); params.putByteArray("source", imageBytes); params.putString("message", "A wall picture"); facebook.request("ALBUM_ID/photos", params, "POST"); Where **ALBUM_ID** \- is your Album id in which you need to post image. For further reference check Facebook Post
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "android, facebook, facebook graph api" }
Members of the Galactic Senate Does anyone know of where I can find a complete or semi-complete list of the systems that have representation in the Galactic Senate and the CIS? I'm attempting to write a Clone Wars Model United Nations background guide and in order do that, I need a decently-sized list of member systems in both factions.
These should get you started: **Member worlds of the Galactic Republic** * Alderaan * Anaxes * Balmorra * Bothawui * Chandrila * Commenor * Corulag * Corellia * Coruscant * Eriadu * Ithor * Kamino * Kashyyk * Kuat * Malastare * Naboo * Rendili * Uvena * Xa Fel **Member worlds of the Confederacy of Independent Systems.** * Ando * Bestine IV * Boz Pity * Cato Neimoidia * Dac (Mon Calamari) * Duro * Falleen * Felucia * Foerost * Fondor * Geonosis * Hypori * Muunilinst * Mygeeto * Neimoidia * Rosha * Ryloth * Saleucami * Skako * Sluis Van * Sullust * Thyferra * Vulpter * Yag'Dhul
stackexchange-scifi
{ "answer_score": 4, "question_score": 4, "tags": "star wars, the clone wars" }
How can I control the pan, tilt, lighting, and other features on a Logitech QuickCam Orbit/Sphere AF webcam? When the **Logitech QuickCam Orbit/Sphere AF webcam** is in use on Windows, a little window pops up enabling pan, tilt, zoom, and lighting control. This applet works outside of the program currently capturing video. **Is there a similar, full featured control program available for Linux?** I did find the CLI `uvcdynctrl` and a simple python/tk GUI program pyuvcdyncrtl.py, which wraps around it, but pyuvcdyncrtl.py can't control the dynamic lighting, zoom, or other features.
You can try 'guvcview' for pan/tilt control.
stackexchange-askubuntu
{ "answer_score": 3, "question_score": 4, "tags": "webcam, camera, logitech" }
preg_match_all to find all words after a certain string I have the following string: `cache:search:amsterdam:hotel` I want to have a `preg_match_all` to find the words `amsterdam` and `hotel` (in this case). I've done some looking around and came to: preg_match_all( "/(?<=cache:search)(:/w*)/i", "cache:search:amsterdam:hotel", $matches ) I'm hoping to get $matches to have the values `amsterdam` and `hotel`, but so far I was only able to get `:amsterdam:hotel` or just `:amsterdam` in various tries. How can I get all words in between the parenthesis after the `cache:search`?
First, once you have extracted `:amsterdam:hotel` you can easily split the string. If you want to directly obtain separated words, you can use a `\G` based pattern: preg_match_all('~(?:\G(?!\A)|cache:search):\K[^:]+~', $subject, $matches); Where `\G` matches the position immediately after the previous match. _(Note that`\G` matches the start of the string too, that's why I added `(?!\A)`.)_
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "php, regex" }
KVM on RHEL 6.1 makes host sluggish I have been running RHEL 5.7 on a host just fine with several VMs (KVM). No major issues. Time came to upgrade to RHEL 6.1 as a few bugs had been fixed in this release. When I start a VM or two under RHEL 6.1, the system becomes really sluggish. Even through SSH, keystrokes appear with delay. System resources appear OK, except dstat reports "missed X ticks" (number varies from 1 < 20). I am using virtio on all the guests. The server has decent hardware (IBM x3850 with 128G RAM). Is anyone running RHEL 6.1 with KVM successfully? I've tried it on 2x servers so far and got the same result!
Maybe this is somehow about ACPI/APIC or kernel clock? I bet kernel in RHEL 6.1 has gained dynamic ticks (or, "tickless kernel") compared to one in RHEL 5.7. If you run `iostat -x 1` at your host, does it report huge number of interrupts during the lag? Interrupt storms, even if rare nowadays, can cause those stalls. Then it might be about ACPI or APIC and disabling those by appending `noapic` and/or `acpi=off` parameters to GRUB kernel line in boot menu might help. If this is about dynamic ticks, passing `nohz=off` as boot parameter in GRUB might help. If this is about something else, well, let's hope RHEL engineers can help you. :)
stackexchange-serverfault
{ "answer_score": 4, "question_score": 3, "tags": "linux, kvm virtualization, rhel6" }
KeyEvent.getKeyCode() always returns zero I am working on a pause key in my little school project, but for some reason it refuses to work. Using this code : public void keyTyped(KeyEvent me) { //ESCAPE PLS WORK ... code = me.getKeyCode(); System.out.println(code); } For some reason "code" always stays zero. I tried to put it in different voids(pressed/released etc), but it still does not work. What could be the reason?
Why not try the `keyPressed()` method again as in the example below: public void keyPressed(KeyEvent e) { int code = e.getKeyCode(); switch( code ) { case KeyEvent.VK_UP: // handle up System.out.println(code); break; case KeyEvent.VK_DOWN: // handle down break; case KeyEvent.VK_LEFT: // handle left break; case KeyEvent.VK_RIGHT : // handle right break; } } Note that you must expect an integer.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "java, swing" }
To check for special characters in a string I need to find special character in a string which has alphanumeric values in it. I have tried the below code snippet but it doesn't work. $Special_characters = ('\n|\r|\t|\a|\"|\`') $Value = "g63evsy3swisnwhd83bs3hs9sn329hs\t" if($Value -match $Special_characters) { Write-Host "Special characters are present" } else { Write-Host "special characters are absent" } The output says "special characters are absent" even though there are special characters at the end. How to resolve it?
Its an one-liner: $Special_characters = '\n|\r|\t|\a|\"|\`' $Value = "g63evsy3swisnwhd83bs3hs9sn329hs\t" $result = @($Special_characters -split '\|' | % { $Value.Contains( $_ ) }).Contains( $true ) $result is true when a special character is found, otherwise false.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "powershell" }
Upload Video from android to youtube? I need to upload the video from android application to youtube. I don`t know how to upload the video , in what format i have to upload or any way to convert and upload the Video. If there is any API or UI is available to upload the Video to Youtube, is it possible or not? Thanks.
Yeah the youtube apis support uploading video.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "android, android ndk" }
How do I return JSON response in Class based views, instead of HTTP response I have a class based view. I am using Ajax on a bootstrap modal. To avoid page refresh, I want to return JSON response instead of HTTP response with this class based view- but I have only seen how to return JSON response for function based views. **views.py:** from django.contrib.auth.mixins import LoginRequiredMixin class TaskCreateView(LoginRequiredMixin, CreateView): template_name = 'create.html' form_class = TaskForm success_url = reverse_lazy('task_list') def get_form_kwargs(self): kwargs = super().get_form_kwargs() kwargs.update(user=self.request.user) return kwargs
Try code below: from django.contrib.auth.mixins import LoginRequiredMixin from django.http import JsonResponse class TaskCreateView(LoginRequiredMixin, CreateView): template_name = 'create.html' form_class = TaskForm success_url = reverse_lazy('task_list') def get_form_kwargs(self): kwargs = super().get_form_kwargs() kwargs.update(user=self.request.user) return kwargs def form_valid(self, form): return JsonResponse({'foo':'bar'})
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 4, "tags": "python, json, django, ajax, django views" }
Is there a SQLCMD equivalent on *nix? We have a heterogeneous environment where some developers are using OSX and some are using Windows. Our build process involves DB revision control and needs to call SQLCMD to execute arbitrary scripts - our databases are all SQL Server. SQLCMD is the command line interface to SQL Server on Windows, similar to Oracle's SQL*Plus. The particular functionality we need is the ability to run SQL scripts from the command line. Is there a SQLCMD equivalent for *nix? If there isn't then the only cross-platform approach I can think of would be to load a script file into memory, then execute the script. Is there a clear leader for a library/language combination that will handle all T-SQL DDL statements? (I ask about DDL statements because they have been the hangup on this approach when I've tried it in the past.)
You might try the `fisql` utility, which is part of FreeTDS, an open-source implementation of the SQL Server wire protocol. `fisql` is purported to be a clone of the ancient `isql`, predecessor of `osql`, predecessor of `sqlcmd`, but presumably it will work with any level of T-SQL. _Disclaimer: I haven't used FreeTDS myself._
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "unix, sqlcmd" }
Listener for Orientation: Portrait and Landscape? I've an app which calculate the subnettable. But if I change the orientation the TextViews are empty. I search for an listener for this. Alternatives are welcome to :D In the listener I'd recalc the table.
Use the following code in you activity: @Override public void onConfigurationChanged(Configuration myConfig) { super.onConfigurationChanged(myConfig); int orient = getResources().getConfiguration().orientation; switch(orient) { case Configuration.ORIENTATION_LANDSCAPE: // handle landscape here break; case Configuration.ORIENTATION_PORTRAIT: // handle portrait here break; default: } }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, android, listener" }
Did Jack Vance write any stories or novels with the original Emphyrio as a protagonist? In Jack Vance's excellent 1969 novel _Emphyrio_ , the protagonist, Ghyl Tarvoke, adopts the name of a legendary hero, Emphyrio, as a sort of _nom de guerre_. Within the novel, we are told the story of Emphyrio in summary form twice: First, when Ghyl attends a traditional play based on the story, and later, a more historical account. Vance linked many of his works into a "Gaean Reach" universe and in fact refers to Emphyrio in other novels. It wouldn't surprise me if the story of the original Emphyrio was a reference to some earlier work. I'd like to know if Vance ever told the story of the original Emphyrio by itself, in a story or novel standing on its own. Or was this story-within-a-story just a plot device?
He did not. Like an awful lot of Vance's worldbuilding, the culture hero Emphyrio was just part of the background—never fully explained. It was not usually Vance's practice to flesh out the background references in his works through additional stories. Moreover, in this particular case, giving an explicit version of the story of Emphyrio would probably undermine the message that the novel _Emphyrio_ (which, unlike most of Vance's writing, is something of a novel of ideas) is trying to convey. Ghyl Tarvoke puzzles about what must really have happened to Emphyrio in legendary past, and he eventually learns a lot—but by no means the whole tale. Had Vance laid out a complete narrative explaining everything that happened to the character of Emphyrio, that would have taken away from the "punch" of the 1969 novel.
stackexchange-scifi
{ "answer_score": 13, "question_score": 9, "tags": "jack vance, emphyrio, gaean reach" }
what is the regex for the following part? src/insp/custom/extractThis1.q.ts what would be the regex for extractThis1 ? I have tried like this `/\/(.*).q.ts/gm` but didn't work
You can match until the last occurrence of `/`, and then use a capture group to match any char except a `.` followed by `.q.ts` ^.*\/([^.]+)\.q\.ts$ Regex demo const s = "src/insp/custom/extractThis1.q.ts"; const regex = /^.*\/([^.]+)\.q\.ts$/; const m = s.match(regex); if (m) { console.log(m[1]); }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -2, "tags": "javascript, regex" }
PHP & MySQL - Why is it not safe to rely on the system time settings? There are so many places where you can modify the time settings in a set up of Linux, Apache, PHP, and MySQL. I need to set everything to UTC in my server and I wondered why not just set the system time to UTC and all services just need to use the timezone "SYSTEM" as I did for MySQL. However, a simple PHP warning made me doubt my decision. "It is not safe to reply on the system's timezone settings" I have to questions, one may lead to another. 1. Why is it not safe to rely on the system time settings, specifically CentOS, in PHP, Apache, or MySQL? 2. What is the best way to unify the time settings from all services: Apache, PHP, and MySQL?
1. You should not rely on system settings as they can be changed accidentally, as simple as that. Instead, specifying the desired timezone in `php.ini` makes sure somebody gave this a thought and selected the correct timezone that is going to be used (unless overridden by `ini_set`) 2. The best way is to specify the timezone you want in corresponding `ini` and `conf` files. Moreover, if you have website now on US server and in few years you migrate to UK server, you want to copy your `conf` files as well and this assures that same timezone is used at all times.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "php, mysql, apache, timezone" }
QLabel setText not displaying text immediately before running other method I have a basic label that is supposed to indicate to the user that the program is searching directories for several seconds. So it goes like... self.label.setText(QString("Searching...")) # method to search directories goes here self.label.setText(QString("Search Complete")) My problem is that the label never displays "Searching...". The execution always seems to jump straight to run the method to scan directories, and then the label text is set to "Search Complete" after the method which scans directories has finished. I'd be grateful if someone could please explain why this is happening or suggest a better way to resolve the problem. many thanks
Your "method to search directories" is blocking the GUI hence QLabel is not able to update the text. You can make your search routine asynchronous or go the easy way and force QLabel to update itself: self.label.setText(QString("Searching...")) self.label.repaint() # method to search directories goes here self.label.setText(QString("Search Complete"))
stackexchange-stackoverflow
{ "answer_score": 34, "question_score": 13, "tags": "qt, pyqt" }
$X^6 + 3X^4+3X^2-1$ is the minimal polynomial of $\sqrt{ \sqrt[3]{2}-1}$ over $\mathbb Q$ It can easily be seen that $\sqrt{ \sqrt[3]{2}-1}$ is a root of $X^6 + 3X^4+3X^2-1$, which should be its minimal polynomial. Let $a=\sqrt{ \sqrt[3]{2}-1}$. Then $\sqrt[3]{2} = a^2+1$. Therefore $\sqrt[3]{2} \in \mathbb Q[a]$ and $\mathbb Q[\sqrt[3]{2}] \subset \mathbb Q[a]$ The goal here is to prove that $[\mathbb Q[a]:\mathbb Q]=6$. It is useful that $$[\mathbb Q[a]:\mathbb Q]=[\mathbb Q[\sqrt[3]{2}]:\mathbb Q]\times [\mathbb Q[a]:\mathbb Q[\sqrt[3]{2}]]$$ Ie$$[\mathbb Q[a]:\mathbb Q]=3\times [\mathbb Q[a]:\mathbb Q[\sqrt[3]{2}]]$$ Nevertheless I can't prove that $[\mathbb Q[a]:\mathbb Q[\sqrt[3]{2}]]=2$. Furthermore usual irreducibility criteria are of no use here.
**Hint:** $X^6 + 3X^4+3X^2-1$ is irreducible over $\mathbb Q$ if, and only if, $\underbrace{(X-1)^6 + 3(X-1)^4+3(X-1)^2-1}_{\large{=X^6-6X^5+18X^4-32X^3+36X^2-24X+6}}$ is irreducible over $\mathbb Q$.
stackexchange-math
{ "answer_score": 2, "question_score": 2, "tags": "abstract algebra, galois theory, irreducible polynomials, minimal polynomials" }
Complex page layout and design I have a page that has a around 30 links divided among 6 groups. Boat a b c Horses d e ... etc When the user clicks the link the page will display a series of controls (dropdown, htmltable, chart) in a layout specific only to the link that was clicked. I have a few ideas: 1. Create separate aspx pages for each link that share the same master page (about 30 aspx pages). Advantage: design/layout is easy. Disadvantage: 30 aspx pages 2. Determine if any links use the the same layout and create a common page with place holder controls 3. Dynamically load controls/css etc onto the page. So a few questions: 1. Are any of these good approaches? 2. What are some alternative approaches? Thanks
Certainly think twice before creating one monster page. It can become a real maintenance nightmare. Just because you have 30 aspx pages does not mean you have to repeat yourself. Structure common functionality into reusable controls. Maintenance isn't so bad.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, asp.net, webforms" }
How to set the default value of a user defined column in SharePoint depending on the content type that uses it In a SharePoint website I defined a new column that is used in three different content types. Now I want to define a different default value for this column for each content type. Is this possible using the webservice interface of SharePoint? Is it possible at all?
You cannot set a default value for a column in Sharepoint based on the content type. What you could do though is modify the editform and newform aspx pages of the lists that use the content types / columns and then use JQuery to set the value based on the selected content type.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 1, "tags": "sharepoint" }
Removing an element from a slice duplicates the last element in Go? I was playing with slices in go to better understand the behaviour. I wrote the following code: func main() { // Initialize myslice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9} newSlice := myslice fmt.Println(myslice) fmt.Println(newSlice) removeIndex := 3 newSlice = append(newSlice[:removeIndex], newSlice[removeIndex+1:]...) fmt.Println(myslice) fmt.Println(newSlice) } This is the output: [1 2 3 4 5 6 7 8 9] [1 2 3 4 5 6 7 8 9] [1 2 3 5 6 7 8 9 9] [1 2 3 5 6 7 8 9] I dont really understand what happens with **newSlice** that duplicates the 9 at the end. Also, does this mean, that this operation removes the given element from the underlying array? <
The `append` operation simply shifts the elements of the underlying array. `newSlice` and `mySlice` are two slices with the same underlying array. The only difference is the length of the two: After `append`, `newSlice` has 8 elements, and `mySlice` still has 9 elements.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "go, slice" }
Issue system call from Python, get filename for output I am writing a Python program that calls a library (GenomeTools) via its C API. There is a function in GenomeTools that takes a filename as input and processes the file's contents in a single pass. I am wondering if there is a way I can issue a system call from Python and have that C function process the output of the system call. I typically use the `subprocess` module when I want to issue system calls in Python, but this is different since the C function takes a filename as input. Is there a way I can assign a filename to the output of the system call?
You can pipe the system call output to a temporary file and then use its filename for your C call. Wit hany luck, you delete the file before it even gets out of the RAM cache onto the disk. import tempfile import subprocess as subp import os tempfp = tempfile.NamedTemporaryFile(delete=False) try: proc = subp.Popen(['somecommand'], stdout=tempfp) tempfp.close() proc.wait() some_c_function(tempfp.name) finally: tempfp.close() os.remove(tempfp.name)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python, c, pipe" }
java.lang.OutOfMemoryError: Java heap space i get this error when calling a mysql Prepared Statement every 30 seconds this is the code which is been called: public static int getUserConnectedatId(Connection conn, int i) throws SQLException { pstmt = conn.prepareStatement("SELECT UserId from connection where ConnectionId ='" + i + "'"); ResultSet rs = pstmt.executeQuery(); int id = -1; if (rs.next()) { id = rs.getInt(1); } pstmt = null; rs = null; return id; } not sure what the problem is :s
You need to close all the resources you create - prepared statement, resultset, etc.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 0, "tags": "java, jdbc" }
Best method for an ETL Package to load all data initially and then next run to only load changes or new items I am new to SSIS and would like the best method for an ETL package creation to load all data initially and then next run to only load changes or new items. I will use the package on a schedule SQL job. I know that I could set SSIS package to truncate the destination table but for me that is a waste of resources and if large tables are concern the transaction log would be huge. Thanks in advance!
I think there are more than one method to achieve that: 1. Adding a reference table that contains the last inserted ID (or primary key value), and this table must be update each time. 2. Using Change Data Capture (CDC), you can refere to the this article for more information about it: Introduction to Change Data Capture (CDC) in SQL Server 2008 _(Note that the database must be configured to enable CDC - may not work with your situation)_ 3. Adding a `LastUpdate` column to the table, and read only date where `LastUpdate` column value is higher than the last running SSIS job date.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "sql, sql server, ssis, etl, sql job" }
Manga where two students are reincarnated in another world with magic and adventurers This manga is about two students that died in an accident and are reincarnated in another world with magic and adventurers. The girl can wield magic of like 5 elements. I forgot about the guy, he can also wield magic and was described as "has a lot of potential to grow" or something like that. * It was a new manga * I'm sure it's Japanese * I ran across it online * I'm sure it was this year, maybe 3 or 4 months ago or maybe longer * I think genre would be magic/adventure * It was already translated into English * I think it was new then when I saw it because it only had like 4 chapters * I remember the 2 students were mentored by 2 women
I think you are refering to _Isekai Cheat Magician_. ![Cover of Isekai Cheat Magician]( _Click to embiggen._ The story is about two students who did not die but instead were transported into a world of magic and adventures by a magic circle. As you said in your description, the girl can use multiple elements and the boy, instead of having an elemental affinity can use magic to enhance his body. There is also the 2 women acting as mentors for the students. ![Discovery of abilities]( _Click to embiggen._ > And, the boy who has the talent of being a **'Unique Magician'** and isn't aligned with any of the elements. > > Fire - wind - earth - water, the girl who has the talent of being a **'Quad Magician'** and is aligned with the four major elements. The manga itself is fairly recent, with less than a dozen chapter translated into English.
stackexchange-scifi
{ "answer_score": 3, "question_score": 6, "tags": "story identification, manga" }
ZF2 - How To Translate Zend Form Validation Error Messages? I have the .po and compiled .mo language files for diffrent languages. But language translation is not working on zend form validation error messages. I dont want to use extra .php file like fr.php for it. I got this code from click here $translator = new Zend\I18n\Translator\Translator(); $translator->addTranslationFile( 'phpArray' 'resources/languages/en.php', 'default', 'en_US' ); Zend\Validator\AbstractValidator::setDefaultTranslator($translator); Any solution how to implement it in ZF2.
Simply add your `.po` or `.mo` files instead of the `.php` ones, i.e. like this: $translator = new Zend\I18n\Translator\Translator(); $translator->addTranslationFile( 'gettext' 'resources/languages/fr.mo', 'default', 'fr_FR' ); Zend\Validator\AbstractValidator::setDefaultTranslator($translator); And then to translate it, use echo $this->formElementErrors($form->get("username"), array('message' => $this->translate("errormessage")) ); I don't know how it is with performance of the translation in ZF2, but in ZF1 using arrays in `.php` files was way faster than any other method.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "php, zend framework2" }
Adding feature layer to ArcGIS Online from REST API? I need to add a feature layer to ArcGIS Online account from code. i have created a developer account where if i want to create a feature layer i have to upload a CSV file and it makes the feature layer. > Problem is: i need to create the sane feature layer using my code. like is there any REST API or some API which ArcGIS provide this option?
I've checked requests which were sent in ArcGIS Online to add Feature Service with Chrome dev tools and found that it uses 4 requests: 1. Create Service - create feature service with REST API without layers, see < 2. update Service item - fix service name, see < 3. addToDefinition request for admin part, see < \- **this is the request to add layer definition into empty service** 4. Last request to updateDefinition of the service (<
stackexchange-gis
{ "answer_score": 5, "question_score": 7, "tags": "arcgis maps sdk javascript, arcgis online, arcgis rest api" }
When do we have $A \subset B$ imples $f^{-1}(A) \subset f^{-1}(B)$? Im not sure if continuity of the function $f$ is enough to have the above. Or is it the monotonicity of $f$?
All you need is that $f$ is a function. If $x\in f^{-1}A$, then $f(x)\in A$, so $f(x)\in B$ as well. Carl Mummert pointed out that if $R$ is any relation between $X$ and $Y$ then the claim still holds, where $R^{-1}A=\\{x\in X: xRa\text{ for some }a\in A\\}$. This is because if $A\subset B$, then $x\in R^{-1}A$ implies $xRa$ for some $a\in A$ implies $x\in R^{-1}B$.
stackexchange-math
{ "answer_score": 5, "question_score": 1, "tags": "elementary set theory, functions" }
SDK for Developer Is there any SDK for developers under Linux? I mean more than man pages, it would be more like MSDN Library or Windows SDK under windows, where all documentation about programming and developer guide is documented and structured in one place.
For GNOME, you can check out devhelp or help.gnome.org. But as everyone has already stated, there is no single SDK for "Linux". You need to have some idea of what you want before we can recommend specific developer resources.
stackexchange-unix
{ "answer_score": 5, "question_score": 3, "tags": "man, development, documentation, system programming" }
c# display table from sql server on winform I am connecting to sql server using c#. How do I display the results of the below query on a winform? I would like to display this data set in a control. I believe it should be a datachart, but it does not matter to me. // Initialize a connection string string myConnectionString = "Provider=SQLOLEDB;Data Source=hermes;" + "Initial Catalog=qcvaluestest;Integrated Security=SSPI;"; // Define the database query string mySelectQuery = "select top 500 name, finalconc " + "from qvalues where rowid between 0 and 25000"; What is the best way to display the results of this query on a winform?
Drop a DataGridView on your form, and use this code to populate it using(var connection = new SqlConnection(myConnectionString)) using(var adapter = new SqlDataAdapter(mySelectQuery, connection)) { var table = new DataTable(); adapter.Fill(table); this.dataGridView.DataSource = table; }
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 2, "tags": "c#, .net, sql, sql server 2008, select" }
How to make object by pointer in const object constant? class Foo { public: int a = 1; }; class Bar { public: Foo *foo_ptr = new Foo; }; int main() { const Bar bar; bar.foo_ptr.a++; // valid: a == 2 bar.foo_ptr = nullptr; // invalid: foo_ptr is const } I understand, why code above is correct - object `bar` is constant, so `foo_ptr` is constant pointer to a non-const `Foo` object. But I think it's a bit illogical. Why `Foo` object also did not become const? What should I do, if I want `Bar` object to become absolute `const` here, and the `foo_ptr` to be a constant pointer to a constant object? For example, I send `Bar` object to some method, and I don't want it or any `Foo` objects in it to be modifiable.
> But I think it's a bit illogical. Why `Foo` object also did not become `const`? The compiler cannot assume how far to extend the notion of `const`. You, as the designer of `Bar`, have to help the compiler with that. You can do that by making the member variable `private` and providing `public` interfaces that preserve the `const`-ness of the object that the pointer points to. Update your class to: class Bar { public: Foo* getFoo(); Foo const* getFoo() const; private: Foo *foo_ptr = new Foo; }; and now int main() { const Bar bar1; bar1.getFoo()->a++; // Not OK. Compiler error. Bar bar2; bar2.getFoo()->a++; // OK. }
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "c++, pointers, constants, transitive const" }
Click to go to contact record from report When i am viewing contacts in a civireport if i click on the persons contact name i am taken to the "view contact detail report" which is basically the Constituent Report (Detail). Is there a way to go the the persons contact record directly from the report and not have to be referred to the Constituent Report (Detail)? this is the url it takes me to when i click on someone from the report that refers me to the constituent detail report: /civicrm/report/instance/2?reset=1&force=1&id_op=eq&id_value=6732
This extension should help with your query – <
stackexchange-civicrm
{ "answer_score": 2, "question_score": 2, "tags": "contacts, civireport" }
How to iterate all the UIViewControllers on the app I have a xib with this structure: - Tab Bar Controller -- Tab Bar -- NavigationController --- Navigation Bar --- News List View Controller ---- Navigation Item --- Tab Bar Item -- NavigationController --- Navigation Bar --- News List View Controller ---- Navigation Item --- Tab Bar Item -- NavigationController --- Navigation Bar --- News List View Controller ---- Navigation Item --- Tab Bar Item [...] How can I code a loop to take each UIViewController (News List View Controller) in each iteration?
Access them codewise like this: NSArray * controllerArray = [[self navigationController] viewControllers]; for (UIViewController *controller in controllerArray){ //Code here.. e.g. print their titles to see the array setup; NSLog(@"%@",controller.title); }
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 11, "tags": "iphone, objective c, ios" }
ISO8601 format in java given seconds How do I get a string in Java in ISO8601 given the number of seconds since the epoch? I'm having trouble finding it anywhere. I want the format to look something like this: 2000-06-31T19:22:15Z Using just Date d = new Date(# of milliseconds from my # of seconds) gives me a date in 1970 when I should be getting something in 2000.
The main problem you are probably having, is that June 2000 only had 30 days. That being said instead of using `Date`, you could use a `LocalDateTime` with `LocalDateTime.ofEpochSecond(long, int, ZoneOffset)` like long epochSecond = 962392935L; int nanoOfSecond = 0; ZoneOffset offset = ZoneOffset.UTC; LocalDateTime ldt = LocalDateTime.ofEpochSecond(epochSecond, nanoOfSecond, offset); System.out.println(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'").format(ldt)); Which should be all you need to see 2000-06-30T19:22:15Z which is _like_ your requested output.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, datetime, time, data conversion, iso8601" }
How to get all horizontal Frame lines in Grid, including topmost and bottom-most? How can I get the option `Frame` in `TextGrid` to do all horizontal lines, including top and bottom? I want: \---- a b \---- c d \---- e f \---- The closest I get is with the following command: TextGrid[{{a, b}, {c, d}, {e, f}}, Frame -> {{False, False}, All}] which produces a grid with horizontal lines but misses top and bottom: a b \---- c d \---- e f I tried several things, but to no avail.
TextGrid[{{a,b},{c,d},{e,f}},Dividers->{False,All}] !Mathematica graphics
stackexchange-mathematica
{ "answer_score": 4, "question_score": 2, "tags": "output formatting, frame" }
Get the position of a DOM element via x, y co-ordinates Is there a way to select the top most DOM element at a certain x-y position with Javascript? So give x and y, what DOM element is there?
You can use `document.getElementFromPoint`.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "javascript, dom" }
Why *formal* linear combination? In Lee's Introduction to topological manifolds on page 340 he writes that an element of $C_p(X)$ can be written as a _formal_ linear combination of singular $p$-simplices. Similarly, on Wikipedia's entry on singular homology the chain groups are described as _formal_ linear combinations of singular simplices with integer coefficients. But to me it seems that $C_p(X)$ are just linear combinations with integer coefficients. What am I missing? What does formal mean here?
Before you form a free abelian group on a set S, there is no addition operation with which to form combinations. So to build it, you have to describe elements of the space formally as "just looking like this sum." Then you are free to define an addition operation (and a scaling operation, if we're talking about a vector space) and we have a bona fide algebraic object in which the formerly formally defined sums are now "actual" sums. So you see, before you create the group, there is no way to initially describe it using "actual" sums. That's the temporary reason we need to say "formal."
stackexchange-math
{ "answer_score": 5, "question_score": 3, "tags": "homology cohomology" }
Solidity confused question in official example I am new to Solidity and reading Solidity's officail example: BlindAuction. Some detail is confusing. According to if (bidToCheck.blindedBid != keccak256(abi.encodePacked(value, fake, secret))) { // Bid was not actually revealed. // Do not refund deposit. continue; } the `uint value` in the reveal process should be exactly the same as `value` send to Contract in the bid process, so why do we need to write if (!fake && bidToCheck.deposit >= value) { instead of if (!fake) { ?
You have two API (external) functions: 1. `function bid(...) payable`, via which the user sends ether to the contract 2. `function reveal(...)`, via which the user reveals his/her bid The documentation says: > The bid is valid if the ether sent together with the bid is at least "value" Function `bid` stores an indication of the amount of ether sent to the contract (`msg.value`). Function `reveal` needs to verify that the user bid is **at least that value**.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "solidity" }
Perl getprint() returns nothing Sorry, I'm new to Perl, however, this seems really weird to me. The point is: I have a perl script with this content: #!/usr/bin/perl print "Content-type:text/html\n\n"; use LWP::Simple; getprint(" And I host it on some domain. The point is that it does work with every domain I enter except for my domain and the domain of the hosting company (including their service domains like those for admin tools and so on)... I'm really confused with that, no idea what I'm doing wrong
You should modify your script a bit for the first, with some kind of "try-catches" or "die(...) if ..." structure and further if you script works on more domains, but not on yours or some certain domains, it means that they don't like crawlers :-). There are many ways to make some workarounds, try to identify your script throw LWP like some "browser" ( you have to many examples in the 'www' ) and the second think is - use first some normal PC as a client, cause it is possible that your server ip can be ban i some of the dark lists, but this is less possible. * * * use LWP; my $userAgnt = LWP::UserAgent->new; print "Content-type:text/html\n\n"; die "no success :-(" unless defined $userAgnt->get("DOMAIN"); ## $userAgnt->getprint("DOMAIN/"); or if (is_success($userAgnt->getprint("DOMAIN"))) { ... } Cheers.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "perl, web, hosting, server side" }
Term similar to "gain" for voltage dividers In amplifiers, the magnitude of amplification is called "gain". Is there an equivalent for that on how much a voltage divider divides? Like how a voltage divider with a 100k and 39k resistor has a "divide" of 0.2806. ![enter image description here]( I wasn't able to google any results so I've come here. Please let me know if the answer is glaringly obvious.
The word you may be looking for is "attenuation" or "attenuate". A voltage divider _attenuates_ the input to produce an output that is smaller than the input so, with your 39 kΩ and 100 kΩ resistors, the _attenuation_ is: - $$\dfrac{39+100}{39} = 3.5641$$ In other words, the output is 3.5641 times smaller than the input. Or, the output is _attenuated_ by 3.5641 compared to the input. In gain terms, the gain is the reciprocal of 3.5641 i.e. 0.2806. In other words the output is 0.2806 times the input. So, you can still use the term "gain" but it has a value less than 1 for a voltage divider. Nothing wrong in doing that in fact sometimes, it is slightly less ambiguous to use fractional gain values.
stackexchange-electronics
{ "answer_score": 14, "question_score": 5, "tags": "voltage divider" }
Selective background coloring Consider this simple code: Grid[RandomInteger[{0, 1}, {10, 10}], Background -> LightBlue] ![output]( Is it possible to modify the code so that the background only apply for certain entries of the matrix, e.g. only for non zero entries?
Grid[Item[#, Background -> If[# == 1, Blue]] & /@ # & /@ RandomInteger[{0, 1}, {10, 10}]] !Mathematica graphics Grid[RandomInteger[{0, 1}, {10, 10}]] /. 1 -> Item[1, Background -> Blue] !Mathematica graphics Grid[m = RandomInteger[{0, 1}, {10, 10}], Background -> {None, None, Thread[Position[m, 1] -> Blue]}] !Mathematica graphics
stackexchange-mathematica
{ "answer_score": 6, "question_score": 2, "tags": "color, grid layouts" }
OpenGL do stuff when player don't look I'm facing this kind of problem: I would like to do something, when player isn't looking. For instance, like in SCP, move monster towards player. My question is: How can I check if player does see an object?
Assuming the player is in control of the camera. The camera has a front vector. Using that front vector and the normal of the object, in this case the monster, you can find out whether he is looking or not. You can take the dot product of the object normal and the front vector. If it is negative or equal to 0, the angle is perpendicular and the player can't see the object.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "c++, opengl, 3d" }
Editing a question to add a tag which is a new tag synonym results in the original old tag being used On Stackoverflow, I've edited this question to add the `[servlet-filter]` tag. I know, before the introduction of tag synonyms this tag was called `[servlet-filters]`. During adding the tag, the existing tag `[servlet-filter]` correctly shows up in the autosuggest. After picking it and submitting the edit, the question ends up with the old `[servlet-filters]` tag! I edited it once again and then once more, but no change. It sticks to `[servlet-filters]`. Bug? * * * **Update:** it now look like that all original `[servlet-filters]` tags were incorrectly renamed to `[servlet-filter]`. _That_ is in turn indeed a bug since it contradicts the Official Repository.
You're right, it looks like the synonym and the merge were done in opposite directions. I've renamed the tag to `[servlet-filters]` now.
stackexchange-meta
{ "answer_score": 2, "question_score": 0, "tags": "support, tag synonyms" }
How to Update Look and Feel of Older Windows User Interface? I have a really solid computer program that was written for Windows XP. The program still works great and I would like to update the look and feel of the user interface. At this time, I would like to give the buttons etc. a more sleek, contemporary look. Much better would be to allow functionality of touch and swipe etc. for tablets and such. Can anyone tell me what tools in Delphi are used to accomplish this? For instance, do I need to change every button and object manually through object inspector or can I update/modify all objects objects within a project using a single set of commands?
You can start by enabling Windows themes, using Project->Options->Appearance from the IDE's main menu. It's on by default since D2007, but won't be on because your app is coming from Delphi 5. (New projects have it turned on by default, but the IDE can't know if you want it enabled or not when importing older projects.) You can then start looking at adding gesture support by looking into the documentation for `TGestureManager` and `TGesture`. There's a `TGestureManager` for both VCL and FireMonkey (FMX) applications. Note that for cross-platform support (Android, iOS, and OS X) you'll need to port your application from the VCL to FMX.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 3, "tags": "delphi, user interface, delphi 5, delphi xe6" }
XPATH and CSS for Selenium Automation - Help Required I want to Find the XPATH/CSS locator to extract the text from the following structure. Kindly help. <div class="page-header song-wrap"> <div class="art solo-art"> <div class="meta-info"> <h1 class="page-title"> Zehnaseeb * * * I want to give the locator/XPATH so that it can return the text "Zehnaseeb" (In this case) This did not yield any result, driver.findElement(By.xpath(".//*[@id='main']/div/section/div[1]/div[2]/h1")).getText();
have you tried waiting for the element, String text = new WebDriverWait(driver,30).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div.page-header h1.page-title"))).getText();
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "css, selenium, xpath" }
jRating plugin stars do not load at all i am using jRating plugin. Everything works fine, thing is... the images of the star does not appear despite the fact that my url to the images are correct and i have already tested with other similar image content that works well using the same conventional url such as "images/stars.png" When i mouse over the url using firebug under style, the rest of my other contents' images appear but only the star.png will keep loading and does not appear. anyone knows what is wrong? the image below is a sample of what i am referring to. !enter image description here
**Note: this module is rarely updated. You probably want to use Fivestar instead.** <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "jquery, rating" }
Remove cases with a specific value in R I want to remove all rows with value 9999 in my dataset. Here is an example dataset: df <- data.frame(a=c(1, 3, 4, 6, 9999, 9), b=c(7, 8, 8, 7, 13, 16), c=c(11, 13, 9999, 18, 19, 22), d=c(12, 16, 18, 22, 29, 38)) So the final dataset will only contain row 1, 2, 4 and 6. I have a large dataset and so how to do this without specifying the names of all columns? Thank you!
An option with `dplyr` library(dplyr) df %>% filter(!if_any(everything(), ~ . == 9999)) -output a b c d 1 1 7 11 12 2 3 8 13 16 3 6 7 18 22 4 9 16 22 38 Or with `across` df %>% filter(across(everything(), ~ . != 9999))
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "r, data manipulation, data cleaning" }
In ASP.NET MVC4 - I need to edit a record and add many (1 to many) sub-records to it (while in Edit mode on the top level record) Here's my list of data: !enter image description here Going into Edit mode on the first record: !enter image description here Here on this Edit page, I need to add multiple "Departments" to this particular contact record. I have a 1 to many relationship (1 contact record to many department records). Ideally, I'd like to have something like an "Add New Department" button, where the user clicks on it and it will create form fields that tie to department. User fills them out, clicks Save, and has the option to again add another department by way of "Add New Department". I'm not exactly sure where to start - how can I go about accomplishing this?
That job can't be achieved only by mvc stuff. To achieve your goal, you need to do some extra works by jquery, ajax and partial views. The main idea is to have a partial view to representing a detail row (when in create phase) and another partial view for getting all details of a master entity (when in edit phase). A brief example is here. A full howto is here.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "c#, asp.net mvc, asp.net mvc 4, foreign keys, one to many" }
Redis finding hashes by field values When using Redis in order to create a "record" you can create a hash with several fields. For example: HMSET myhash field1 "Hello" field2 "World" HMSET myhash2 field1 "Goodbye" field2 "World" You can retrieve this by knowing the key values, however what I want to know is there any way to retrieve all hashes that have "World" in field2?
There are no indexes in redis, and it doesn't implement SQL. It's a key-value store. You provide a key, it gets you a value. That said, you can implement this by maintaining secondary indexes yourself. For example: create a record and an index entry HMSET myhash field1 Hello field2 World SADD field2_world myhash update a record, delete old index entry, create new one SREM field2_world myhash HMSET myhash field2 Mundo SADD field2_mundo myhash find all records which have "World" in `field2` SMEMBERS field2_world I hope you get the idea.
stackexchange-stackoverflow
{ "answer_score": 24, "question_score": 11, "tags": "nosql, redis" }
what is the limit of $(\log n)/n^{(1/100)}$ as n approaches infinity? I am kind of confused about this question, are we allowed to take l'Hopitals rule, can someone please show me the steps.
**It is 0.** _Yes, you can use l'Hopitals rule, to find the limit of this function. Since numerator and Denominator each is limiting to infinity at infinity._ * Derivative( log(n) ) = 1/n * Derivative( n1/100 ) = 1/100 * n \- 99/100 So as per l'Hopitals rule : limn->inf [ ( log(n) ) / ( n1/100 ) ] = limn->inf [ 100 / ( n1/100 ) ] = 0. Moreover, _functions of the form **x a** always grow faster than **logarithmic functions_**. **Therefore, you can safely assume as limit turning out out be 0.**
stackexchange-math
{ "answer_score": 0, "question_score": 1, "tags": "calculus, limits" }
Jquery ID Attribute Contains With Selector and Variable I would like to search for an image ID that contains a value AND a variable. I need the below script to be something like $("[id*='MYVALUE'+x]") but that does not work. for (x=0; x< imageList.length; x++) { var imageSRC = imageList[x]; //need this to be MYVALUE + the X val //search for IDs that contain MYVALUE + X $("[id*='MYVALUE']").attr('src', 'images/'+imageSRC); }; <!-- These images are replaced with images from the array imageList--> <img id="dkj958-MYVALUE0" src="images/imageplaceholder" /> <img id="mypage-MYVALUE1" src="images/imageplaceholder" /> <img id="onanotherpage-MYVALUE2-suffix" src="images/imageplaceholder" />
Take a look at this: < $('[id*="MYVALUE' + x + '"]').attr('src', 'images/'+imageSRC);
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "jquery, selector, contains" }
react Material-ui, How do I know I can use onClick for button? The list of properties on the doc doesn't include `onClick` (< How do I know I need to use onClick for click handler?
The Material-UI documentation does not list the standard React (native browser) events: < This is because it's expected that you are already aware of the available native events. For example, you can also use `onWheel`. It would be a long and redundant list if all the native events were included. As kouak explains, other props (such as `onClick`) are passed down to a relevant child component. Random example: <Button color="primary" onClick={() => { console.log('onClick'); }}> Primary </Button>
stackexchange-stackoverflow
{ "answer_score": 107, "question_score": 104, "tags": "reactjs, material ui" }
What really happened to civilization in Alita: Battle Angel? In the movie we are told that > there was a war against the Martians that destroyed a lot of civilization on the surface of the planet and all but one of the floating cities. We are also told that > Alita is built with Martian technology. But Alita eventually remembers that > she originally used to fight against the floating cities and Nova, who lives in the remaining floating city and does evil experiments on humans. So I’m confused. What caused all the destruction? Or in other words > who actually fought who?
I'm not sure what the movie back story is, if one exists, but in the manga version the series _Battle Angel Alita: Last Order_ explains that Earth was devastated by a "Geo Catastrophe" in 2012. This was an asteroid impact near Japan that caused massive devastation and a decades long ice age that nearly wiped out humanity. < <
stackexchange-scifi
{ "answer_score": 5, "question_score": 6, "tags": "alita battle angel" }
Calculate sum of numbers on matrix diagonal I have a dynamic matrix and I need to to calculate sum of digits in this way: **0 1** 2 3 4 5 6 10 **11 12** 13 14 15 16 20 21 **22 23** 24 25 26 30 31 32 **33 34** 35 36 40 41 42 43 **44 45** 46 50 51 52 53 54 **55 56** 60 61 62 63 64 65 **66** I can't understand in which way I should compare `i` and `j`: long result = 0; for (int i = 0; i < len; i++) { for (int j = 0; j < len; j++) { // only works for diagonal if (i == j) // should use j - 1 or i - 1? { result += matrix[i][j]; } } }
**no need to scan full matrix** : long result = 0; for (int i = 0; i < len; i++) { result += matrix[i][i]; // diagonal if (i < len - 1) // stay within array bounds result += matrix[i][i+1]; // next to diagonal } * * * > modification without index check on every iteration: // assign corner value from bottom row to result long result = matrix[len-1][len-1]; // for each row (except last!) add diagonal and next to diagonal values for (int i = 0; i < len-1; i++) result += matrix[i][i] + matrix[i][i+1];
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 4, "tags": "c#, matrix" }
What to do if the user drags a symbolic link or Alias into iTunes File Sharing? My will use iTunes File Sharing so the user can drag files easily into the Documents directory of the app, using iTunes. I never tried this but what if the user drags an alias or symbolic link in there? What happens? I guess that iTunes is clever and actually pulls in the real file, not the symbolic link. But assuming it's not clever, how will I deal with this in my app? How can I detect this and tell the user that he dragged garbage to the documents dir?
Use `NSFileManager`' `attributesOfItemAtPath:error` to get details on the file path. `NSFileType` key should tell you whether its a symlink or not.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "iphone, ios, ipad, itunes, file sharing" }
Simultaneusly solving $2x \equiv 11 \pmod{15}$ and $3x \equiv 6 \pmod 8$ Find the smallest positive integer $x$ that solves the following simultaneously. Note: I haven't been taught the Chinese Remainder Theorem, and have had trouble trying to apply it. $$ \begin{cases} 2x \equiv 11 \pmod{15}\\\ 3x \equiv 6 \pmod{8} \end{cases} $$ I tried solving each congruence individually. The inverse for the first is 8: $x \equiv 8\cdot11 \equiv 88 \equiv 13 \pmod{15}$. The inverse for the second is 3: $x \equiv 3\cdot6 \equiv 18 \equiv 2 \pmod{8}$. But I can't figure out how where to go from here.
Let's proceed completely naively and see where it takes us. The first congruence is equivalent to $x \equiv 13 \pmod{15}$. This is the same as $x = 13 + 15n$ for any integer $n$. Let's use this in the second congruence. $$\begin{align} 3x &\equiv 6 \pmod 8 \\\ 3(13 + 15n) &\equiv 6 \pmod 8 \\\ 39 + 45n &\equiv 6 \pmod 8 \\\ 7 + 5n &\equiv 6 \pmod 8 \\\ 5n &\equiv 7 \pmod 8. \end{align}$$ This lets you determine a solution for $n$. In particular, you'll find that $n \equiv 3 \pmod 8$, or rather $n = 3 + 8l$ for any integer $l$. Going back, we see that $x = 13 + 15n = 13 + 15(3 + 8l) = 13 + 45 + 120l = 58 + 120l$, or rather that $x \equiv 58 \pmod{120}$. $\diamondsuit$
stackexchange-math
{ "answer_score": 6, "question_score": 6, "tags": "elementary number theory, modular arithmetic, chinese remainder theorem" }
Pattern matching Data.Sequence like lists I am using `Data.Sequence` instead lists for better performance. With lists we can do the following foo :: [Int] -> Int foo [] m = m foo (x:xs) m = ... How can this be accomplished with `Data.Sequence`. I have tried the following: foo:: S.Seq Int -> Int foo S.empty m = m foo (x S.<: xs) m = ... I think the solution involves using `S.viewl` and `S.viewr`, but cannot seem to figure out how.
`ViewPatterns` is probably the way to go here. Your code doesn't work because you need to call `viewl` or `viewr` on your `Seq` first to get something of type `ViewL` or `ViewR`. `ViewPatterns` can handle that pretty nicely: {-# LANGUAGE ViewPatterns #-} foo (S.viewl -> S.EmptyL) = ... -- empty on left foo (S.viewl -> (x S.:< xs)) = ... -- not empty on left Which is equivalent to something like: foo seq = case S.viewl seq of S.EmptyL -> ... (x S.:< xs) -> ...
stackexchange-stackoverflow
{ "answer_score": 14, "question_score": 12, "tags": "haskell, pattern matching, abstract data type, pattern synonyms" }
Regular Expression: L= {w | every even position of w is '1'} I am trying to solve a regular expression of binary string where every even position is a '1' I've solved this for an **odd position** : (1(0+1))*(1+ε) How would it look like for an even position then? Thanks in advance.
An odd position can either have 0 or 1 and every even position can only have 1. RE for this can be: $$ ((0 + 1)1)^* (\epsilon + (0+1))$$ Note that, it also contains the empty word.
stackexchange-cs
{ "answer_score": 2, "question_score": 0, "tags": "automata, regular expressions" }
Welcome emails being blocked by receivers email clients Our site is hosted by a company on a remote server. Our welcome emails used to be received fine, but as we've grown many customers are complaining about never seeing their emails. Some end up in junk/spam folders, which isn't ideal but is fine since it still gets through. But some email domains, such as comcast.net, aren't evening letting them hit the inbox. Is there anything I can do about this? Or do I need to contact our server host? Is there somewhere else I should ask about this?
You should start by contacting your hosting provider. It is possible that you IP address has been out on a blacklist and Comcast blocks them. It is also possible that your reverse DNS lookup is incorrect and Comcast is rejecting the emails for that reason. The fact that they once worked and now don't point to the conclusion that your IP address and been registered on a blacklist site. If you are on a shared host it is possible that another site on the same server caused the issue. In the end your hosting provider will have to help solve the issue.
stackexchange-magento
{ "answer_score": 2, "question_score": 0, "tags": "email, server" }
TypeSript: narrow down from a broader type How can I rewrite this code to avoid TypeScript error: const level: "debug" | "info" | "warn" | "error" | "custom" = "custom"; if (level in window.console) { // Error: Element implicitly has an 'any' type because expression of type '"custom"' can't be used to index type 'Console'. window.console[level].call( window.console, `Level is: ${level}` ); } else { window.console.log.call( window.console, `Level is: ${level}` ); } Thanks.
Use a type guard: // alias for convenience type ConsoleKey = keyof typeof console; function isConsoleKey(val: string): val is ConsoleKey { return val in console; } const level: string = "custom"; if (isConsoleKey(level)) { // you don't need call since `this` will automatically be set consolelevel; } else { console.log( `Level is: ${level}` ); }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "typescript" }
How to get data from server into Datagridview C# I want to get some Data displayed at a DataGridview. Here is what I tryed so far : cn.Open(); SqlDataAdapter sda = new SqlDataAdapter("select * FROM Arbeiter WHERE (Name Like '%" + tbSuche.Text + "%'", cn); DataTable dt = new DataTable(); sda.Fill(dt); dataGridView1.DataSource = dt; I get the error : > An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll it works without the WHERE part ... so I think the error should be there . Thanks for your help
You did not close your parenthesis in the sql query. Should be: SqlDataAdapter sda = new SqlDataAdapter("select * FROM Arbeiter WHERE (Name Like '%" + tbSuche.Text + "%')", cn); I always like to put mine on a new line like: string sql = "select * FROM Arbeiter WHERE (Name Like '%" + tbSuche.Text + "%'"; SqlDataAdapter sda = new SqlDataAdapter(sql, cn); That way I can always put in a breakpoint before execution and copy the SQL statement over to SQL Management Studio to run it there to check the results.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, sql, database, visual studio, datagridview" }
Cannot give myself root my permissions I am trying to give myself root access to all the file in this folder and not have to `sudo` everything I want to run a command. The file I am concerned with is `pro` When I enter `ls -l` I get : drwxr-xr-x+ 12 Guest _guest 384 13 Jan 14:56 Guest drwxrwxrwt 9 root wheel 288 13 Jan 14:30 Shared drwxr-xr-x+ 148 Santi staff 4736 1 Apr 17:13 pro then I enter `chmod 775 pro/` It doesnt seem to change the permssions. What can I do to fix this or why is the folder restricting permission even though I appear to be root?
`drwxr-xr-x+ ...` the final **+** means that the file is governed by acl see * `apropos acl` : give you the mans to consult * wikipedia * Access Control Lists on Arch wiki
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "bash, terminal" }