INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
"code ." command doesn't work to open Visual Studio Code operator from mac terminal **"code ." command doesn't work to open Visual Studio Code operator from mac terminal** I cannot open Visual Studio Code Editor from command line just by typing "code ." in terminal ![code](
Locate your bash profile with the command 'locate bash_profile'.That file is usually located in '/Users/user_name/.bash_profile'.Once you found the file, insert the following command. "code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}" After that, save the file and type the following command in the same directory. See the attached screenshot for more clarity. enter image description here $source .bash_profile
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 14, "tags": "visual studio" }
All possible combinations of elements of three vectors in Python I have three lists, each containing lets say 2 elements. How can I obtain a (8x3) array which contains all the possible combinations (with replacement) of the elements in the three lists? Example: vec1 = [4, 6] vec2 = [2, 4] vec3 = [1, 5] output = [[4, 2, 1], [4, 2, 5], [4, 4, 1], [4, 4, 5], [6, 2, 1], [6, 4, 5], [6, 2, 5], [6, 4, 1]] This is my code (simplified): import scipy.stats as st percentiles = [0.01, 0.99] draws1 = st.norm.ppf(percentiles, 0, 1) draws2 = st.norm.ppf(percentiles, 0, 1) draws3 = st.norm.ppf(percentiles, 0, 1)
You could use numpy.meshgrid() like so: np.array(np.meshgrid([4, 6], [2, 4], [1, 5])).T.reshape(-1,3) Which results in: array([[4, 2, 1], [4, 4, 1], [6, 2, 1], [6, 4, 1], [4, 2, 5], [4, 4, 5], [6, 2, 5], [6, 4, 5]])
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "python, combinations, permutation" }
How to mark some points on 2D heat map in gnuplot? I am using simple scheme for plot 2D heat map from my data like this: set pm3d map set pm3d interpolation 5,5 splot "file" Now i need to mark few points on this data, maybe with white color. I tried to do: splot "file"; plot "points" and it's not working and writes: "Can't use pm3d for 2d plots".
What does the file look like? You can do: splot 'file' with pm3d, 'points' with points linecolor rgb "white" depending on what `'points'` looks like though, you might need to add a using specification: splot 'file' with pm3d, 'points' using 1:2:(0.0) with points linecolor rgb "white"
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 3, "tags": "gnuplot, heatmap" }
Plesk website via local IP I run Plesk Panel on my local Windows web server which works just fine but I want to add a website that will only be used on my local network. I have added it in the usual way and it works fine via it's domain however I want to know if it's possible to execute it via a local IP instead of the domain name. The main reason for this is that I hope it will speed up access for local users by avoiding DNS etc. So currently it's: < but I want to use: < (or similar) Is this possible? I appreciate it probably isn't done from within Plesk. The site requires PHP if that makes any difference.
After a couple of days hunting its actually remarkably simple and can be done through Plesk. Tools & Settings > IP Addresses Select servers IP and assign the relevant domain to it from the drop down.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, iis, plesk" }
html helper dropdown list to display hardcoded values in my view, not values from database I want to be able to display a dropdownlist that has values not from my database, but have hardcoded values that will be used to perform an insert query later. How would I go about doing it? <%=Html.DropDownList("Chart Type", "Horizontal") %> I need values Horizontal, Vertical, Pie to be in the dropdownlist. Any help is much appreciated!
Try <%=Html.DropDownList("Chart Type", new List<SelectListItem> { new SelectListItem{ Text="Horizontal", Value = "Horizontal" }, new SelectListItem{ Text="Vertical", Value = "Vertical" }, new SelectListItem{ Text="Pie", Value = "Pie" } }) %>
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 2, "tags": "html, asp.net mvc, model view controller" }
Does a CommCare app copy from the latest saved state or the latest deploy? If I copy a CommCare application from one project space to another, will the copy of the app represent the latest _saved_ state of the original application or the latest _deployed_ state of the application?
It will be the latest saved state. If you want to copy the latest deployed state then you would need to 'revert' to that build before copying. To keep the latest saved state you could: 1. create a build (let's call it 'Build Latest') 2. revert to the build you want to copy 3. copy the app to the new project space 4. revert back to 'Build Latest' to restore your app to it's original state
stackexchange-webapps
{ "answer_score": 1, "question_score": 1, "tags": "commcare" }
What is a USB Type-C "Charge Cable" When looking to purchase a USB Type-C cable, I'm noticing a bunch of differences that I don't understand. Some USB Type-C cables purport to be a "Charge Cable." Some of those cables also claim to only support USB 2.0 speeds, while others claim USB 3.1 speeds. If I see a USB-C cable sold as a "Charge Cable," does that cable differ from another USB-C cable claiming to support the same speeds, but not claiming to be a charge cable? I know the standard is fairly new, and barely supported, so that might help explain my question.
First off power output (useful for charging) and transfer speeds (useful for moving files) are two different numbers. Transfer speeds are determined by the USB version (i.e. USB2.0, USB3.0, USB3.1) and power output is determined by the power source but limited by the cable. A USB-C charging cable may have slower transfer speeds, as its purpose is to be used for charging and not for transferring data (such as a USB2.0 USB-C). USB-C cables have a power output up to 100W, though again how much power is actually going through the cable will be dependent on the source. On the other hand, you may have a USB3.1 USB-C cable, which can transfer up to 10Gbps. **tl;dr** All USB-C cables should be capable of both charging and transfer but the transfer speeds will depend on the version of USB and the charging speed will depend on what it's plugged into (e.g wall outlet vs a laptop). Please someone correct me if I'm wrong on anything, I'm learning a lot here doing research!
stackexchange-superuser
{ "answer_score": 1, "question_score": 3, "tags": "usb, usb 3" }
sitecore page editor change position actually deleting sublayout added on an item(Page) I have a layout with two place holders leftColumn and rightColumn. For an item i am adding multiple sublayouts for leftcolumn and multiple sublayouts for rightcolumn. Now in page editor when i am trying to change position using "Change Position" button in toolbar and move content to another location, content is getting moved to my new location as desired. But when i click Save button on Ribbon, it is actually deleting moved content from presentation itself. I am not sure why it is behaving like this. we are using Sitecore 6.4
We opened a ticket with Sitecore and found out that this is an existing bug. They do not support movement of multiple controls/sublayouts within same placeholder on layout using PageEditor. We need to use multiple placeholder on layout and then we can change position of controls from one placeholder to another one.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "sitecore, page editor" }
Android Studio 4.0 not showing build error details After upgrading Android Studio version to 4.0 there's no "toggle view" button in the Build Output window that switched to full output. So now there's no way now to see the error details. Is there a way aside from building the app in the terminal to see full error details? ![Build output](
_Android Studio > Preferences > Compiler > Command-line Options:_ \--stacktrace --debug
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "android, android studio, android studio 4.0" }
Split parent pane instead of the active one Let's say I've obtained this configuration by using `splitw -h` once, with `A` currently active: +---+---+ | A | B | | | | | | | +---+---+ How can I add a new split _below_ those 2 splits? +---+---+ | A | B | +---+---+ | C | +---+---+ I'm not sure how to search for this... Everything I've found is about splitting _inside_ a pane with `splitw`, which is not what I want: +---+---+ | A | B | +---+ | | C | | +---+---+ _For those familiar withi3, this would be the equivalent of sending `focus parent; split v` before opening the new window._ Is `tmux` able to do this? I'd rather stop searching now if that's not the case :)
Use the `split-window -f` command.
stackexchange-unix
{ "answer_score": 2, "question_score": 2, "tags": "tmux" }
Multiplying unsymmetrical data frames in R I have these two different size dataframes I want to multiply. a<- data.frame(Var1=c("a","a","b","b","d","d"), Var2=c(1,1,2,2,3,3),Var3=c(3,4,5,6,7,4)) b<- data.frame(Var1=c("a","b"), Var2=c(123,234),Var3=c(9,8)) I want to do something like this apply(a, 1, FUN = function(x) { x[2:3]*b[b$Var1==x[1],2:3] } ) But I get the following error: Error in FUN(left, right) : non-numeric argument to binary operator What is the best way to get a dataframe whith multiplied columns (Var2 and Var3) between the two dataframes?
`match` the `Var1` keys, and then multiply the corresponding parts: sel <- match(a$Var1, b$Var1) a[!is.na(sel), 2:3] <- a[!is.na(sel), 2:3] * b[na.omit(sel), 2:3] # Var1 Var2 Var3 #1 a 123 27 #2 a 123 36 #3 b 468 40 #4 b 468 48 #5 d 3 7 #6 d 3 4
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "r" }
Is it possible to include and exclude via tags on the same karate command line We can select multiple scenario's by including the following on the command line: -Dcucumber.options="--tags @S1,@S2,@S6" And if I want to exclude @S6 I can with: -Dcucumber.options="--tags ~@S6" But if I want to include @S1, @S2 and exclude @S6 all tags are ignored with: -Dcucumber.options="--tags @S1,@S2,~@S6" and all tags are also ignored if I try to double up on the options with: -Dcucumber.options="--tags @S1,@S2" -Dcucumber.options="--tags ~@S6" Is there a command line way to include and exclude in the one command line? The reason I would like to do this is to run all of a type of test but exclude tests that use some external system that may be down temporarily.
EDIT: Turns out I was not fully aware of the difference between AND and OR in the Cucumber world. This SO answer and this article was a good reference, look for "Logical OR" and "Logical AND": so to run S1 `OR` S2 `AND NOT` S3 mvn test -Dkarate.options="--tags @S1,@S2 --tags ~@S3" Using the Java (or `Runner`) API, just use commas for OR and separate strings for AND: Results results = Runner.path("classpath:com/myco/some.feature") .tags("@S1,@S2", "~@S3") .parallel(5); For _really_ advanced cases, also see: <
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "karate" }
LWC: get value of checkbox on change I am trying to get the value of a checkbox on change handler. What I tried so far: <template for:each={objInfo.todoList} for:item='todoListItem' class="slds-p-top_medium"> <lightning-input key={todoListItem.fieldName} name={todoListItem.fieldName} label={todoListItem.fieldLabel} type={todoListItem.fieldType} value={todoListItem.value} disabled={todoListItem.disabledRes} checked={todoListItem.value} onchange={handleTodoChange} > </lightning-input> </template> and handleTodoChange(event) { this.value = event.target.value; console.log("Todo: " + event.target.value); } But no success. What am i doing wrong here?
you need to reference `checked` for the `lightning-input` checkbox > For input types checkbox and checkbox-button, the value of checked attribute. handleTodoChange(event) { this.value = event.target.checked; console.log("Todo: " + event.target.checked); }
stackexchange-salesforce
{ "answer_score": 10, "question_score": 5, "tags": "lightning, lightning web components" }
How to fix USB gamepad problem with Sega Mega Drive (Genesis) Classics 1 Lately I bought Sega Mega Drive Classics 1 on Get Games, featuring Golden Axe, Shadow Dancer, Crack Down and several others (also available on Steam). The games work perfectly with my ancient, game-port based gamepad, though since it is a little worn out, I decided to try a much more recent Hama USB based gamepad instead. It works pretty good in Control Panel->Game Controllers options (calibrated, all buttons and analogs working properly), but when I launch the Sega Mega Drive Collection 1 emulator, the controls go crazy, as if the pad was completely uncalibrated. The same happens when I somewhat succeed to run any of the games. Is the Sega Mega Drive Collection packages known to have issues when used with USB gamepads? Is there a way to fix the problem?
Not an actual answer, but a workaround. You can try using Xpadder to map your joystick to keyboard keys. Of course, that will only work if you can disable the in-game joystick support. Since I don't own Sega Mega Drive Classics, I don't know if that's possible, and probably I can't help you further than that.
stackexchange-gaming
{ "answer_score": 3, "question_score": 4, "tags": "technical issues, controllers, sega genesis classics" }
Why does it skip array index 0? I came across this computer science problem and it wasn't working out the way I was writing it down. This is the code: int[][]grid = {{1,2,3,4},{5,6,7},{8,9},{10}}; for(int i = 0; i < grid.length; i++) for(int j = 0; j < grid[i].length; j++) grid[j][i] = grid[i][j]; System.out.println(Arrays.toString(grid[1])); It should change grid[0] to {1, 5, 8, 10} but instead it does nothing to it. Why does it skip over that one? Shouldn't `i` start out as 0 so the second for loop should start with `grid[0][0] = grid[0][0]` then `grid[1][0] = grid[0][1]`?
It's because you're changing the initial variable (grid) on each iteration, put the output into a separate variable and then print that. Explanation: grid = {{1,2,3,4},{5,6,7},{8,9},{10}}; After the first sub loop (looping j) grid = {{1,2,3,4},{2,6,7},{3,9},{4}}; Then when it performs the subsequent i loops, you can see it puts the numbers back where they were. If you start with an empty array as your output variable, you will avoid this problem.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "java, arrays, for loop" }
Can a bounded function always attain its least upper bound on a bounded rectangle in $R^n$? Suppose we have a rectangle $Q$, and $Q\subset R^n$. Then $Q$ is bounded by the definition of higher dimensional rectangles. Suppose $f$ is a bounded function defined on $Q$. Since $f$ is bounded, we can produce its infimum $\inf_Q f$ and supremum $\sup_Q f$. My question is that is it always true that $\exists x_1,x_2\in Q$ with the property that $f(x_1)=\inf_Q f$ and $f(x_2)=\sup_Q f$? If this does not always hold, please provide an example.
If $Q$ is also closed, then it is compact (Heine-Borel theorem), and thus any **continuous** function realizes its extrema on it. If $Q$ is an open rectangle, then for example any coordinate function gives you a counterexample. If we do not ask $f$ to be continuous, take a countable number of points $\\{x_n\\}_{n\in\mathbb{Z}}\subset Q$, and consider the function $$f(x) = \cases{1&if $x\notin\\{x_n\\}_{n\in\mathbb{Z}}$ or $x = x_0,$\\\\\frac{1}n & if $x = x_n$ and $n>0$,\\\2+\frac{1}{n} & if $x=x_n$ and $n<0$.}$$ It provides a counterexample.
stackexchange-math
{ "answer_score": 0, "question_score": 1, "tags": "real analysis, supremum and infimum" }
Question: Counting Number of Ways to Color ![enter image description here]( Each of the nine dots in this figure is to be colored red, white or blue. No two dots connected by a segment (with no other dots between) may be the same color. How many ways are there to color the dots of this figure? What I have done so far: I know there are $3\cdot 2\cdot 1=6$ ways to color the leftmost triangle. How do I proceed?
Assume the middle triangle is coloured R, B, W, starting from the top vertex and moving clockwise. Then the top vertex of the rightmost triangle cannot be R, and the bottom-left vertex cannot be B. You can list all possible valid arrangements of the rightmost triangle, of which there are $3$ in total. Draw them for yourself! The top vertex must be of the other two colours, B or W in our case. There are $2$ arrangements when B is the top vertex, and $1$ arrangement when W is the top vertex, as in the other colouring, the bottom two vertices have the same colour. This is true for the leftmost triangle as well by symmetry. Therefore, the number of possible arrangements is $6 \times 3 \times 3 = 54$.
stackexchange-math
{ "answer_score": 5, "question_score": 2, "tags": "combinatorics, graph theory, coloring" }
pass kinit a custom krb5.conf file I'm using kinit to log into a server that my sys admin didn't anticipate us using. It seems that the default location for the config file is `/etc/krb5.conf`, but I don't have root access so I can't edit this file to add a new server. How can I pass kinit a custom config file?
OK, solved the problem: the default config file location can be overridden by setting the `KRB5_CONFIG` environment variable
stackexchange-stackoverflow
{ "answer_score": 28, "question_score": 25, "tags": "kerberos" }
Initialize variable depending on another variables type In Python 2.7 I want to intialize a variables type depending on another variable. For example I want to do something like: var_1 = type(var_2) Is there a simple/fast way to do that?
Just create another instance var_1 = type(var_2)() Note that if you're not sure whether the object has a non-default constructor, you cannot rely on the above, but you can use `copy` or `deepcopy` (you get a "non-empty" object. import copy var_1 = copy.copy(var_2) # or copy.deepcopy You could use both combined with the latter as a fallback mechanism Note: `deepcopy` will ensure that your second object is completely independent from the first (If there are lists of lists, for instance)
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "python, python 2.7" }
Usage Data via Valence API Is there a way to pull user usage data from the Valence API? In particular I want to know if a user has ever logged in or accessed a certain course.
No, sorry, currently that information is not available through the Valence APIs. If you'd like the Valence APIs to provide that information, and you're affiliated with a D2L customer, please use their account management chain to report your request. If you're not directly affiliated with a D2L account manager, then you can report your request through the Valence support chain. This particular request is something that other partners and customers have indicated an interest for.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "desire2learn" }
Is it possible to call a function after Page_Load event? I have this page say test.aspx.Its codebehind is like the code below. protected void Page_Load(object sender, EventArgs e) { } public void display() { // some block statements } Since the function `display()` is outside the `Page_Load` it is never called. So how do I make this call to this function after `Page_Load`. NOTE: I need this function outside the `Page_Load`.
Use Page.LoadComplete.aspx): protected void Page_LoadComplete(object sender, EventArgs e) { display(); }
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 2, "tags": "c#, asp.net" }
public iCloud Data for my new app, I need to save data generated by the user (e.g. gps positions). First I thought I save these data within the icloud storage. Problem is, I would like to add the possibility to share a few data with friends. Therefore these data needs to be public. Is this possible within icloud? Thanks
You can use CloudKit for that: > With CloudKit, you can focus on your client-side app development and let iCloud eliminate the need to write server-side application logic. CloudKit provides you with Authentication, private and public database, structured and asset storage services
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ios, xcode, icloud" }
What are the best steps to install ZeroMQ in Windows 10 64 bit? I am trying to install ZeroMQ in my windows. I have xampp and **`php`** version 7.0, so what are the best steps to install this library?
Try this You can directly download and install .exe file
stackexchange-stackoverflow
{ "answer_score": -1, "question_score": 0, "tags": "php, zeromq" }
How bad is a tempdb drive failure (with multiple tempdb files on different drives)? I'm getting a new 16 core server for my SQL Server 2005 database. I would like to create 16 files for my temp DB, and put each one on a separate drive. If one of these drives fails, can SQL Server continue to function using the other 15 files?
No. Your database becomes corrupt and SQL Server stops. Last I checked, it was one file per socket not per core nowadays. Note, unless you've RAIDed each volume (or have separate SAN LUNs attached) having multiple files on the same drive is mostly pointless: you'll cannabalise IO on that drive trying to spread the load.
stackexchange-dba
{ "answer_score": 4, "question_score": 4, "tags": "sql server" }
MVC - how to retrieve multiple records in a controller I have the following action: public ActionResult Details(string id) { MyRecordContext rc = new MyRecordContext(); MyRecord r = rc.MyRecords.Single(x => x.RecordID == _id); return View(r); } But turns out there are multiple records with the same id (table's primary key is a composite key). So I need to retrieve a List of type MyRecord, so I changed the code to: public ActionResult Details(string id) { MyRecordContext rc = new MyRecordContext(); List<MyRecord> rl = rc.MyRecords.Any(x => x.RecordID == id); return View(rl); } But the above is clearly incorrect since method Any returns bool. Can someone help me correct my code?
public ActionResult Details(String id) { MyRecordContext rc = new MyRecordContext(); List<MyRecord> rl = rc.MyRecords.Where(x => x.RecordID == id).ToList(); return View(rl); } That will return all matches with `RecordID == id`, then pass this list off to your view. Just make sure you update the `Details` view as well to accept `List<MyRecord>` instead of `MyRecord` (now that you're passing a collection).
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "sql server, asp.net mvc" }
Rusted gas tanks, how do you repair them? If I have an extremely old vehicle that has limited parts availability for replacement, **_how would I fix a rusted gas tank in order to put it back in service in a vehicle?_** I've run into this issue a couple of times in my life and would like to hear procedures and effective methods to remediate this problem. I have fixed many motorcycle gas tanks that are rusted, but never on a car. **Is a coating recommended for the inside of the tank?** **How would I get all of the rust out of it?** I've used electrolysis with sodium carbonate to remove rust from smaller parts in a 65 gallon plastic container but the size of car gas tanks obviously makes this prohibitive. Here's the basic procedure I've used in the past for just parts.
Do you have a picture of the tank? If you have any holes, obviously you would grind, cut, weld. White vinegar does wonders. Fill it up to the brim, add some change. Let it sit for days, preferably a week. As you drain the tank, shake it rigorously, the flakes will come off. If you need to do this again, you most certainly can. Vinegar is a cost effective way to do this. Here are some results of what vinegar can do for you and all your rust removing needs! ![enter image description here]( ![enter image description here]( When you are done make sure to seal your tank. Caswell makes a great product. They also have an epoxy sealer that you can look at. ![enter image description here](
stackexchange-mechanics
{ "answer_score": 6, "question_score": 10, "tags": "repair, tools, rust" }
Do I have to retain/release values taken from NSDictionary? Normally I do something like this (below) to get value I need: NSDictionary *state = [notification.userInfo objectForKey:@"state"]; [self.tabBarItem setBadgeValue:[state objectForKey:@"short"]]; But does it worth to do retain/release for values taken from NSDictionary? Something like this: NSDictionary *state = [[notification.userInfo objectForKey:@"state"] retain]; [self.tabBarItem setBadgeValue:[state objectForKey:@"short"]]; [state release]; Is it more memory friendly? Or I shouldn't bother and just trust to autorelease pool to do its job?
No, there's no point in doing that. The result of `[notification.userInfo objectForKey:@"state"]` is always an autoreleased object; if you add an extra `retain` and `release`, that won't change anything.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "objective c, ios, memory management, nsdictionary" }
Does PayPal support the Dirham? I am setting up my PayPal, but the currency I need is not on the pull down list. I live in Dubai and the currency is United Arab Emirates, Dirham (AED). Is there a add-on I need or an "other" option available? anyone know the way how to add AED to Paypal.
As per their site they do not support your currency. Probably, you need to do your transactions in USD Official quote: > Send and receive payments in these countries. Withdraw from your PayPal account to a U.S. bank account. In addition, withdraw to a credit or debit card in countries marked with a (+). Note: UAE is marked as +
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "php, paypal, currency, paypal sandbox" }
Hello Every one, How can i provide security by using spring in the application by folder wise ![enter image description here]( Above image is the springsecurity.xml file. ![enter image description here]( Above image is the folder wise I written.
I hope what you are trying to achieve is restricting access based on user role. You can intercept each incoming request and check if the user who is trying to access the url has required role to perform this operation. Please read this link and develop your logic.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -4, "tags": "spring" }
Detect a 'scrollIntoView' call of an element with jquery I have an element on which I trigger the function 'scrollIntoView()'. And now I have to detect and catch this event when it is triggered. I trigger it like this: $('.element').scrollIntoView(); So I tried to catch it with jquery with something like this: $('.element').on('scroll', function() { // STUFF }); $('.element').on('scrollIntoView', function() { // STUFF }); But unfortunately it's not working. Is this even possible? Which event does it trigger?
$.fn.inView = function(){ var win = $(window); var obj = $(this); var scrollPosition = win.scrollTop(); var visibleArea = win.scrollTop() + win.height() ; var objEndPos = (obj.offset().top + obj.outerHeight()); return(visibleArea >= objEndPos && scrollPosition <= objEndPos ? true : false) }; this will work. But inside of a scroll you can do if(element.inView()) { do this }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, jquery" }
How to create a Cardano private network I need help with a project proposal, but I think this topic could be interesting for many developers and architects. Does somebody know how to start to build a private Cardano network or where I can find some tutorials? The idea would be to build a sidechain as layer two, which utilizes the token of the mainnet as the native coin. Does the idea have sense? Is it possible? Any suggestion? Many thanks, Valerio
Alternatively/additionally, check out the Making a Shelley Blockchain from Scratch repo.
stackexchange-cardano
{ "answer_score": 1, "question_score": 1, "tags": "native assets, token, sidechains" }
How to import XAML pages together with code-behind in Visual Studio 2012? I am trying to port my Windows 8 Store application from Developer Preview to RTM now and I got problems with importing old XAML layout into the newly created project (the old project isn't runnable anymore). Whenever I import .xaml and .xaml.cs files, they are not recognized as a single file. Rather, two different files are added. How can I import both files as a single "entity", as it happens if I add a new XAML page to my project?
When including XAML files you should have both XAML and xaml.cs files in the same folder, and then in Visual Studio select for including only the XAML files, not the xaml.cs files - they should be included automatically in the process.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 5, "tags": "xaml, visual studio 2012" }
I can't update sdk manager ' packages I installed Xamarin on Visual studio 2013. I Unfortunately get the error: " The installed Android SDK is too old. Version 25.1.3 or newer is required. Please update to the latest version." I updated to latest version but still it isn't the version that is needed for Xamarin!!! The SDK tools is v25.2.4, the Platform-tools is v25.0.2, the build-tools is v25.0.2. I open sdk manager to update these packages but the link doesn't work!! Is there any other way to resolve this sticky error??
Google has filtered some countries to access these important installations and updates. Using a VPN is the solution. Good luck.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "android, xamarin, visual studio 2013" }
Seperate by loose parts I have just tried to do the "separate by loose parts" option and I think there might be too many objects to separate so blender just crashes. Is there anyway I can do this without it crashing? Thanks, Dan !enter image description here These are the blocks here ^ ^ ^ ^
If you are having troubles with doing this in one operation you may have better luck by breaking it into smaller pieces. 1. In edit mode goto side view and Box select one or two levels. Press `B` to start box select mode. 2. Press `Ctrl``L` to select vertices linked to what is selected, this ensures you keep each piece together. 3. Press `P` and choose Selection to separate the selected portion into a new object. 4. Repeat until you have separated the whole tower into smaller parts. 5. Select one of these smaller objects and go into edit mode. 6. Press `P` and choose by Loose Parts 7. Repeat for each part created above.
stackexchange-blender
{ "answer_score": 8, "question_score": 3, "tags": "mesh" }
Ruby / RSpec - Expect not to include any of I have the following spec: describe 'active' do it 'does not include inactive or deleted records' do inactive_record= create(:record, :inactive) deleted_record= create(:record, :deleted) expect(described_class.active).not_to include inactive_record expect(described_class.active).not_to include deleted_record end end This is OK when there are two tests, but when I have 10 different statuses I need to check, I'd need to write out ten different expect lines. I can do something like this: [records_not_to_be_included].each { |record| expect(described_class.active).not_to include record } But would like to be able to do something like: expect(described_class.active).not_to include_any_of [records_not_to_be_included] Is this possible with RSpec?
As you can see, from the docs: # Passes if actual includes expected. This works for # collections and Strings. You can also pass in multiple args # and it will only pass if all args are found in collection. # # @example # expect([1,2,3]).to include(3) # expect([1,2,3]).to include(2,3) # expect([1,2,3]).not_to include(4) # expect("spread").to include("read") # expect("spread").not_to include("red") # expect(:a => 1, :b => 2).to include(:b => 2, :a => 1) # expect(:a => 1, :b => 2).not_to include(:a => 2) # ... def include(*expected) BuiltIn::Include.new(*expected) end `include` accepts one or more elements, so you can try with: expect(described_class.active).not_to include(inactive_record, deleted_record)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "ruby, rspec" }
Добавить строку в QTableWidget если ее еще нет Моя программа должна постепенно выводить результаты вычислений в ячейки таблицы. Есть окно (реализовано как объект класса Widget, наследованного от QWidget), у этого объекта есть свойство r_table (указатель на QTableWidget) - эта самая таблица. Сколько строк понадобится, заранее неизвестно, поэтому я хочу чтобы они добавлялись по мере необходимости. Нужен метод void Widget::setTableValue(int i, int j, double value) который ставит число _value_ в ячейку с номером строки _i_ и номером столбца _j_ , а если строки _i_ нет, то создает ее. Как такое реализовать? Попытался сделать вот так void Widget::setTableValue(int i, int j, double value) { while (r_table->rowCount() < i) r_table->insertRow(r_table->rowCount()); r_table->setItem(i, j, new QTableWidgetItem(QString::number(value, 'g', 2))); } но он заполняет таблицу как попало.
Вот так void Widget::setTableValue(int i, int j, double value) { if (r_table->rowCount() <= i) r_table->setRowCount(i + 1); r_table->setItem(i, j, new QTableWidgetItem(localeRus->toString(value, 'g', 4))); } localeRus - объект QLocale с русской локалью, чтобы десятичный разделитель был запятая.
stackexchange-ru_stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c++, qt" }
In a cylindrical bucket full of water where does the liquid apply maximum force on its WALL? The height of the container is $h$. Please ignore the atmospheric pressure.
Use Integration Take an element at a depth y of thickness dy Let 'a' be the area of the base. Then, Torque can be written as r cross df where df=pgyady And integrate it from 0 to h You will find that maximum force would be found on the wall at a depth 2h/3.
stackexchange-physics
{ "answer_score": 0, "question_score": 0, "tags": "pressure, free body diagram, fluid statics" }
How to detect input string characters language with build in .NET functionalities? I want to detect if my input string has `Arabic` characters in it. Maybe some code like this : string str = "سS"; str[0].IsArabicCharacter(); //true str[1].IsArabicCharacter(); //false Currently using mapping but I want to migrate to some C# built in feature. ArabicChars = "ساینبتسیکبدثصکبثحصخبدوزطئظضچج"; string str = "ل"; if(ArabicChars.Contains(str[0]) return true; else return false;
The best you're going to get is going to be the various RegEx unicode block character class: `\p{name}` Regex.IsMatch(str[0], @"\p{IsThai}"); Regex.IsMatch(str[1], @"\p{IsArabic}"); MSDN Reference Pages: * Unicode Category or Unicode Block * List of supported named Unicode Blocks
stackexchange-stackoverflow
{ "answer_score": 14, "question_score": 7, "tags": "c#, .net, vb.net" }
Optimización Consulta Base de Datos Resulta que quería hacer un programa que guarde las temperaturas de la base de datos en un PDF. Cada día se creará un nuevo PDF con las temperaturas de todas las cámaras, pero los datos de la base de datos van a seguir creciendo diariamente. Para poder guardar estos datos primero tengos que consultarlos, por ejemplo: Select temperatura, fecha from tempCam1 where Fecha BETWEEN FechaMinima y FechaActual Mi pregunta es como optimizo la consulta, en plan, hago 10 tablas y cada una con temperaturas o hago una tabla con todas las temperaturas, y le hago a esta una consulta. Una tabla será más lenta por tener más campos... Porque en teoría todas las tablas de temperaturas, deberían de tener el mismo número de registros.
No es el camino correcto, el pensamiento de optimizar una consulta cuando no dispones de las tablas. Lo que tienes que hacer es Normalizar la base de datos. Cuando la tengas al menos en 3ª forma normal, ya puedes pensar en como aplicar las consultas, e indices necesarios para optimizarla. Si la tienes bien diseñada, aunque no tengas las consultas bien realizadas te va a funcionar muy bien, y luego siempre podrás dedicarle tiempo a ir haciendo las cosas bien. Pero si la diseñas mal, luego da igual lo que hagas, tendrás muchos problemas. Normalización Normalizar
stackexchange-es_stackoverflow
{ "answer_score": 8, "question_score": 2, "tags": "mysql, sql, sql server, base de datos, oracle" }
Convex Set Examples. Is a closed interval $[a,b]$, or $[0,1]$ in particular, a convex set ? I mean, let $\lambda\in [0,1]$. Then, \begin{align} a\lambda+(1-\lambda)b&=a\lambda+b -b\lambda &=(a-b)\lambda+b \end{align} Where does it lie?
if $a \le x \le b$ and $a \le y \le b$, since $\lambda$ and $1-\lambda$ are nonnegative, $\lambda a \le \lambda x \le \lambda b$ and $(1-\lambda )a \le (1-\lambda)y \le (1-\lambda)b$, Summing the equations, we have $$a \le \lambda x + (1-\lambda )y \le b$$
stackexchange-math
{ "answer_score": 3, "question_score": 0, "tags": "convex analysis" }
Encoding issues on Java 7 file names in OS X I have the following code: public static void main( String[] args ) { System.out.println(Locale.getDefault()); File f = new File("/Users/johngoering/Documents"); File[] fs = f.listFiles(); for (File ff : fs) { System.out.println(ff.getName()); System.out.println(ff.exists()); } } In my Documents folder I have a file called "öß.pdf". Here is the output under Java 6: en_US (...) öß.pdf true (...) But here is the output under Java 7: en_US (...) o.pdf false (...) Note especially that `file.exists` returns `false` for a file returned by `listFiles`!! What gives? Is there any way to fix this? This seems like quite the Java 7 bug...
With some help from Oracle, we discovered a workaround: the environment variable `LC_CTYPE` was not set to `UTF-8` within Eclipse (and when starting from a JNLP or wherever else). This explains why the code worked on the terminal, since the OS X terminal by default "sets the locale environment variables" (an option which can be turned off and then you get the same issue as above even in the terminal). Setting this environment variable in the launcher worked around the problem. I still consider this a bug for Java 7 because Java 6 still worked even WITHOUT this variable.
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 6, "tags": "java, macos, file, encoding, java 7" }
Java:Selenium Grid: How to Run specific tests on particular node I am new to selenium. I wrote 4 tests, now i want to run 2 tests on one node and two to other, how to do that. both the node have same configurations i mean same browser same platform and same versions i am using selenium-server-standalone-2.44.0.jar to create hub and node.
Grid generally manages distribution of test case execution on it's own. If both nodes are of the same configuration, Grid will send a test to each node, then as these first tests complete, another test will be sent, repeated until the suite is complete. Depending on the length of your tests, this could in fact result in two tests on each node being executed. If tests vary in length, you could possibly end up with a 3/1 scenario. Even if that's the case though, it wouldn't create any technical difference so long as the nodes are the same (as you stated, they are). Unless you have a specific purpose in mind for why which tests get executed on which node, Grid pretty much handles all the work of dividing the work among the resources it has at its disposal. I know this info is somewhat generic, but if you have a specific requirement, please update your question and we'll all be able to help you better.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "java, eclipse, testng, selenium grid2" }
x1, y1 and radius are given - can anything be assumed about x2, y2? I have a list of lat/lng coordinates. Given the coordinates x1, y1, and a radius r -- is there anything I can assume about the coordinates that fall within the radius of x1, y1? For example, can I compute a min and max value for x2 and y2? Basically, I want to get from the list of lat/lng coordinates all those that are within the radius of x1, y1. Normally, I would use the haversine formula to compute the distance between the two points and see if it falls within the radius. However, I do not have that option at this point due to the programming environment I am currently in (this is for a website that returns a list of companies within an area).
$x_2$ and $y_2$ need to satisfy the following inequality: $\sqrt {(x_1-x_2)^2 + (y_1-y_2)^2} \leq r$
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "coordinate systems, spherical coordinates" }
How to split first 4 rows and sum the remaining records and show as last record I have a table like below col1 col2 col3 i1 23 36 i2 48 21 i3 28 4 i4 349 12 … … i200 287 32 Now, how to get the result as below col1 col2 col3 i1 23 36 i2 48 21 i3 28 4 i4 349 12 >i4 (sum of (sum of remaining) col2 remaining) Please help me. Thanks
This might help select col1,col2,col3 from dbo.t3 where col1<='i4' union select '>i4',SUM(col2),SUM(col3) from dbo.t3 where col1>'i4'
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "sql, sql server, sql server 2008" }
What are the nuances between these three terms for intelligence: 知恵 [ちえ], 知能 [ちのう], 知性 [ちせい] ? In particular which one is closer to the idea of "ability to reason over things" as a quality of someone in particular? What I believe is that on the other hand is closer to "knowledge" and "understanding" and is more about "discrimination, insight", but as an intellectual operation, not a property attached to someone, like .
I'd add to @istrasci's answer that: * is more oriented towards mechanical problem solving skills, while * is more about reasoning and discerning abilities only thought to be possessed by humans. Words like (artificial intelligence), (IQ) show this aspect of . Also, because of these differences, you will hear more about "" (animal intelligence) than "" (animal intellect). So, "ability to reason over things" as a quality of someone, will likely be about .
stackexchange-japanese
{ "answer_score": 12, "question_score": 17, "tags": "word choice, compounds" }
How to change css styles on alloy-ui form validator? How i can change css styles of input fields and labels when alloy ui form validator detect a empty field? This is one of the fields <label for='<portlet:namespace />formnumdoc'> <liferay-ui:message key="formulario.DOCUMENT"/><span class="red_mini">*</span> </label> <input type='text' id='<portlet:namespace />formnumdoc' name='formnumdoc' /> And this is Alloy Ui script YUI().use('aui-form-validator', function(Y) { new Y.FormValidator({ boundingBox : '#frmEntity', rules : { formnumdoc : { required : true } }, fieldStrings: { formnumdoc: { required: '<liferay-ui:message key="formulario.REQUIRED_FIELD_ALERT"/>' } } }); });
You can change the CSS that AlloyUI `FormValidator` applies with the `errorClass` and `validClass` attributes: new Y.FormValidator({ /* your code here... */ errorClass: 'your-new-error-class', validClass: 'your-new-valid-class' }); You may also want to check out `containerErrorClass` and `containerValidClass`.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "css, liferay, alloy ui" }
Error "return type int is not compatible with Intent" when using FirebaseMessagingService class I need FCM service in my application, I can't use FirebaseMessagingService class, it says : Error:(24, 8) error: zzaa(Intent) in FirebaseMessagingService cannot override zzaa(Intent) in zzb return type int is not compatible with Intent here is my code public class MyFirebaseMessagingService extends FirebaseMessagingService { @Override public void onMessageReceived(RemoteMessage remoteMessage) { sendNotification(remoteMessage.getData().get("message")); } private void sendNotification(String messageBody) { // } } I'm using this version of library **`compile 'com.google.firebase:firebase-messaging:9.2.0'`** ![enter image description here](
I solved my problem, I was using the latest version of google map and auth services compile 'com.google.android.gms:play-services-auth:9.4.0' compile 'com.google.android.gms:play-services-maps:9.4.0' when I downgrade version to **9.2.0** problem were solved
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 5, "tags": "android, firebase cloud messaging" }
How to get the Stoock ROM from Huawei P30 lite New Edition (MAR-LX1B)? I am trying to root my new Huawei P30 lite New Edition(MAR-LX1B). I found out that there is no official version of TWRP for Huawei P30 lite New Edition(MAR-LX1B). After a long research I found out that there is a way to root without TWRP. But, you would need the stock ROM of Huawei P30 lite New Edition(MAR-LX1B). I have long searched how to get the stock ROM, but could not find anything. So I wanted to ask if anyone knows how to get the stock ROM of Huawei P30 lite New Edition (MAR-LX1B)?
This site seems to have a link to the stock ROM. As with everything related to flashing and getting root access, do proper research as if things go wrong you might brick your phone. Also, note that I don't own your model, so can't ascertain if the file is legit or not.
stackexchange-android
{ "answer_score": 0, "question_score": 0, "tags": "root access, adb" }
Shortcut for splitting only once in C#? Okay, lets say I have a string: string text = "one|two|three"; If I do `string[] texts = text.Split('|');` I will end up with a string array of three objects. However, this isn't what I want. What I actually want is to split the string only once... so the two arrays I could would be this: one two|three Additionally, is there a way to do a single split with the last occurrence in a string? So I get: one|two three As well, is there a way to split by a string, instead of a character? So I could do `Split("||")`
For your first scenario, you can pass a parameter of how many strings to split into. var text = "one|two|three"; var result = text.Split(new char[] { '|' }, 2); Your second scenario requires a little more magic. var text = "one|two|three"; var list = text.Split('|'); var result = new string[] { string.Join("|", list, 0, list.Length - 1), list[list.Length - 1] }; Code has not been verified to check results before using.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "c#, string, split" }
How to custom format a negative percent as (x.xx%) I'm using the following code: #.#0%;Red However, for negative decimal numbers i'm getting: (.32%) When I try to modify the code to: #.#0%;Red This works in the above example and outputs: (0.32%) But for something like -1.55% it outputs: (01.55%) Any solution to get the leading zero in?
You want the `0` just before the `.`: 0.#0%;Red ![enter image description here](
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "excel" }
How to simplify this sequence So I had this question (f) at my last exam that I failed and I'm now studying for my re-exam, the problem is that I still don't know what the answer is supposed to be in this question (f): ![Question]( ![My attempt]( Do you have any suggestions how to solve it?
**HINT:** The only thing you need to know is that any sequence convolved with a (shifted) delta impulse is a shifted version of itself: $$f[n]*\delta[n-k]=f[n-k]$$ Apply this to the expression $u[n]*(\delta[n]-\delta[n-1])$, and realize that what you're left with is a very simple sequence. (The result of (a) will be helpful.) Then convolve this very simple sequence with $x[n]$ to get the final result.
stackexchange-dsp
{ "answer_score": 1, "question_score": 2, "tags": "signal analysis, convolution, homework" }
Hausdorff dimension of graphs of one-dimensional Brownian motion First question here, my apologies if it is a duplicate or inappropriate. There is a page on Wikipedia listing fractals by Hausdorff dimension and it includes the graph of a "regular Brownian function" as having Hausdorff dimension 1.5. Does this mean that a Brownian motion has Hausdorff dimension almost always, or is it the expected value, or something else? I've tried to look for references (besides the Wikipedia one that I can't get) and googling for more information to little avail. If it's not true that the graph of a Brownian motion has Hausdorff dimension 1.5 almost always, is it true that the Hausdorff dimension >1 almost always?
Yes, the Hausdorff dimension of the graph is 3/2 almost surely. A good explanation can be found in Chapter 4 of Peres and Morters's book on Brownian motion. See Theorem 4.29 on page 110.
stackexchange-math
{ "answer_score": 6, "question_score": 8, "tags": "probability, fractals, brownian motion" }
Unzip with zlib without using SetCurrentDirectory I'm using zlib for unzip list of zip files. Here is the simple way to do it. But `SetCurrentDirectory` function calling affect my other threads. is there any way to unzip to specific directory using zlib. SetCurrentDirectory("c:\\docs\\stuff"); HZIP hz = OpenZip("c:\\stuff.zip",0); ZIPENTRY ze; GetZipItem(hz,-1,&ze); int numitems=ze.index; for (int i=0; i<numitems; i++) { GetZipItem(hz,i,&ze); UnzipItem(hz,i,ze.name); } CloseZip(hz);
Found the solution. void unZipPackage(std::wstring zip_file,std::wstring dest_dir){ HZIP hz = OpenZip(zip_file.c_str(),0); ZIPENTRY ze; GetZipItem(hz,-1,&ze); int numitems=ze.index; for (int i=0; i<numitems; i++) { GetZipItem(hz,i,&ze); wchar_t dest[MAX_PATH]; swprintf(dest,MAX_PATH,L"%s\\%s",dest_dir.c_str(),ze.name); UnzipItem(hz,i,dest); } CloseZip(hz); }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c++, zip" }
Customizing jTable I need to customize my jTable. All I need, is to put a custom Swing object (like jButon, jPanel, etc.) into the table cell. Is it possible? I'm trying: jTable.getModel.setValueAt(jPanel1,0,0) and jTable.getModel.setValueAt(jPanel1.getUI(),0,0) But the result is only a some kind of string, representing the object... I'm aware of custom renderers, but still don't get the technique of registering them properly. How do you do that?
See _How to Use Tables, Concepts: Editors and Renderers_ in the swing tutorial. It sounds like you're getting the default renderer for `Object`, which is "rendered by a label that displays the object's string value." You can use `setDefaultRenderer` to associate your class with your renderer, as shown in this example.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "java, swing, jtable" }
How do I enter the time value in hh:mm:ss format? I need to enter the time value hh:mm:ss `(09:45:56)` format , but in the Xcode text field I always get `(094556)` as format - how to resolve this?
You can use `NSDateFormatter` to parse any custom format NSDateFormatter *dateformatter = [[NSDateFormatter alloc] init]; dateformatter.dateFormat = @"HH':'mm':'ss"; NSString *mydate = @"09:45:56" NSDate *parseddate = [dateformatter dateFromString:mydate]; This should give you a date of "9.45 am today" The Docs for NSDateFormatter are pretty good but you can find the specific formatter variants possible here. Its linked from the apple docs. <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "ios, cocoa, ios4, xcode4" }
Geodjango with PostgreSQL 8.4.20 and PostGIS 2.2 I'm trying to use Geodjango with a somewhat older version of PostgreSQL (8.4.20). When trying to migrate the model generated in python to the database (`python manage.py migrate`), it throws the following error: django.db.utils.ProgrammingError: syntax error at or near "EXTENSION" LINE 1: CREATE EXTENSION IF NOT EXISTS postgis According to this answer, this probably has to do with the fact that I'm using an older version of PostgreSQL/PostGIS. But since I've already installed PostGIS, this command (`CREATE EXTENSION IF NOT EXISTS postgis`) which attempted by django is not necessary. Is there a workaround for this?
This is hardly a surprise as the minimum version of Postgresql that is supported by Postgis 2.2 is posgresql 9.1 According to the Version Compatibilit Matrix the latest version of Postgis that you might be able to use with 8.4 is 2.00 but it's going to be a lot of hard work.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "postgresql, postgis, geodjango" }
Function to change import and destination file I need to run the same code over 5 datasets which are too large to bind together. The code exports a table to a destination file which also needs to change depending on the file imported. Imagine I have the following code : load("file 1", .GlobalEnv) tab<-table(df$A, df$B) write.table(tab, "output 1.txt", sep="\t") So I would like a function that imports files 1 to 5 and exports them to outputs 1 to 5 respectively. Thanks in advance
Just use a loop. For example, if you have your files in an array called `files` for (i in 1:length(files)) { input.filename <- files[i] load(input.filename, .GlobalEnv) tab<-table(df$A, df$B) output.filename <- paste("output ", i, ".txt", sep="") write.table(tab, output.filename, sep="\t") }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "r, function" }
How to customize keyboard shortcuts in Jupyter Lab to run current line or selected text? I happen to use "Run Selected Text or Current Line in Console" command a lot under the "Run" menu in JupyterLab. How can we configure a custom keyboard shortcut in JupterLab/Jupyter notebook for this?
**For JupyterLab** Go to `Settings` and choose `Advanced Settings editor`. Under the `Keyboard shortcuts` tab, copy the entire `System Defaults` content to `User Preferences` column and find section containing: "command": "notebook:run-in-console", "keys": [ "" ], Add the key combination you wish and save, e.g: "keys": [ "F12" ],
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 7, "tags": "python, jupyter notebook, jupyter lab" }
What is the default Set/List implementation with Collectors in Java 8 Stream API? I have below code snap with Java 8. List<Employee> employees = DataProvider.getEmployees(); Set<Employee> set = employees.stream().filter(emp -> { System.out.println(emp.getName()); return emp.getName().equals("Vishal"); }).collect(Collectors.toSet()); I just want to know which implementation of `Set` it is using by default when we use `Collectors.toSet()` (refer above example)? Also, is there any way to tell the Java API to use a particular implementation (for example, `HashSet`)?
The `toSet()` collector does not specify which implementation it uses; you get a `Set`, that's all. If you want a specific kind of set, use `toCollection()` and provide a factory method for your set: ...collect(Collectors.toCollection(HashSet::new));
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 4, "tags": "java 8, java stream, collectors" }
jQuery Accordion - enlarging the box I'm using jQuery accordion to implement the similar features which < have. I've designed the palette which consists of text links which leads to text box, dropdown box etc..etc. What I need is when I click any link in the accordion, the entire box should be enlarged according to the text boxes and other items in the accordion link. Here is my code: < Could anyone just modify the code to get that feature for me? Thanks!
If I have understood you correct, this should solve the problem? #boxtext { font-family: Tahoma; color: white; word-wrap: break-word; }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jquery, jquery ui, jquery ui accordion" }
How can I make Twitter Bootstrap Popover that always be open? I want to make Twitter Bootstrap Popover that when document loaded, be open for ever. i see some solution but they show popover by `click` or `hover`! There is my code: $("#min-allowed-price .bar-label-shape").popover({ offset: 10, trigger:'manual' });
One way is to show popover manually and then remove the click event handler for the popover link. $('.popover-visible-trigger') .popover('show') .off('click'); See the working jsfiddle. The thing, though, is that maybe you don't need to do that. If you want the popover displayed at all times why not add it to markup?
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "javascript, twitter bootstrap, bootstrap popover" }
How to enable mysql support in Komodo 7.1? In Komodo 6 I can connect to my mysql database but not in Komodo 7.1? When I want to add my mysql connection to Komodo it gives me sqlite 3 support only?! How can I add my mysql connection to Komodo 7.1? !enter image description here
I installed the mysql.xpi extension in Komodo: < image description here
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "windows, linux, komodo" }
Why does my oven need to be above 36" if installed in Canada? I'm considering this oven for my cabin (in Canada). Installation manual says it needs to be at least 916 mm (36 inch) from the floor. But that applies only in Canada. Why? What's special about Canada? Is there an actual reason, or is this a code requirement? I was considering having it below counter. If that would be acceptable in the US or Europe, I wonder what the problem would be in Canada.
Sounds like they don’t want people bending over to pick up the hot dishes etc. That is a positioning concept applied in some kitchens when the other ergonomics permit.
stackexchange-diy
{ "answer_score": 2, "question_score": 2, "tags": "oven" }
What's the deal with the cure delivery on the rooftop in Arkham City? So I've been playing Arkham City recently. Near the beginning of the game, > The Joker poisons Batman. Much of the rest of the game is spent > searching for the cure to the poison. At one point, you get a call from Alfred, who tells you that Lucius Fox has synthesized a cure and it's Coming Soon To A Rooftop Near You. Sure enough, the cure is in a delivery capsule just like the ones that brought me the BatSuit and the Turbo Grapple, but when Batman injects the cure, he passes out and wakes up at the Mad Hatter's Tea Party. The supposed cure is never mentioned again and the rest of the game centers around finding more cure? **What did I miss?**
It's all part of Mad Hatter's delusion. > Mad Hatter specializes in hypnotic suggestion. We are told that finding a cure may take time and suddenly Batman receives a call that the cure is ready, only to find that it's actually a sedative. What happened is that by some sort of hypnosis , Batman is led to believe that whole part - the call, the delivery, taking the cure, etc. What probably happened is that the hatter planted a syringe with the poison at this location and led Batman there. (I don't believe we actually can tell when that hypnosis takes place but we do get a glimpse of the hatter when Batman rescues Vicky Vale, so it might have happened then)
stackexchange-gaming
{ "answer_score": 13, "question_score": 7, "tags": "batman arkham city" }
Delete all tables in the postgresql database using Django without deleting the database I am running AWS Elastic Beans which automatically set up a working postgresql database instance and connection for me. Therefore I do not want to just delete the database instance and configure it myself. I would rather just delete all tables in the database from python/django. I also do not want to delete the content of all tables (what `python manage.py flush` does). I want the database to return to a state where I can just run `python manage.py migrate` and it will create all empty tables from my current model definitions. Thanks
# Prints the SQL statements that would be executed for the flush command. Will delete all the data from tables in database django-admin sqlflush # You can pass the name of your database specifically. Defaults to default. --database DATABASE # If you want to delete all the tables of your app, then you can run the command python manage.py migrate appname zero
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "python, django, postgresql, amazon web services, cloud" }
Extract select columns from file based on value in single column I have a text file with 9 columns. Column 1 contains values 1-22. I want to print a new file containing only rows where column 1 = 15. Can this be done using awk?
`awk` to the rescue! awk '$1==15' file assumes whitespace is the field delimiter, otherwise set -F (e.g. for csv `-F,`)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "bash, shell, awk" }
kubectl run not creating deployment I'm running Kubernetes with docker desktop on windows. DD is up-to-date, and the `kubectl version` command returns 1.22 as both the client and server version. I executed `kubectl run my-apache --image httpd`, then `kubectl get all`, which only shows ![enter image description here]( There is no deployment or replicaset as I expect. This means some commands, such as `kubectl scale` doesn't work. Any idea what's wrong? Thanks.
The `kubectl run` command create pod not deployment, I mean it used to create in the past before kubernetes version 1.18 I guess. For deployment you have run this command `kubectl create deployment my-apache --image httpd`
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "kubernetes, kubectl" }
LDO issue for atxmega32e5 powering ![enter image description here]( Hello everyone! I am trying to test this circuit, but actually I have some issues with LDO power supply! Actually the problem is that, the two LDO: LDO_circuit and DLDO are working fine. I mean that if the power supply is 3.3 V they put on output 2.6 V and if the power supply is 5 V on the LDOs'output there is 3.3 V. Instead, on LDO_uC I have always on output very few mV even if I checked that on input I have the given power supply. Someone have ideas to suggest? Thank you very much in advance!
Looking at your schematic you have pin 1 of the uC (GND) connected pin 32 (AVCC). You have created a short between GND and the output of the LDO via the 2 inductors (or ferrite beads). It is simple to prove this: remove "Inductor uC" from the circuit, and the output of the "LDO uC" should be 3.3V. The solution is probably to lift (disconnect) pin 1 of the uC and use some fine wire (mod wire) to connect it to GND somewhere else. It would make it easier to refer to the parts on your circuit if you used a standard way. Rather than calling the LDO's "LDO 3.3 circuit" it would be better to call them U1, U2, U3 etc. Inductors are always called L1, L2. Ferrite beads can be FB1, FB2. Capacitors are C1, C2, etc. Connectors are usually K1, K2.
stackexchange-electronics
{ "answer_score": 1, "question_score": 0, "tags": "power supply, diodes, ldo, atxmega" }
Create a script to run my cocoa application with a service I need to create a package, that should include my application, my pluggin and a script. The idea, is to create a script that leaves my application running as a service, because I need to launch my application on the computer start up. I read about services but I am new and it is hard for me to understand how to do it. Any Ideas? Thanks
You cite Growl as an example. Growl is: 1. A non-document-based application. 2. That runs in the background. 3. And adds itself (with the user's permission) to Login Items. The first part is easy; Xcode has templates for that. To make it run in the background, but still capable of showing UI, set `LSUIElement` in your Info.plist. If your app will never show UI, you probably want `LSBackgroundOnly` instead. Both of these are documented in the Information Property List Key Reference. For the last part, that's been previously covered on Stack Overflow. (Updates to that answer: I left Growl a few months ago, and I'm pretty sure they're using LSSharedFileList now.)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "macos, cocoa" }
How to add a Python application to OS X right-click menu? I have made a Python-based application that plays a slideshow. I want to add shortcut on the right-click menu of a folder and play the slideshow. How can I achieve this?
You can use a service created by Automator to call your python script. !Automator Service example Once your service is created, it will be available in the service submenu of your contextual menu.
stackexchange-apple
{ "answer_score": 5, "question_score": 5, "tags": "macos, applications, python" }
What are the benefits of using the fields option when querying in Meteor SomeCollection.find({}, { fields: { exerciseId: 1} }) After running a time test, it looks like this query takes longer than just `find()` without any arguments. Are there any benefits of limiting the field? I guess, it will use less local memory but when is that worth it?
In my experience the benefits of using `fields` on the _client_ are limited. But you should absolutely use it when defining your publications on the _server_ for two reasons: 1. Security: hide fields the client has no business seeing, especially fields about other users 2. Performance: fewer fields means fewer bytes on the wire. Especially important when a subscription includes many documents.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "mongodb, meteor" }
How do I echo the original HTML in PHP? I have some HTML. In my HTML, there is a form that uses a PHP script. When I submit this form, it sends me to a blank page. I have tried this, as suggested in a similar question, but it doesn't work because I have HTML events that call functions with arguments, so both " and ' are already used... I am new to PHP, so, is a there a solution to this that I do not know of?
Use the backslash character `\` to escape your quotes like so `\"`. The backslash causes PHP to treat the quote as a regular character. :] Example: `<?php echo "Hello World"; ?>` outputs `Hello World` `<?php echo "\"Hello World\""; ?>` outputs `"Hello World"`
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, javascript, html, echo, server side" }
How to simplify this indices question The question: > $$ \mbox{(d)} \ \ \frac{ \frac{ 4^{ n + 1 } }{ 2^{ -n } } - 8^n }{ 2^{ 3n + 2 } } $$ And here are my workings: $$ 2. \quad \frac{ \frac{ 4^{ n + 1 } }{ 2^{ -n } } - 8^n }{ 2^{ 3n + 2 } } = \frac{ 2^{ 2n + 2 } \div 2^{ -n } - 2^{ 3n } }{ 2^{ 3n + 2 } } = \frac{ 2^{ 2n -(-n) + 2 } - 2^{ 3n } }{ 2^{ 3n + 2 } } = \frac{ 2^{ 3n + 2 } - 2^{ 3n } }{ 2^{ 3n + 2 } } \\\ = \frac{ 2^{ 3n } \times 2^2 - 2^{ 3n } }{ 2^{ 3n } \times 2^2 } = \frac{ 4 \times 2^{ 3n } - 2^{ 3n } }{ 4 \times 2^{ 3n } } $$ I am unable to proceed to the next step can someone please help? Or did i did something incorrect? Btw from the left to right
You have $\displaystyle \frac{4 \cdot 2^{3n} - 2^{3n}}{4 \cdot 2^{3n}}=\displaystyle \frac{3 \cdot 2^{3n}}{4 \cdot 2^{3n}}$
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "algebra precalculus" }
Better action hook for creating table than after_switch_theme and switch_theme action hook I want to create table only if my custom theme is activated. I have tried with `after_switch_theme` action hook but it is creating table regardless my custom theme. This means it is triggering action if I activate `Twenty fifteen` or any other theme. add_action('after_switch_theme', ['\Recruitment\recruitment', 'create_table']); I want to create table only if my custom theme is a current theme or activating that theme. Is there any hook for it or any alternate way?
Ah I found it. You can use `after_setup_theme` action hook. So it will be like add_action('after_setup_theme', ['\Recruitment\recruitment', 'create_table']); # Updated Code $theme = wp_get_theme(); if ( $theme->name == 'My THEME NAME' ) { global $wpdb; global $charset_collate; $sql = "CREATE TABLE IF NOT EXISTS ... $charset_collate;"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta( $sql ); add_option( 'ab_db_version', self::$db_version ); } // in another file add_action('after_switch_theme', ['\Recruitment\recruitment', 'create_table']);
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "actions, table" }
What are the similarities and differences between Groovy and LINQ? Today twitting with a colleague, he said me that Groovy is like C# but without LINQ. I don't know much about LINQ, but I answered him that Groovy has similarities to LINQ, for example, Groovy's class DataSet. Can you tell me more about similarities / differences between Groovy and LINQ (C#)?
I wonder who told you that ;P First, let me clarify my statement: Many of the things that I love about c# 4.0 are implemented on groovy, but groovy is already much more succinct. There are other obvious differences like the dynamic/scripting nature of the groovy language and so forth. now, linq is a step over closures, like a dsl inside c# to create closures in a query (sql) like sintax, with a pattern based on interfaces and a provider model behind to allow this closures to be translated to sql or to any kind of other representation. In this respect, since groovy has closures and beautifully implemented, AND it has many dsl-building capabilities built in, it should be possible to make a linq-like feature.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "linq, groovy" }
.data symbols equivalent to .text labels? It is understood that the labels that come in the `.text` section of an assembly program are representative of the address of the following instruction. Is it the same idea with the symbols we see in the `.data` section ? i.e. _"The label is representative of the base address of whatever follows"_. Does this apply anywhere in the program ? I'm a NOOB in assembly, learning MIPS as a part of coursework.
You basically stated the answer yourself, a label is representative of a location in your assembly code. The section is irrelevant. (You misused the term "base address" though)
stackexchange-reverseengineering
{ "answer_score": 1, "question_score": 0, "tags": "assembly, mips" }
Sed with variables i have a config file with this format Im using this code to replace the Username1/Password1 with a different Username2/Password2 sed -i -e 's/\/Username1\/Password1/\/Username2\/Password2/g' /etc/config.cfg Now i want to make this something like $UsernameOLD = Username1 $PasswordOLD = Password1 $UsernameNEW = Username2 $PasswordNEW = Password2 sed -i -e 's/\/$UsernameOLD\/$PasswordOLD/\/$UsernameNEW\/$PasswordNEW/g' /etc/config.cfg Could anyone help me getting this ready ?
I found the solution i had to use double quotes instead of ' The working command looks like this: UsernameOLD=MyOldUsername PasswordOLD=MyOldPassword UsernameNEW=MyNewUsername PasswordNEW=MyOldUsername sed -i -e "s/\/$UsernameOLD\/$PasswordOLD/\/$UsernameNEW\/$PasswordNEW/" /etc/config.cfg
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "sed" }
Creating Android resource images sizes So I need to create images to be part of my app that I'm making. I haven't found the answer anywhere. What I am wondering is... If I created an image that is to be displayed on Activity1, then what image size in PIXELS should I created the initial image at? The initial image would then be resized to their corresponding DPI to work well on Android phones. I may be doing this wrong in creating images so they don't lose their quality, any ideas? If I am doing this wrong, then please can someone advise on the best practice on creating Android images in pixels and then converting to DPI later after the initial image? Thank you! :) EDIT: This question is different because I'm mainly talking about keeping image quality by making the image big first and then downsizing.
You have to create six generalized size image densities: * ldpi (low) ~120dpi * mdpi (medium) ~160dpi * hdpi (high) ~240dpi * xhdpi (extra-high) ~320dpi * xxhdpi (extra-extra-high) ~480dpi * xxxhdpi (extra-extra-extra-high) ~640dpi For more detail check out this link
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "android, image, xamarin, xamarin.android" }
How to set null value from SQL query to empty string in C#? I have to query array of strings from SQL using this code: defaultMail = getDefaultMailList(requester); and the sql query string is SELECT * FROM dbo. .... Then, I get array of string from the `getDefaultMailList` method: string toEmail = defaultMail[0]; string ccEmail = defaultMail[1]; Then, I use the value of SQL query to make a condition of if else like this. if (ccEmail != "") { do something } Now, I met the problem when SQL query returns `null` value. The `ccList != ""` still returns `TRUE`, but I want to make it return `FALSE`. How to handle with this problem? Thank you.
To check if it's empty or null you can use the `IsNullOrEmpty` Function. This function will both check if the variable is null or empty. If you want to check user input you could also use `IsNullOrWhitespace`, which additionally checks if the string consists of only whitespace characters. // Check if the string is either empty or null. if (string.IsNullOrEmpty(ccList)) { // do something }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -2, "tags": "c#, asp.net" }
Bug: Counting Consecutive Reset I'm facing a problem with my loggin consecutive count. Today, it was reset back to 1. I've never missed a day since March 21. Please check and let me know. Thanks so much. !calendar **UPDATE:** This is my Calender in SO. !enter image description here
One of the reason from a reply on similar question > It is easy to visit Stack Overflow every day and still "miss a day." Stack Overflow's days starts at midnight (UTC, over in London somewhere ). So a "Stack Overflow day" starts at (for example) 8pm Eastern Time. Another reason(again answered here) can be: > No access to internal pages (login pages, along with a number of other homepage style pages, don't count as "access").
stackexchange-meta
{ "answer_score": 2, "question_score": 1, "tags": "bug, status bydesign" }
pinescript crossover price with SMA does not seem to be working I want to check if the price crossed over the 200 SMA for more than a given amount of candles (customizable). If true i want it to open a long (i have other conditions i need to add later but i noticed my code is already not working here). It opens longs over the complete chart even when the price is not over the 200SMA. this is what i have: SMA200 = sma(close, 200) //PRICE OVER EMA CHECKS TrendBarsCount = input(5, "Price closes needed above/below 200 MA", minval=1) emaCrossOver = crossover(close, SMA200) var emaLongCondition = false if barssince(emaCrossOver) >= TrendBarsCount emaLongCondition := true strategy.entry("Open Long", strategy.long, when = emaLongCondition) it just doesn't seem to care about the SMA at all, what am i doing wrong?
This worked for me. Checks if a candle closes above 200 SMA, then waits 5 candles to open a long. SMA200 = sma(close, 200) TrendBarsCount = input(5, "Price closes needed above/below 200 MA", minval=1) emaCrossOver = crossover(close, SMA200) longCondition = barssince(emaCrossOver) == TrendBarsCount if longCondition strategy.entry("long", strategy.long)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "pine script" }
Compute a cosine dissimilarity matrix in R I want to create heatmaps based upon cosine dissimilarity. I'm using R and have explored several packages, but cannot find a function to generate a standard cosine dissimilarity matrix. The built-in `dist()` function doesn't support cosine distances, also within the package `arules` there is a `dissimilarity()` function, but it only works on binary data. Can anybody recommend a library? Or demonstrated how to calculate cosine dissimilarity within R?
As @Max indicated in the comments (+1) it would be simpler to "write your own" than to spend time looking for it somewhere else. As we know, the cosine similarity between two vectors $A,B$ of length $n$ is $$ C = \frac{ \sum \limits_{i=1}^{n}A_{i} B_{i} }{ \sqrt{\sum \limits_{i=1}^{n} A_{i}^2} \cdot \sqrt{\sum \limits_{i=1}^{n} B_{i}^2} } $$ which is straightforward to generate in `R`. Let `X` be the matrix where the rows are the values we want to compute the similarity between. Then we can compute the similarity matrix with the following `R` code: cos.sim <- function(ix) { A = X[ix[1],] B = X[ix[2],] return( sum(A*B)/sqrt(sum(A^2)*sum(B^2)) ) } n <- nrow(X) cmb <- expand.grid(i=1:n, j=1:n) C <- matrix(apply(cmb,1,cos.sim),n,n) Then the matrix `C` is the cosine similarity matrix and you can pass it to whatever heatmap function you like (the only one I'm familiar with is `image()`).
stackexchange-stats
{ "answer_score": 34, "question_score": 27, "tags": "r, clustering, similarities, cosine similarity, cosine distance" }
Wordpress - вывести посты с "метками" на главную Хочу на главной странице вывести n количество новостей из двух типов - популярные и новые. С таким условием что мне нужно самому выбирать какие посты отображать главной и с какой меткой. Вот яркий пример того чего я хочу добиться: > < Как это лучше сделать ? Видел на одном в одном шаблоне возле поста вот такое: !alt text что это ? Может можно при помощи этих "меток" сгруппировать нужные посты и вывести в нужном месте ? PS группировать по типу постов, категориям, Тегам не вариант.
Проще всего использовать плагин. Посмотрите здесь
stackexchange-ru_stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "wordpress" }
How to make ReactiveCommand Async ? I am using ReactiveCommand to get Async behavior. According to Paul Betts comment in this discussion > If you're using RxUI 5.0, just use ReactiveCommand, they are now merged and have a better API. I have the following code to test to see if it does the Async behavior. And it turns out to be not. It freezes up the UI for 5 seconds. MyReactiveCommand.Subscribe(s => { Thread.Sleep(5000); }); What am I missing?
Try: MyReactiveCommand .RegisterAsyncAction(_ => { Thread.Sleep(5000); }); And if you need to return a result: MyReactiveCommand .RegisterAsyncFunction(o => { Thread.Sleep(5000); return o.ToString(); }) .Subscribe(s => MessageBox.Show(string.Format("{0} was returned", s)));
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "reactiveui" }
Entropy[...] doesn't calculate the entropy of a probability distribution? What does it do? I know the definition of entropy of a probability distribution: $$H = - \sum_i p_i \log p_i $$ So for example, in a Bernoulli distribution with $p = 0.2$, $1-p=0.8$, the entropy is $0.5$. However, in Mathematica Entropy[{0.2,0.8}] returns `Log[2]`. So either the Mathematica has a bug, or I don't understand what it is that `Entropy[...]` calculates in Mathematica. Can someone clarify this for me?
It seems Mathematica's `Entropy` is equivalent to the following code (at least for lists of symbols and strings): entropy[list_List] := With[{p = Tally[list][[All, 2]]/Length[list]}, -p.Log[p] ] entropy[str_String] := With[{p = Tally[Characters@str][[All, 2]]/StringLength[str]}, -p.Log[p] ] You can try this on the examples on the `Entropy` help page to see the result is the same: entropy[{0, 1, 1, 4, 1, 1}] == Entropy[{0, 1, 1, 4, 1, 1}] (* True *) entropy["A quick brown fox jumps over the lazy dog"] == Entropy["A quick brown fox jumps over the lazy dog"] (* True *) This means that Mathematica calculates entropy using `Log` base e, which is called nat) entropy. With a choice of 2 for the base of the `Log` you get the Shannon entropy and with 10 as base you end up with the Hartley entropy.
stackexchange-mathematica
{ "answer_score": 10, "question_score": 12, "tags": "probability or statistics" }
Use stream instead of snprintf I'm not fairly familiar in C++ stream API and I want to convert a C code using stream in C++, char sHex[20] = {0}; int numid = 2; snprintf( sHex, sizeof(sHex) - 1, "%X", numId );
stringstream ss; ss << uppercase << hex << numId; string res = ss.str();
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "c++, c" }
What do we mean by <variable> = new Comparator(<data_type>) in Java I had a piece of code. compareScanMz = new Comparator<Triplet>() { @Override public int compare(Triplet o1, Triplet o2) { int scan1 = o1.scanListIndex; int scan2 = o2.scanListIndex; int scanCompare = Integer.compare(scan1, scan2); if (scanCompare != 0) { return scanCompare; } else { int mz1 = o1.mz; int mz2 = o2.mz; return Integer.compare(mz1, mz2); } } };` In the code I am able to figure out the other statements, but am unable to get the first one. i.e: compareScanMz = new Comparator() What does this statement mean?
You are creating new comparator for Triplets and inside it you define how to compare two of them. You need id when you want to override the default compare method on the Triplets. If by default two Triplets are comparet by name, in some cases you may want to compare them by age. And for that case you write own comparator and define new comparing rules.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, comparator" }
I want to select all and copy it to clipboard I have a WebBrowser displaying text. If i copy it to clipbaord it copy's all the html tags to and i don't want that. I want to be able to **select all** then copy to clipboard. I want to copy the **text and its formatting** to the clipboard. When i highlight the text my self and click copy when i paste, its perfect just how i want it. But when i use this code to copy just the Document text i get the Html tags to. This is how i copy to clipboard: void CopyCellText() { Clipboard.Clear(); if (webBrowser1 != null) { Clipboard.SetText(webBrowser1.DocumentText.ToString().Trim()); } }
To Select all and copy to clipboard: webBrowser1.Document.ExecCommand("SelectAll", true, null); webBrowser1.Document.ExecCommand("Copy", true, null); You wont see the html tags but have all there formatting.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "c#" }
Download Files from a Website with Python I have about 300 small files that I need to download from a website. All are located in one directory. The files are of different sizes and have different extensions. I don't want to type each one into my web browser and then click 'save as' and such. I want to give my list to python and have it download and save each file in a directory. If python can simply download the directory, that would be even better.
This is all detailed here. I would favor using Requests as it's generally great, but urllib2 is in the standard library so doesn't require the installation of a new package.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": -1, "tags": "python, web, download" }
Duplicates issue I have a problem with duplicates. Actually what I need is only the see duplicates but my table has many variables something like the below: a b c d e 32 ayi dam som kem 32 ayi dam som tws 32 ayi dam tsm tws 12 mm ds de ko 12 mm tmm to ko I am trying to keep if 'a' 'b' 'c' and 'd' variables are same. So I need only first 2 columns. I try to do this proc sort data=al nodupkey dupout=dups; by a b c d; run; any idea if this works?
Another option could be Proc SQL, no pre-sort needed: proc sql; create table want as select * from have group by a, b, c, d having count(*)>1; /*This is to tell SAS only to keep those dups*/ quit;
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "duplicates, sas" }
JavaScript library like JsonViewer I am trying to write the documentation of a custom HTTP API. I would like to see it like a demo client, with real responses. In design there will be 3 columns, 1 for request methods, 1 for JsonViewer and 1 for html output. My question is if there a library (JS) to help me in the JsonViewer like < ? Thanks.
Finally I found this JQuery library. < . It is exactly what I was looking for.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "javascript, jquery, json, api, rest" }
ant deployment fails with "Error: limit exceeded" I've been running ant deploy all day yesterday on an org of mine with no problems. Before each deployment, I ran an undeploy to delete everything I had deployed previously. In the middle of the day, I ran into this error while deploying: "objects/Opportunity.object (Opportunity.BillingOrganization__c) -- Error: limit exceeded (line 818, column 13)." I'm nowhere near hitting any storage limits, nor am I close to hitting any custom field limits. There are no fields available to be undeleted and nothing in the org's recycling bin. I am able to create a custom field manually in my org. I also ran an ant deployment on another org of mine with no problems. Here is the org's System Overview: Does anyone know what is going on? Thank you.
Ended up making a case about this issue. Support ran a Physical Delete (PD) on my org to delete custom fields that have been deleted but still remain. Deployments are working now. I've also asked about the purgeOnDelete flag when running an ant undeploy job. Here is their response: > "That's slightly different. Essentially, the OnDelete flag puts the field in a 'hard' deleted state. We then have a sweeper program that will remove these later ('physical delete'). This is random and usually occurs nightly. In situations like ours here, we can manually run the physical delete, instead of waiting for it to occur organically."
stackexchange-salesforce
{ "answer_score": 4, "question_score": 4, "tags": "custom object, deployment, limits, ant" }
Points to line in ArcMap with colours I have points table in ArcMap. I would like to make a points to line based upon a column "Element" and make a color scheme. I made it in ArcMap , see figure. The first green line with name element "II" is made using points 1 to 5 and second blue line "III" using points 6 to 15. I would like to start the blue line right at the edge of green line and so on. I do not want any gap in between. How should I do this? Should I need to modify points table in some way or can do it in line table or under symbology? Any suggestion? ![enter image description here](
I think that you would need to duplicate the start and end points for each colour bracket. For example, the final point in your green line "II", should also be the first point in your blue line "III".
stackexchange-gis
{ "answer_score": 0, "question_score": 0, "tags": "arcgis desktop, arcmap, symbology" }
How does this serial input DAC work? This is the datasheet for 6379A: datasheet I looked at the timing charts, but I’m still having trouble figuring out how the IC treats the serial input. Apparently, SI is sampled at positive clock edge, but what indicates the start of the input? I mean where are MSB and LSB? Also, I don’t get what LRCK does either. Can someone please explain to me, in simple words, how this IC is used?
The converter needs one 16 bit word for both channels, L first and then R. LRCK shows to the converter is there coming in data for L or R. Both words come in MSB first, LSB last. The output of the converter is made from the last fully inputted L+R word pair. The output changes when the input of the next L+R word pair is started. Both channel outputs change at the same time, because people generally do not want any time delay between L and R signals, the timing must be "sample accurate".
stackexchange-electronics
{ "answer_score": 0, "question_score": 0, "tags": "digital logic, dac, serial bus" }
Django OneToOne reverse relationship does not allow null values I have this architecture (very simplified) from django.db import Models class MainClass(models.Model): a = models.IntegerField() b = models.CharField() class OtherClass(models.Model): c = models.IntegerField() main = models.OneToOneField(MainClass, primary_key=True) Which means my **MainClass object has an attribute named otherclass, because of the existence of the reverse relationship between these models**. My problem is if I specify valid values for MainClass.a and MainClass.b, but None for MainClass.otherclass. I get the error **_ValueError: Cannot assign None: "MainClass.otherclass" does not allow null values._** I understand there cannot be OtherClass without MainClass (it doesn't make sense), but why the opposite situation is also causing an error? Other way: **Why cannot be MainClass without OtherClass?**
Looks like this is a normal behaviour in Django 1.8, although the restriction has been removed in Django 1.10 So, This isn't an error.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "database, python 2.7, one to one, django 1.8" }
How to merge 2 arrays python (similar to SQL Join) I have 2 large arrays (500,1,23000) and another one (700,1,25000) I need to merge them. They are different Easy example would be this: a = np.array([['a', 3, 5, 6, 9], ['b', 14, 15, 56]]) b = np.array([['b', 4, 76, 44, 91, 100], ['c', 14, 15],['d',2,6,7]) Desired result: `c = [['a', 3, 5, 6, 9], ['b', 4, 76, 44, 91, 100],['c', 14, 15],['d', 2, 6, 7]]` This is part of data-preprocessing for machine learning.
This could probably be made faster (it iterates over both lists twice), but should give you what you want. import numpy as np from collections import defaultdict a = np.array([['a', 3, 5, 6, 9], ['b', 14, 15, 56]]) b = np.array([['b', 4, 76, 44, 91, 100], ['c', 14, 15],['d',2,6,7]]) def dictify(arr): return defaultdict(lambda : [], {x[0]: x[1:] for x in arr}) d1 = dictify(a) d2 = dictify(b) new_keys = set.union(set(d1.keys()), set(d2.keys())) ans = [[k] + d1[k] + d2[k] for k in new_keys] The value of `ans` is: [['d', 2, 6, 7], ['c', 14, 15], ['a', 3, 5, 6, 9], ['b', 14, 15, 56, 4, 76, 44, 91, 100]]
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, numpy, machine learning, keras, autoencoder" }
symfony twig translation not working after update I upgraded my project from 2.5.x to 2.8.1 and suddenly twig is not using the correct translations anymore. In the twig template i have something like this: `{% trans %}something.abc{% endtrans %}` my config.yml looks like this: ... framework: translator: ~ ... templating: engines: ['twig'] default_locale: en_US in Controller action: $request->setLocale('nl_BE'); The page is always showing the en_US translation and never something else. Did something change?
It is because the `TranslatorListener` (which was added in 2.6) sets the locale before the action is called in your controller. Use `$this->get('translator')->setLocale('nl_BE');` instead, if you want to change the locale in your controller.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "php, symfony, twig" }
Trigger 404 error if accessed directly I have a page which basically makes show a information from a specific id through get requests. The url could be something like: I want to redirect to 404 error page, if the page is accessed directly, for instance if you access How can i do this?
language? server? with apache server and php script, you could do something like: <?php if($_GET["id"] === null || $_GET["id"] == false || $_GET["id"] == "") { header("HTTP/1.0 404 Not Found"); include("/error_pages/new404.html"); } ?> but then you would need a custom 404 page, that can be provided.. <
stackexchange-stackoverflow
{ "answer_score": -3, "question_score": -3, "tags": "php, wordpress" }
Reading all double number from string which length is unknown I have a string, but I don't know its length, because I read from a file. (I must do this way, so pls don't tell me that read somehow else) I want to read all double number from it, but I don't know how many numbers it has. I wanted to use sscanf, but it doesn't work, it always reads the first number of course. Ideas?
Something like this will work. const char *p = str; double d; int n; while (sscanf(p,"%lf%n",&d,&n) == 1) { // do something with d p += n; } The reason you are having issues with sscanf is because it does not automatically move the buffer provided, you must ask it how many characters it has read (`%n`) and move it yourself.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c, string" }
vector of historical highs of another vector I searched at the forums but I could not find an answer for this. I am looking for a way to convert c(1,3,4,2,7,12,6,8,15) to c(1,3,4,4,7,12,12,12,15) using no loops. It can be defined as a vector of historical highs of another vector. This is an example, my data length will be fairly long. thanks a lot, Emre
We can use `cummax` from `base R` cummax(v1) #[1] 1 3 4 4 7 12 12 12 15 ### data v1 <- c(1,3,4,2,7,12,6,8,15)
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "r" }