INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Coordinate compression
Problem: You have an N x N grid (1 <= N <= 10^9). Each square can either be traversed or is blocked. There are M (1 <= M <= 100) obstacles in the grid, each one shaped like a 1xK or Kx1 strip of grid squares. Each obstacle is specified by two endpoints (A_i, B_i) and (C_i, D_i), where A_i=C_i or B_i=D_i. You are also given a start square (X,Y). The question is: how many squares are reachable from the start square if you can go left, right, up, and down, and you cannot traverse obstacles?
I have tried to solve this problem with BFS, but for very large dimensions of the grid it is too slow. Then i heard of coordinate compression. Can someone explain what is coordinate compression, how is it implemented, where can i learn more about it ?
|
You have few obstacles on a large field. If you treat every square of the field as vertex in your graph, you will end up with a large graph, which requires a lot of memory and will take a long time to traverse.
The idea is to reduce the number of squares in the graph by creating rectangular blocks from the squares. To illustrate, you want to convert your graph like this:
!Fine \(left\) and coarse \(right\) grid resolution
This reduces the number of vertices greatly. For example, the 5×7 squares in the top left corner are now represented by a single block. The new graph has only 7×7 blocks.
It should be easy to achieve such a representation: Find the horizontal and vertical block coordinates. Sort them. Use binary search to find the block coordinates of obstacles and the starting point. Then use your original algorithm on the compressed grid.
|
stackexchange-stackoverflow
|
{
"answer_score": 19,
"question_score": 12,
"tags": "algorithm, compression, coordinates, graph theory"
}
|
Is it okay to say "What was the number of..." meaning "How many..."?
Is it okay to say "What was the number of" meaning "How many"? For example, "What was the number of students that came here yesterday?"
|
It's grammatically correct, but in an informal context, it would be more likely to say "how many".
|
stackexchange-english
|
{
"answer_score": 1,
"question_score": 1,
"tags": "word choice"
}
|
Serial Port Synchronization in Delphi
I am still having issues with the TComPort component but this time is not the component itself is the logic behind it. I have a device witch sends some ascii strings via serial port i need to prase those strings the problem is the computer reacts very fast so in the event char it captures only a part of the string the rest of the string comes back later... so parsing it when it is recived makes it impossible.
I was thinking in writing a timer witch verify if there was no serial activity 10 secons or more and then prase the string that i am saving into a buffer. But this method is unprofessional isn't there a idle event witch i can listen...Waiting for the best solution for my problem. Thanks.
|
After using a number of serial-port-components, I've got the best results until now, by using `CreateFile('\\?\COM1',GENERIC_READ or GENERIC_WRITE,0,nil,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,0)`, passing that handle to a THandleStream instance, and starting a dedicated thread to read from it. I know threads take a little more work than writing an event handler, but it still is the best way to handle any synchronization issues that arise from using serial ports.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "delphi, serial port"
}
|
Is there an array function which produces more elements than it receives?
If we use `map` on array - we will get the same number of elements.
If we want less elements - we can use `filter`, `find` or `reduce`, depending on situation.
Is there a build in function which would work the other way?
For example, let's say I have an array like this:
myArray = [
{nodes: Array(5)}, // some array with 5 elements
{nodes: Array(3)},
{nodes: Array(3)}
]
I want to split every array with more than 3 elements into array which maximum 3 elements. So in the end I want to get:
splittedArray = [
{nodes: Array(3)},
{nodes: Array(2)},
{nodes: Array(3)},
{nodes: Array(3)}
]
I know how to achive this with looping over `myArray` with `forEach` and pushing items to some new array, but is there some ready-to-go function for it?
|
> but is there some ready-to-go function for it?
Unfortunately not. Other languages (Kotlin for example) , do have a `chunk` method.
However this could be achieved with `.flatMap`, but "good old for loops" work way better here:
const result = [], size = 3;
for(const { nodes } of myArray) {
for(let i = 0; i < nodes.length; i += size)
result.push({ nodes: nodes.slice(i, i + size) });
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "javascript, arrays"
}
|
Socket.IO Java Client to Jar
I'm trying to compile Socket.IO Java client to JAR file but have no luck. I need it for Android project to comunicate with Node.JS Socket.IO.
The Socket.IO Java client is this one: <
I do it like its said in github wiki, but no luck:
cd $PATH_TO_SOCKETIO_JAVA
ant jar
ls jar/socketio.jar
I tryed it with: Java Sun 6, Java Sun 7 and Java Open 6 (JDK, JRE)
I noticed, that the `build.xml` file does not contain all of the paths as they should be. For example path to eclipse directory. So what should I do. Maybe I can build the jar somehow else?
|
At the time of this writing, the build.xml in github doesn't have the target _jar_ anymore or any task that builds jar. Latest version of auto generated build.xml seems to have dropped the _jar_ task. Look at the history of build.xml, some of the older files have _jar_ task. May be you can copy that task and include it in the latest version.
**@HeatfanJohn** : This is the code that I added to `build.xml` to allow `ant jar` to successfully build `socketio.jar`
<target name="jar" depends="build-project">
<mkdir dir="jar"/>
<jar destfile="jar/socketio.jar" basedir="bin">
<zipgroupfileset dir="libs/" includes="*.jar"/>
<manifest>
</manifest>
</jar>
</target>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "java, android, jar, socket.io"
}
|
How to show json into client like this
How to show json into client like this link
<
|
Use the `JSON_PRETTY_PRINT` option:
$data = Array(
"Foo" => "Bar",
"Fiz" => "Buz"
);
echo json_encode($data, JSON_PRETTY_PRINT);
This requires PHP 5.4.0 or greater. The output follows:
{
"Foo": "Bar",
"Fiz": "Buz"
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -4,
"tags": "php, json"
}
|
Grabbing a word from a character?
I have done my google research. I've tried preg_match, strsub_replace, almost everything.
I honestly can't seem to figure out how to grab a word that is connected to a character.
I have a statuses system on my website. I am trying to figure out how replace a word with something else if it has the character '@' in it.. like on twitter, when you say '@person'.
Any help is very much appreciated.
|
to just print matches:
preg_match_all("/@([0-9a-z]+)/i",$input,$matches);
print_r($matches[1]);
to replace them:
$input = preg_replace('/@([0-9a-z]+)/i','-->\1<--',$input);
will replace `@text` with `-->text<--`, as an example.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php"
}
|
Woocommerce custom style for specific product category?
Is there an easy way to add a custom style to a specific products in Woocommerce? For example, I want all products with a category of 'Category1' to have a blue page background color, and all products with a category of 'Category2' to have a white page background color.
Unfortunately, I am mostly clueless when it comes to PHP. Can you explain the solution to me like I'm a 5th grader?
Thanks in advance :)
|
You'll need to ad a function to your theme's `functions.php` file:
// add taxonomy term to body_class
function woo_custom_taxonomy_in_body_class( $classes ){
if( is_singular( 'product' ) )
{
$custom_terms = get_the_terms(0, 'product_cat');
if ($custom_terms) {
foreach ($custom_terms as $custom_term) {
$classes[] = 'product_cat_' . $custom_term->slug;
}
}
}
return $classes;
}
add_filter( 'body_class', 'woo_custom_taxonomy_in_body_class' );
This function is cribbed from here. This function will add the product category slug as a class name to the `<body>` element, which will allow you to target the styles specifically for that page.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "woocommerce"
}
|
How can I uninstall ubuntu web browser?
I have installed Ubuntu 16.04 and find ubuntu web browser as pre-installed web-browser. I find it useless as Mozilla is far superior than this.
How can I remove it from Ubuntu?
|
Assuming you're using the standard package for Ubuntu Web Browser, you can uninstall it by opening a terminal (press `Ctrl`+`Alt`+`T`) and running:
sudo apt purge webbrowser-app
sudo apt autoremove --purge
|
stackexchange-askubuntu
|
{
"answer_score": 8,
"question_score": 8,
"tags": "webbrowser app"
}
|
SQL Query Issues
Having a very hard time wrapping my head around how this should be written, I have a key made up of a fixed number column and an incrementing number column.
I want to have the select query only return the newest row for each fixed number.
For example:
20, 1
20, 2
20, 3 <-- Should only return these rows
25, 1
25, 2 <--
30, 1
30, 2
30, 3 <--
Is there to write this in a single query without having to iterate over the results in php?
|
select col1, max(col2) from table group by col1
would give you
20 3
25 2
30 3
SqlFiddle Demo
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php, mysql, sql"
}
|
why is this loop running infinitely discord.py?
users = await new_msg.reactions[0].users().flatten()
users.pop(users.index(self.client.user))
finaluser= users
role = discord.utils.get(ctx.guild.roles, name="Admins")
print(finaluser)
for user in users: //this is running infinitely
await ctx.send(user.name)
if role in user.roles:
finaluser.append(user)
await ctx.send(finaluser)
return
Here why is this for loop running infinitely? I cannot understand
|
I have found a way to fix it. Instead of assigning finaluser to users, I assigned it to `finaluser= await new_msg.reactions[0].users().flatten()`. Now, It's working as expected.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "loops, discord, discord.py, bots"
}
|
How to extract rows of a matrix with condition in matlab
Suppose
A = 1 0 0
1 0 1
0 0 1
1 0 1
0 0 0
Now I want to extract rows whose 1st and 3rd column values are 1 at the same row ie output should be
1 0 1
1 0 1
tried with `A(A(1:end,1)==A(1:end,3)==1)`, but not getting result.
|
Try this:
A(A(:,1) == 1 & A(:,3) == 1, :)
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "matlab"
}
|
Trying to use. Find in VBA, getting error saying the object doest support the property or moethod
Here's the problem function. I've written lots of functions similar to this without issue and I've no idea what the problem is this time.
Sub FindEquipCost()
Dim equipment As Range
Set equipment = Sheets("Sheet1").Find("EQUIPMENT",
LookIn:=xlValues, MatchCase:=True)
MsgBox (equipment)
End Sub
|
As mentioned in the comments, `Find()` is a method of the `Range` object, not of the `Worksheets` object.
This is a way to run your code without an error:
Sub FindEquipCost()
Dim equipment As Range
Set equipment = Sheets("Sheet1").Cells.Find("EQUIPMENT", _
LookIn:=xlValues, MatchCase:=True)
If Not equipment Is Nothing Then
MsgBox equipment.Address
Else
MsgBox "MISSING"
End If
End Sub
See the `.Cells` between `Sheets()` and `.Find`.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "excel, vba"
}
|
Angular Material can't set md-card as an anchor
Is it possible to make the whole card a link in Angular material or is there another directive intended for this use case?
|
You can just put a `ng-click` on the card and perform your operation.Further you can style the card with hover effects to get the feel of a link.Like this :
**HTML:**
<md-card ng-click="cardSelected()" class="cardAsLink">
....
</md-card>
**JS:**
$scope.cardSelected=function(){
console.log("card Clicked");
}
**CSS:**
.cardAsLink{
cursor: pointer;
}
.cardAsLink:hover{
border : 1px solid blue;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "angularjs, angular material"
}
|
port ksh if condition to bash shell
I have this if statement in ksh, same is not working bash. what is ksh equalent in bash?
#!/bin/ksh
if [[ "$1" = @(hello|world|shell) ]] ; then
echo "matched"
else
echo "not matched"
fi
Thanks SR
|
You can enable a subset of `ksh`'s extended pattern support (which, luckily for you, includes the `@(...)` construct :) with
shopt -s extglob
if [[ $1 = @(hello|world|shell) ]]; then
(`bash` 4.1 and later temporarily enable extended pattern support for `=` inside `[[...]]`, so the `shopt` command is only necessary in earlier versions of `bash`.)
Incidentally, you can achieve the same result with the POSIX-standard `case` statement.
case $1 in
hello|world|shell) echo "matched" ;;
* ) echo "not matched" ;;
esac
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 1,
"tags": "bash, shell"
}
|
Cannot perform runtime binding on a null reference on C# String.IsNullorEmpty in VS2019
I use the String.IsNullorEmpty to check if a cell in Excel worksheet is null or empty. Why VS2019 still reports a error if the cell is empty? I am sure the worksheet wshIO exists and the intRowIO is 1 when this error came out. The code associated with this worksheet before this line works very well.  a null _dynamic_ type.
For instance, it's the same scenario as the following:
dynamic s = null;
s.ToString(); // Cannot perform runtime binding on a null reference
One fix is to use the _null conditional operator_ , which will check the _dynamic_ type for `null`.
string.IsNullOrEmpty(s?.ToString());
Or related to your example:
string.IsNullOrEmpty(something.Cells[x,y].Value2?.ToString())
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "c#, string, isnullorempty"
}
|
How to figure out this Polar Equation to find out domain of Θ values to get the entire graph without repeating?
I understand that the period for the graph 4 + 2sin(2Θ/3) is 3π. The way I got that was by 2π/b. b is 2/3. Therefore I did 2π/(2/3) and got 3π for the period. Can someone guide me to solve part b? I need to get the domain values of Θ to get the whole graph without repeating any part of the graph. I posted a picture of the graph below and part b in case I didn't explain it clearly.
, and
2. as it heats up the pipe rattles (sounds a little bit like popcorn popping - progressively gets faster)
Once it's hot the pipe stops rattling. From what I've read it seems as though this is water hammer? In which an arrestor should address this? I have easy access through one of our closets floorboards to the pipes, and I have confirmed that they are secure.
So my question is - does this sound like in fact I need a water hammer arrestor? Would something like this work?
|
It's not hammer time, it's thermal expansion. As the hot water travels through the pipe, the pipe itself heats up and expands. As this happens, fasteners and any materials in contact with the pipe experience friction and, at times, the pipe moves slightly against that material and causes a poping sound. It's like snapping your fingers. We hear this all the time with other materials in other circumstances if you think about it. The frequency of the poping changes as the pipe heats up. The fix would be to better secure the pipe (not tight, but with an intermediate material) to the studs or block as necessary to keep it from rattling or "poping". If attached to concrete, insulate the pipe with something, anything, to keep it from contacting the concrete.
|
stackexchange-diy
|
{
"answer_score": 3,
"question_score": 4,
"tags": "plumbing"
}
|
How to display a snackbar or toast at top of the screen in xamarin forms
I implemented snackbar in xamarin project. But I need to displaty that snackbar at top of the screen.
Code:
SnackBarOptions options = new SnackBarOptions
{
MessageOptions = new MessageOptions
{
Foreground = Color.Black,
Message = toastMsg,
Padding= 15
},
BackgroundColor = Color.White,
Duration = TimeSpan.FromSeconds(8),
CornerRadius = 15,
IsRtl = true,
};
Application.Current.MainPage.DisplaySnackBarAsync(options);
|
You need to write custom platform specific code to achieve this:
**Android:**
GradientDrawable shape = new GradientDrawable();
shape.SetCornerRadius(15); //For Corner radius
shape.SetColor(Android.Graphics.Color.Black);
var contentView = Xamarin.Essentials.Platform.CurrentActivity?.FindViewById(Android.Resource.Id.Content);
Snackbar snackBar = Snackbar.Make(contentView, "Your Message", 5000);
Android.Views.View view = snackBar.View;
view.SetBackground(shape);
FrameLayout.LayoutParams frameLayout = (FrameLayout.LayoutParams)view.LayoutParameters;
frameLayout.Gravity = GravityFlags.Top;
view.LayoutParameters = frameLayout;
snackBar.Show();
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "xamarin, xamarin.forms, toast, snackbar"
}
|
UIKit controls visible after pushScene in cocos2d
I've got a scene with two UIKit controls: UITextView. But from this scene, user has possibility to go to another scene to check something and come back. After pushScene the UIKit controls are still visible on screen and user can tap on them and edit them.
How can I get rid of them so that they are not visible after pushScene? I don't want to remove one scene and add another, as I want to maintain whatever happened in it, this also means I cannot release the controls and create new ones after user does popScene.
|
When calling pushScene, set the UITextViews as hidden:
myTextView.hidden = YES;
After popping the pushed scene simply unhide the text fields again. While hidden, UIViews don't receive input events but they remain in the view hierarchy.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "uikit, cocos2d iphone"
}
|
Can Ted Cruz and John Kasich still win delegates in upcoming 2016 state primaries?
Ted Cruz and John Kasich, like many Republican candidates before them, have suspended their presidential campaigns this week.
I'm curious about the upcoming state primaries. Will they still be on the ballots? Is it still theoretically possible that they could win additional delegates?
|
Yes, it is possible for any candidate on the ballots of the remaining primaries to gain delegates. In most states, once you are on the ballot, you are on the ballot. It would be too much of a PITA for the states to take them off. Notice that Cruz did not withdraw; he suspended his campaign.
|
stackexchange-politics
|
{
"answer_score": 5,
"question_score": 6,
"tags": "united states, republican primary"
}
|
Is it a bug in the design of a low side UCC27524A, and 2EDN7424 gate driver if it doesn't use VDD capacitor?
I am using low-side TI and Infineon gate drivers.
If I don't use a VDD capacitor, then there is a glitch in the output waveform as shown in the figures. It seems it's the designer's or layout problem but I'm not sure about it.
Can anybody give me a suggestion on what kind of problem it could be a and how to correct it?
^2 + \frac{1}{12n^2}$$
Can someone help me, what should I use for the proof?
|
We can use the three identities $$ \sum_{i=1}^n1=n $$ $$ \sum_{i=1}^ni=\frac{n^2+n}2 $$ $$ \sum_{i=1}^ni^2=\frac{2n^3+3n^2+n}6 $$ to evaluate $$ \begin{align} \frac1n\sum_{i=1}^n\left(\frac{2i-1}{2n}\right)^2 &=\frac1{4n^3}\sum_{i=1}^n(4i^2-4i+1)\\\ &=\frac1{4n^3}\left(\frac{4n^3+6n^2+2n}3-2n^2-2n+n\right)\\\ &=\frac1{4n^3}\frac{4n^3-n}3\\\ &=\frac13-\frac1{12n^2} \end{align} $$ Therefore, $$ \frac1n\sum_{i=1}^n\left(\frac{2i-1}{2n}\right)^2+\frac1{12n^2}=\frac13 $$
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": -1,
"tags": "integration, numerical methods, approximation"
}
|
How can I determine the translator of a wikisource work?
I am considering putting together English/Spanish versions of a few Mark Twain books, such as "The Prince and the Pauper" which can be found here.
However, I need to know who translated it into Spanish from English. How can that be determined? If it is given in the link above, I couldn't find it...
|
First, the work on wikisource is labeled BY-SA. So essentially you are not required to list the translator if republishing.
It is surprising not to have a translator listed. One method may be to try to locate the actual translation to an actual edition. On Google Books, for example, you can browse here.
Another possibility is to search on WorldCat for a physical copy of the book. Even if you don't try to obtain the book, WorldCat might give you metadata about the translator's name.
Some books simply aren't published with the translator's name. (I seem to recall that 1001 Arabian Nights has a public domain version without a translator's name).
For the record, Project Gutenberg doesn't list spanish translations of the book: <
|
stackexchange-ebooks
|
{
"answer_score": 1,
"question_score": 1,
"tags": "translation"
}
|
Linux path for users' shared binaries
I would like to standardize on a directory where normal users would put programs/installs which would be used by other users. What would be the best practices? For instance, I could create a `/users/shared_binaries/` directory with fairly open permissions. Is there a convention/best practice for doing something like this? Assume I don't have any network drive to place them.
Basically, I want a location to share binaries without needing to install in the users' home directory nor have higher access than standard user.
|
There's no standard location for this. The standard way to do things is that you have to be privileged to install a program in a place where other users would run it.
It's your choice between a subtree of `/usr/local` like `/usr/local/users/bin`, a subdirectory of `/home` like `/home/shared/bin`, a subdirectory of `/opt` like `/opt/users/bin`, etc.
Do use path ending in `/bin`. This makes it more evident that it's meant for executable program, and it lets you put other things in sibling directories, such as libraries, documentation and data files used by these programs.
|
stackexchange-unix
|
{
"answer_score": 1,
"question_score": 0,
"tags": "directory structure, non root user"
}
|
Translation: Wear glasses to read
I’m preparing for a written exam at a beginner level and trying to expand a simple sentence, (He) wears glasses:
>
Into: “he wears glasses to read”, as in not all the time.
My first thought was:
>
, but it means, I think: (He) is wearing glasses and reading.
I appreciate the answer might be a bit out of my depth, but it really bothers me now. Please help.
|
The easiest way to say this would be:
>
after is a nominalizer. is a particle that can mark a purpose. So is like "for reading" in English.
You can also say:
> *
> *
>
is another way of saying "in order to" (see this). is "when " (see this). There are small difference in meaning, but I think you can choose which is best in your case.
As you have correctly guessed, " " is a correct Japanese sentence, but it means "He is reading wearing glasses."
|
stackexchange-japanese
|
{
"answer_score": 4,
"question_score": 1,
"tags": "translation, syntax"
}
|
How to play multiple html5 audio files in iOS?
Let's say I have two audio files. I hooked them up with my javascript.
var audio1 = new Audio();
audio1.src = 'file1';
audio1.load();
var audio2 = new Audio();
audio2.src = 'file2';
audio2.load();
when I play audio1 then play audio2, mobile safari (ios) stops audio1 then plays audio2. It only happens with ios safari.
|
As far as I'm aware, this is a design decision from Apple, it'S not possible to play more than one audio file.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "ios, html, audio"
}
|
Load URL by .png from a webview
After I've filtered out the extension inside my webview, ".png". How can I then use the entire link to open a new activity?
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.contains(".png")) {
Toast.makeText(getActivity(), "png clicked", Toast.LENGTH_SHORT).show();
Instead of having my toast, I want to load the URL that was clicked. I'm new to programming in general so I'm not sure the approach.
|
I would really like to know the use case, but assuming that what you want is just to load that PNG in the webview, you could do this:
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.contains(".png")) {
view.loadUrl(url);
}
return true;
}
Kind regards
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "android, url, webview"
}
|
javascript regex .match stop at a certain string
What should I add to this regular expression to stop the search at "/stopHere" and only return what it found up until that string?
var string = "
var reg = string.match(/goodText=.*\/stopHere/);
this captures `["goodText=hello/hello/hello/stopHere"]`, so how would i make it exclude "/stopHere" ?
Thanks!
|
don't know if this is the best way, but found something called a Positive Lookahead:
var string = "
var reg = string.match(/goodText=.*(?=\/stopHere)/);
// returns: goodText=hello/hello/
basically if I put `(?=regex)` at the end, it stops when it finds that!
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 4,
"tags": "javascript, regex"
}
|
Overriding CSS property using jQuery
Suppose I have the following CSS in a linked style sheet:
td {background: -moz-linear-gradient(top, #fbfbfb, #fafafa);}
This makes all my table columns green.
Suppose I have the following table row:
<tr id="myRow"><td>stuff</td><td>more stuff</td></tr>
The whole row is green but following user input I want to do the following:
$("#myRow").children('td').css('backgroundColor', 'red');
Why won't this turn my row from green to red and how can I make that work without adding `!important` to my style sheets?
|
You can try:
$("#myRow").children('td').css('background-color', 'red');
or
$("#myRow").children('td').css('background', 'red');
Also some bizzare things to check if the above won't work:
* Where do you call your jQuery code? (Is it in some function, `$(document).ready()`..?)
* Do you have inline `style` attribute there?
* Do you have any errors caused by previous code? (see debugger - built-in Chrome Dev Tools of FireBug)
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 1,
"tags": "jquery, css"
}
|
GCC #pragma message ignored
I am trying to display a compile-time message in GCC, via
#pragma message "hello world"
But when I compile with `-Wall` it gives the warning
warning: ignoring #pragma message
I'm using GCC 4.2.1 on Mac OS X 10.6.8 (Snow Leopard).
Why isn't it displaying the message? How can I make it display the message?
|
If you read the correct documentation, you'll find that `#pragma message` isn't supported in GCC 4.2.1.
|
stackexchange-stackoverflow
|
{
"answer_score": 15,
"question_score": 10,
"tags": "c++, c, gcc, pragma"
}
|
How to Read Text file as input and write into excel columns using panda?
I am using permission.txt file as intput and want to write data into columns of excel -2007(I am using panda XlsxWriter becasue I want more than 256 columns). I want to write like this into excel file. I have tried following code up to this which writes data in rows instead I want to write data into columns(column 1,column 2......column 400).
import pandas as pd
from pandas import ExcelWriter
from pandas import ExcelFile
import numpy as np
data = pd.read_csv('F:/Research_Work/python/Permission.txt', sep=" ", header=None)
writer = ExcelWriter('Example2.xlsx')
data.to_excel(writer,'Sheet1',index=False)
|
You could just transpose the dataframe data, like this:
import pandas as pd
# Create a Pandas dataframe from some data.
df1 = pd.DataFrame({'Data': [10, 20, 30, 40]})
df2 = df1.T
# Create a Pandas Excel writer using XlsxWriter as the engine.
writer = pd.ExcelWriter('pandas_simple.xlsx', engine='xlsxwriter')
# Write the data in column and transposed (row) directions.
df1.to_excel(writer, sheet_name='Sheet1',
startrow=1, startcol=1, header=False, index=False)
df2.to_excel(writer, sheet_name='Sheet1',
startrow=1, startcol=3, header=False, index=False)
# Close the Pandas Excel writer and output the Excel file.
writer.save()
Output:
;
</script>
how can do it? thank you
|
Read this article in the TinyMCE manual. Use `mode` either with `specific_textareas` or `exact`.
Your initialisation code should look like this:
tinyMCE.init({
...
mode : "specific_textareas",
editor_selector : "YourOwnEditor"
});
...or...
tinyMCE.init({
...
mode : "exact",
elements : "myarea1"
});
...and your HTML could look like this:
<textarea id="myarea1" class="YourOwnEditor">This will be the editor!</textarea>
<textarea id="myarea2">This will not be an editor.</textarea>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, jquery, html, tinymce"
}
|
Responsive Wordpress Gallery
I have been trying to make my Wordpress Gallery responsive with the help from another post: Making WordPress Gallery (.gallery-item) Responsive?
I would also like the original 5-column gallery to display three columns on a tablet. I have used the following css:
/* For displaying 3 columns on tablet */
@media only screen and (max-width: 800px) {
.gallery-columns-5 .gallery-item {
width: 33% !important;
}
}
This works and is now displaying three columns. But it leaves a blank space after every 5th picture. As suggested in the other post i tried
.gallery-columns-5 .gallery-item:nth-child(5n+1) {
clear: none;
}
But this does not seem to work. Does anyone know how to get rid of the blank spaces and still display the page correctly on both tablets and desktops?
The URL for the page is: <
|
You need add some CSS to make it auto clear left after each 3th item and need to hide `<br>` tag
Update your code like this-
/* For displaying 3 columns on tablet */
@media only screen and (max-width: 800px) {
.gallery-columns-5 .gallery-item {
width: 33% !important;
}
.gallery-columns-5 br {
display: none;
}
.gallery-columns-5 .gallery-item:nth-of-type(3n+1) {
clear: left;
}
}
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "gallery, responsive"
}
|
Python List manipulation - couting common instances
I have a ListA = [1,2,3,3,2,1,3,3,1,3]
The 3s are in a sequence of 2,2,1 (2 instances, 2 instances, and 1 instance at the end)
I want to generate a ListB = [2,2,1] from the above ListA
I have code:
ls = [1,2,3,3,2,1,3,3,2,3]
pplist = []
pp = 0
for ii in range(0,len(ls)):
if ls[ii] == 3:
pp += 1
else:
if pp > 0:
pplist.append(pp)
pp = 0
print(pplist)
This gives me [2,2] and for the last element I have to add an additional if-loop. Is there a way to achieve this without having additional code just for the last element?
(ListA could also end with multiple 3s instead of a single 3)
Thank you
R
|
ls = [1,2,3,3,2,1,3,3,2,3]
pplist = []
pp = 0
for ii in range(0,len(ls)):
if ls[ii] == 3:
pp += 1
if ii == len(ls)-1:
pplist.append(pp)
else:
if pp > 0:
pplist.append(pp)
pp = 0
print(pplist)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, list"
}
|
"Valid through 2021" means until when?
If some validity period, say a promotion, specifies "valid through 2021", does that mean until Dec 31, 2021, or Jan 1, 2021?
This is in the USA, if this differs around the world.
|
In normal use, in the US, when "through" is used to refer to a chronological range, it implies that the range extends to the end of the day/month/year stated.
"Sale runs through Friday" implies that it goes until the end of business on Friday.
"Coupon valid through 2021" implies that it goes until the close of business on the last business day of 2021. Since Dec 31, 2021 is a Friday, and not a holiday in the US, this would imply the validity runs through the close of business on Dec 31. (But note that many businesses close early on New Year's Eve.)
|
stackexchange-english
|
{
"answer_score": 1,
"question_score": 0,
"tags": "meaning, phrases, dates"
}
|
Maximum number of pairwise linearly independent vectors
Consider vectors $v_1,\dots,v_n\in\mathbb{R}^d$. My question is: What is the maximum number of such vectors, that are **pairwise** linearly independent?
Clearly, if we remove the word **pairwise** the answer is $d$, but it feels the number is larger. Is this known explicitly?
|
Consider the case $d=2$. Then you have that the vectors $(1,0)$, $(0,1)$ and $(\sqrt{2},\sqrt{2})$ are pairwise linearly independent vectors, for example. Indeed, the set of all vectors of length $1$ (unit circle) consists of pairwise linearly independent vectors (except, of course, those pairs on the same line). Notice that such set is uncountable.
The same argument can be extended to any dimension $d$. Hence, the maximum number is infinity.
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 1,
"tags": "linear algebra, vector spaces, vectors"
}
|
Typescript / Angular drill down property checking
Is there a simple generic way in Typescript/Angular to see if a complete path to a property exists and has a value?
For example Could I have a function like
if (thisExists(aaa.bbb.ccc.ddd)) {
...
}
Where thisExists would determine somehow that it needs to check
if (aaa == null) return false
if (aaa.bbb == null) return false
etc I know from the html perspective there's a ?. operator, but is there something on the typescript side?
|
You can do something like this, which is called `optional chaining`
if (aaa?.bbb?.ccc?.ddd) {
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "angular, typescript"
}
|
How to run Opendds application without test_run.pl perl script?
I am using VS2017,
Eclipse 4.4 modeling SDK, transport is TCP
I created a model and generated code from it, now able to run the application publisher.cpp and subscriber.cpp with test_run.pl Perl file from Opendds GitHub (common Perl file), but as I know this for testing purpose only,
I have pub.exe and sub.exe
how to run them without Perl script?
|
You need to make sure the OpenDDS lib directory is in your PATH, after that you can execute the pub and sub.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "visual studio, ace, opendds"
}
|
An half-open cover has a countable subcover
Let $\mathscr{U}$ consist of half-open interval $[a,b)$ such that $\mathscr{U}$ covers $\mathbb{R}$. Then does there exists a countable subcover for any such $\mathscr{U}$.
I know this is true if we have an open cover and I alway's assumed that this was true for half-open covers, but I can't quite figure out the details.
|
Say $$ \mathscr{U}=\\{[a_i,b_i):i\in I\\} $$ for some (uncountable) set $I$. Let $$ \mathscr{V}=\\{(a_i,b_i):i\in I\\} $$ Put $V:=\bigcup\mathscr{V}$. As $\mathscr{V}$ is an open (in the Euclidean topology of $V$), there exists some countable $\mathscr{V}_0\subset \mathscr{V}$ such that $V\subset \bigcup \mathscr{V}_0$.
We'll be done if we can show that $\mathbb{R}\setminus V$ is countable. Let $x\in\mathbb{R}\setminus V$, so that $x=a_i$ for some $i\in I$. Pick some rational number $q_x\in (x,b_i)$. I claim that $x\mapsto q_x$ is injective. Indeed, suppose $x<y$ and $q_x=q_y$. This implies $y<b_i$, so that $x<y<q_y=q_x<b_i$, whichh gives $y\in (x,b_i)\subset V$, which is a contradiction.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 1,
"tags": "real analysis, general topology"
}
|
How to check if a constraint already exists inside a view?
I'm using auto layout for my tableView and for every cell in it, I create some constraints programmatically.
In order to avoid to delete ALL the constraints every time, I would like to know if there is a way to loop `view.constraints()` and if there is a constraint such as `H:|-view-|`, I delete it.
Is it possible?
|
You would need to use variables (or an array) to hold those constraints that match what you want and then loop the view.constraints() to remove them. When you use the visual format, whatever you create is converted into multiple constraints.
Another method to use is to go through the constraints and check the constraint properties such as firstItem and secondItem, relation, etc. to match what you want.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 5,
"tags": "ios, swift, autolayout"
}
|
how to get values from jsp in ${clue.text}
I define a class of Clue :
Class Clue{
...
String text;
..
getter/setter method
}
I want to get ${clue.text} from jsp to use in the scope "<%...%>" to just show subSequence(0, 10),like this:
<c:forEach items="${clues}" var = "clue">
<tr>
<td>${clue.weibo.user.name}</td>
<td>
<%
String str = ${clue.weibo.text};
%>
<%=str.subSequence(0, 10) %>
</td>
</tr>
</c:forEach>
How can I do?
|
To access A JSTL variable in a scriplet:
<%
String str = (String)pageContext.getAttribute("clue.weibo.text", PageContext.REQUEST_SCOPE);
%>
However, a better way is to use JSTL functions to manipulate the string.
<%@ taglib prefix="fn" uri=" %>
<c:forEach items="${clues}" var = "clue">
<tr>
<td>${clue.weibo.user.name}</td>
<td>
${fn:substring(clue.weibo.text, 0, 10)}
</td>
</tr>
</c:forEach>
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "java, spring, jsp"
}
|
Improper Integrals Comparison Method
I have the Integral: $$\int^\infty_{20}\frac{1}{x\cdot \ln^{15}(x)}\,dx$$ I know that $$\lim_{x\to \infty}(\ln(x)) = \infty$$
Subsequently, I could substitute with $$\ln(x)$$ in the denominator and try to prove that this integral is convergent because $$f(x) > g(x)$$ But it does not seem to be working. Because it seems divergent and could not state the same for a smaller function. Could you suggest another substitution.
|
Hint: The integral $$ \int_{20}^\infty\frac{dx}{x(\ln(x))^{15}} $$ can be rewritten as $$ \lim_{t\rightarrow\infty}\int_{20}^t\frac{dx}{x(\ln(x))^{15}}. $$ Then, use the substitution $u=\ln(x)$ to get that this integral is $$ \lim_{t\rightarrow\infty}\int_{\ln(20)}^{\ln(t)}\frac{du}{u^{15}}. $$
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "calculus, integration, improper integrals"
}
|
Mini puzzle IP header
Look at the following code :
#define IP_HL(ip) (((ip)->ip_vhl) & 0x0f)
#define IP_V(ip) (((ip)->ip_vhl) >> 4)
full code here <
I understand that out of 8 bits in `ip_vhl`:
* `IP_HL` does & operation with 0000 1111, which means that we get the last four bits
* `IP_V` shifts a bit patter to the right by four bits, ehich also give us last four bits...
I checked code and it works fine: it shows 4 for IP Version and 5 for Header size...
How does it return a different number? What is wrong with my understanding?
|
No, `IP_V` shifts a bit pattern to the right by four bits, which give us _first_ four bits (assuming, as you do, that it's an 8-bit value).
In more detail, assume the bit pattern `abcdefgh`:
abcd efgh abcd efgh
& 0000 1111 >> 4
========= =========
0000 efgh 0000 abcd
The `>> 4` operation throws away bits exiting on the right hand side and feeds in `0` bits at the left hand side. Hence, right-shifthing that value a bit at a time would give:
abcd efgh --> direction of shift
0abc defg
00ab cdef
000a bcde
0000 abcd
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c, ip, c preprocessor"
}
|
Add button relative to cell?
I have a workbook with multiple sheets where I have some data in the range `M1:O2`. The width of those three columns can vary from sheet to sheet, but the button should get added to every single sheet without overlapping the data. So instead of using the typical way like this:
`Set btn = ws.Buttons.Add(690, 4, 173.25, 41.25)`
I would like to add the button relative to cell, in my case cell `Q1` or `Q2`. Is that possible? Or can I find out where cell `Q1` is located (i.e. double values for `left` and `top`)?
|
Every range (a cell is a range) has properties like `left` and `top` (and `width` and `height`).
Dim r as Range
set r = ws.range("Q1")
Set btn = ws.Buttons.Add(r.left, r.top, 173.25, 41.25)
' To fit the button exactly into the cell, use:
' Set btn = ws.Buttons.Add(r.left, r.top, r.width, r.height)
' To ensure that the button stays always in the cell, use:
btn.Placement = xlMove
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "excel, vba"
}
|
Do UDP sockets expire?
I want to initialize a socket globally which can be used by sendto to send a udp packet at a later time. Instead of initializing the socket when I'm just about to send the packet, I want to initialize it when the program first starts and then access it later at a different time.
Will this cause issues if the socket is sitting there for hours without being active?
|
It is a OS-specific question.
Speaking of Unix-like operating system, socket is counted as _opened file_ , so the only resource you consuming is entry in open file table, which is usually limited with ulimit:
myaut@panther:~> ulimit -a
...
open files (-n) 1024
Socket will also take small amount of kernel memory for its buffers. But since it is open file, it shouldn't be closed until you close it explicitly, or your program is dead.
Other operating systems probably have similiar limits/requirements.
However since memory nowadays is pretty cheap, keeping pre-opened socket has much more benefits in terms of latency.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "sockets, udp"
}
|
Nativescript - app launch icon shapes on different devices
I used nativescript CLI "tns resources generate icons" command to generate my icons. Everything looks nice, but... not on all devices. When I installed my app on android emulator with this specification:
Device: pixel_xl (Google)
Target: Google APIs (Google Inc.)
Based on: Android API 28
Tag/ABI: google_apis/x86
my app icon looks strange. It seems all icons on this type of device are in circles. My icon is square shaped with background and it's scaled down and put inside this circle with white padding around (which is ugly).
How can I handle this? When I used another tool to generate circle icons everything looks nice, but in this case I have a circle icon on every device. I want a square - is there any chance to achieve this and at the same time have a circle icon on Android version, where all of icons are in circles?
|
Its the adaptive launch icon
> Android 8.0 (API level 26) introduces adaptive launcher icons, which can display a variety of shapes across different device models. For example, an adaptive launcher icon can display a circular shape on one OEM device, and display a squircle on another device. Each device OEM provides a mask, which the system then uses to render all adaptive icons with the same shape. Adaptive launcher icons are also used in shortcuts, the Settings app, sharing dialogs, and the overview screen.
There is an open feature request at Github. If you are interested to use these icons for your app, nStudio had published a blog post that might help you.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "android, icons, nativescript, nativescript vue, nativescript cli"
}
|
Yii - remove smart quotes for all active records
I have an application that allows a user to import/enter information, which gets saved to the MySQL database using a Yii active record, and I have a few users who copy/paste text that has Microsoft smart quotes. This is an issue when the data is parsed on the iPhone implementation of the site, so I need a way to get rid of all the smart quotes everywhere.
I found a php function that will remove these characters from a piece of text, but I was wondering if there is a way in Yii to have the function get called every time text is saved to the database.
|
You can extend `CActiveRecord` overriding beforeSave method in the following manner:
class ActiveRecord extends CActiveRecord
{
protected function removeMagicQuotes($value)
{
return your_function_remove_magic_quotes($value);
}
protected function beforeSave()
{
$attributes = array_keys($this->getAttributes());
foreach ($attributes as $attribute)
$this->$attribute = $this->removeMagicQuotes($this->$attribute);
return parent::beforeSave();
}
}
This one will remove magic quotes for all attributes declared in active record. As an alternative you can override beforeValidate method instead of `beforeSave` to remove quotes just before validation.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "php, activerecord, yii, smart quotes"
}
|
Is it possible to completely disable Grub timeout?
I am setting up a dual boot install for my wife's computer. I would like to disable the timeout for selecting OS that defaults to Ubuntu so the computer wont boot without making a selection. (IE. `GRUB_TIMEOUT=INFINITE`) Is it just a simple case of leaving it blank or `#out` the line in `/etc/default/grub` ? I want it so my wife can choose OS easily on her newly Dual booting PC.
I would also like to know if updating Burg after this would keep the change - as the big graphics of the OS's are a little more noob friendly.
|
Edit `/etc/default/grub` (with root privileges), change `GRUB_TIMEOUT` value from `10` to `-1`, save the file and then run `sudo update-grub`. Reboot and now you have infinite time to choose the OS.
While this works in GRUB, it doesn't work with BURG, and you'll have to change `GRUB_TIMEOUT` value to some large number like `120` seconds to wait before booting into any OS and run `sudo update-burg` to reflect the changes. Also note that this change must be made to file `/etc/default/burg` as BURG doesn't consider options set in `/etc/default/grub`
|
stackexchange-askubuntu
|
{
"answer_score": 25,
"question_score": 19,
"tags": "12.04, grub2, burg, timeout"
}
|
Apache2 -Indexes causes server to fail
I want to prevent Directory listing, in my `/etc/apache2/apache2.conf` I have this:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
And I add the `-` before `Indexes`. When I restart the server I get an error in that line.
I have this version: `Apache/2.4.10` and I have done this before for preventing directory listing without problems, but I don't know why is this happening now.
|
From the documentation: <
> **Note**
>
> Mixing `Options` with a + or - with those without is not valid syntax and will be rejected during server startup by the syntax check with an abort.
So instead of:
Options -Indexes FollowSymLinks
You should use:
Options -Indexes +FollowSymLinks
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "apache, apache2, directory listing"
}
|
Python Selenium - Get url from a listbox instead of clicking it
I want to send search term to a listbox, capture/print the url instead of clicking on it. If there is a better way than using Selenium that would also be acceptable also. Example:
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
import time
#Choose Browser
driver=webdriver.Chrome()
time.sleep(1)
#Go to url
driver.get("
#fill out search field
driver.find_element_by_xpath("""/html/body/div/div/div[1]/div[3]/nav/nav/form/div/div/div/input""").send_keys("eth")
#Select first option from dropdown
listbox = Select(driver.find_element_by_xpath("/html/body/div/div/div[1]/div[3]/nav/nav/form/div/div[2]/ul/li[2]/a/span"))
print(listbox.select_by_index(0)) # I want to print the link instead of clicking it
|
I found that simply entering text in the searchbox did not show the dropdown. Here is a sample of code that will give you the innerHTML of the dropdown. You can modify the xpath to get your specific `li` element or parse it accordingly with BeautifulSoup.
driver.get("
#fill out search field
search_box = driver.find_element_by_xpath("""/html/body/div/div/div[1]/div[3]/nav/nav/form/div/div/div/input""")
search_box.click()
time.sleep(1)
search_box.send_keys("eth")
#Select first option from dropdown
listbox = driver.find_element_by_xpath("//div[@class='cmc-popover__dropdown']")
print(listbox.get_attribute('innerHTML'))
Edit: Also, if the driver instance is not wide enough, the search box won't appear. Consider opening it maximized.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "python, selenium"
}
|
"Increasing" Vs "Additional"
Consider:
> The network suffers from additional users.
I think It declares that if the number of users exceeds a specific number, the network will have to deal with some problems.
I have used the adjective " **additional** " several times. I want to imply the same connotation but, it really bothers me to overuse a word in a piece of writing. I came up with:
> The network suffers from increasing numbers of users.
Can I use **_increasing_** in this context if I have to avoid using adjectives like **_extra_** , **_excessive_** , **_further_**.
* * *
Personal Statement:
I think **_increasing_** would convey the general sense of growth no matter how much this expansion is big. something similar to ever-growing.
|
I think "increasing" works OK. It does suggest something that is growing. It's not precise, though. The network doesn't suffer because the number of users increases; the network suffers because there are too many people using it. I would suggest "ever-increasing" instead. It's a relatively common phrase that's a little stronger than "increasing." It implies the network is _always_ growing -- and therefore is also difficult to maintain. I think it gets to the heart of what you want to say.
|
stackexchange-ell
|
{
"answer_score": 1,
"question_score": 1,
"tags": "meaning in context, word choice"
}
|
Ways to find registration between images?
I am doing image registration
Are there other image-registration methods out there?
|
Computing the regular cross-correlation through multiplying with the complex conjugate in the Fourier domain gives a nice peak that can be localized with sub-pixel precision. To find the location of the peak, fit a parabola to the 3x3 neighborhood of the largest value.
The DIPimage function `findshift` implements this method and a few other ones too. The C++ source code is here if you're interested in seeing how it's implemented.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "matlab, image processing"
}
|
Why can't we usually speak of partial derivatives if the domain is not open?
In the book by Guillemin & Pollack they define a function $f$ from an open subset $U\subset R^n$ to $R^m$ to be smooth if it has continuous partial derivatives of all orders. Then they say "However, when the domain of $f$ is not open, one usually cannot speak of partial derivatives. (Why?)" Can someone explain this a little bit more?
|
The definition of the $i$th partial derivative is really as follows: at a point $x = (x_1,\dots,x_n)$, we say $$ \left.\frac{\partial f}{\partial x_i}\right|_{x} = \lim_{t \to 0} \frac{f(x_1,\dots,x_{i-1},x_i+t,x_{i+1},\dots,x_n) - f(x_1,\dots,x_{i-1},x_i,x_{i+1},\dots,x_n)}{t} $$
However, in order for this limit to make sense, $f$ needs to be defined over $x + t(0,\dots,0,1,0,\dots,0)$ for $t$ such that $|t|$ is small enough. That is, $x + t(0,\dots,0,1,0,\dots,0)$ needs to be in $U$ for $t$ close enough to $0$.
One way to guarantee that this definition will make sense for every point $x \in U$ is to say that for each $x$, there is some $t$ so that the "cube" $$ (x_1-t,x_1+t) \times \cdots \times (x_n - t, x_n + t) $$ is contained in $U$. That is, as long as $U$ is open, we can talk about partial derivatives at every point.
|
stackexchange-math
|
{
"answer_score": 11,
"question_score": 14,
"tags": "multivariable calculus, differential geometry, differential topology"
}
|
Creation of Magnetic Monopoles using Black Holes
If a very long bar magnet is made and is allowed to free fall in a black hole, a point will come when exactly the north pole is inside and south pole is outside the event horizon for a very small amount of time. At that point of time, the magnetic field lines from north pole must not travel outside the event horizon to the south pole and the south pole outside must behave like a monopole. Is this thinking perspective correct?
|
> At that point of time, the magnetic field lines from north pole must not travel outside the event horizon to the south pole and the south pole outside must behave like a monopole. Is this thinking perspective correct?
No, that is not correct. The magnetic field lines are not causal lines. They can be spacelike and thus go out of an event horizon.
What cannot travel outside the event horizon is changes in the magnetic field, that is electromagnetic waves. In fact, a black hole can be charged and spinning in which case the black hole itself will produce an electromagnetic field, just not a wave.
|
stackexchange-physics
|
{
"answer_score": 6,
"question_score": 2,
"tags": "black holes, event horizon, magnetic monopoles"
}
|
How do i formally show that the vectors are in a subspace?
Let $A = \\{(a, b, c) \in \mathbb{R}^3 : 3a − 2b + 7c = 0\\}$.
Clearly $(0,0,0) \in A$ since $3(0) -2(0) + 7(c) = 0$.
I understand the concept of showing that the set is closed under addition and closed under scalar multiplication but am a bit unsure how to formally show it.
So, if we let $\overrightarrow{u} = (a,b,c)$ and $\lambda \in \mathbb{R}$ then we can write: $\lambda\overrightarrow{u} = (\lambda a, \lambda b, \lambda c)$ so $3\lambda a - 2 \lambda b +7 \lambda c = \lambda (3a-2b+7c) = 0$ which is true since $\overrightarrow{u} \in A$ i.e. $3a-2b+7c=0$. Is this sufficient proof?
To show it is closed under addition I am unsure however...
Let $\overrightarrow{u} = (a_1,b_1,c_1)$ and $\overrightarrow{v} = (a_2,b_2,c_2)$. Then $\overrightarrow{u} + \overrightarrow{v} = (a_1 +a_2, b_1+b_2, c_1+c_2)$. How do I show that this vector is now in the subspace?
|
Since $\overrightarrow{u} = (a_1,b_1,c_1) \in A$ and $\overrightarrow{v} = (a_2,b_2,c_2) \in A$ we have $3a_1-2b_1+7c_1 = 0$ and $3a_2-2b_2+7c_2 = 0.$
For $\overrightarrow{u}+\overrightarrow{v} = (a_1+a_2,b_1+b_2,c_1+c_2)$ we test for membership in $A$ by computing
$$3(a_1+a_2)-2(b_1+b_2)+7(c_1+c_2) = (3a_1-2b_1+7c_1)+(3a_2-2b_2+7c_2) = 0+0=0.$$
Therefore we do indeed have $\overrightarrow{u}+\overrightarrow{v} \in A$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "linear algebra"
}
|
select2 - hiding the search box
For my more significant selects, the search box in Select2 is wonderful. However, in one instance, I have a simple selection of 4 hard-coded choices. In this case, the search box is superfluous and looks a little silly being present. Is it possible to hide it somehow? I took a look through the documentation online and couldn't find any options for this in the constructor.
I could, of course, just use a regular HTML select, but for consistency, I'd like to use Select2 if possible.
|
See this thread < you can hide the search box by setting minimumResultsForSearch to a negative value.
$('select').select2({
minimumResultsForSearch: -1
});
|
stackexchange-stackoverflow
|
{
"answer_score": 545,
"question_score": 243,
"tags": "jquery, jquery select2"
}
|
jq - How do I print a parent value of an object when I am already deep into the object's children?
Say I have the following JSON, stored in my variable _jsonVariable_.
{
"id": 1,
"details": {
"username": "jamesbrown",
"name": "James Brown"
}
}
I parse this JSON with jq using the following:
echo $jsonVariable | jq '.details.name | select(.name == "James Brown")'
This would give me the output
_James Brown_
But what if I want to get the id of this person as well? Now, I'm aware this is a rough and simple example - the program I'm working with at the moment is 5 or 6 levels deep with many different JQ functions other than select. I need a way to select a parent's field when I am already 5 or 6 layers deep after carrying out various methods of filtering.
Can anyone help? Is there any way of 'going in reverse', back up to the parent? (Not sure if I'm making sense!)
|
For a more generic approach, save the value of the "parent" element at the detail level you want, then pipe it at the end of your filter:
`jq '. as $parent | .details.name | select(. == "James Brown") | $parent'`
Of course, for the trivial case you expose, you could omit this entirely:
`jq 'select(.details.name == "James Brown")'`
Also, consider that if your selecting filters return many matches for a single parent object, you will receive a copy of the parent object for each match. You may wish to make sure your select filters only return one element at the parent level by wrapping all matches below parent level into an array, or to deduplicate the final result with `unique`.
|
stackexchange-stackoverflow
|
{
"answer_score": 94,
"question_score": 61,
"tags": "json, jq"
}
|
htacess redirect all pages to www except checkout page
I have a website with ssl which works on only the non www version. Is it possible to redirect all url to www version except the checkout page using htacess and to add the https:// on the checkout page
Thanks
|
Say your checkout page is at `
Try:
RewriteEngine On
# redirect non-www hostname to www hostname, but not /checkout.php
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule !^/?checkout.php [L,R=301]
# if checkout.php, redirect if not HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^/?checkout.php [L,R=301]
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "regex, .htaccess"
}
|
Probability of collision in linear hashing?
Take an $u × m$ matrix $A$ filled with random bits(0,1). Given a non-zero vector $x$ in $\\{0,1\\}^u$, what is the probability that $x$ is in null space of $A$. All calculations are done modulo 2. Source of randomness is selection of $A$ from $2^{um}$ choices.
|
If $x$ is in the nullspace of $A$, then all the coordinates of $Ax$ are equal to $0$, ie for any $i \in \\{1, \dots, u\\}$: $\displaystyle\sum_{k=0}^m a_{ik} x_k = 0$.
Now, all $a_{ik}$ and all $x_k$ are uniformly random, so you can deduce the distribution of the product $a_{ik}x_k$. Then, in modulo 2, the sum can be found by computing how many terms of the sum are nonzero.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "linear algebra, probability, hash function"
}
|
Charts showing on the same line in non-IE browsers, but on the next line on IE browsers
Here is the exact code you can try for yourself:
<
When I render this in IE, each chart shows in a different line. When I render it in any other browser except for IE, charts show on the same line like in-line elements.
What is going on? What is the reason for this? Is there any fix ?
|
for me all are loading in the inline fashion the reason ? Because SVG has inline property associated by the USER AGENT of the browser . I am not sure which IE browser you used , but I am using IE 10.0 , chrome and firefox also the latest . EVERYTHING displays it INLINE .
ps: SVG doesn't work properly for IE less than 8
FIX : try reducing height and width of the svg using CSS . It might be pushed to next line for some reason.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, css, svg, d3.js"
}
|
Regex (C#): Replace \n with \r\n
How can I replace lone instances of \n with \r\n (LF alone with CRLF) using a regular expression in C#?
I know to do it using plan `String.Replace`, like:
myStr.Replace("\n", "\r\n");
myStr.Replace("\r\r\n", "\r\n");
However, this is inelegant, and would destroy any "\r+\r\n" already in the text (although they are not likely to exist).
|
Will this do?
[^\r]\n
Basically it matches a '\n' that is preceded with a character that is not '\r'.
If you want it to detect lines that start with just a single '\n' as well, then try
([^\r]|$)\n
Which says that it should match a '\n' but only those that is the first character of a line or those that are _not_ preceded with '\r'
There might be special cases to check since you're messing with the definition of lines itself the '$' might not work too well. But I think you should get the idea.
**EDIT:** credit @Kibbee Using look-ahead s is clearly better since it won't capture the matched preceding character and should help with any edge cases as well. So here's a better regex + the code becomes:
myStr = Regex.Replace(myStr, "(?<!\r)\n", "\r\n");
|
stackexchange-stackoverflow
|
{
"answer_score": 46,
"question_score": 44,
"tags": "c#, regex"
}
|
Can I use my old Sony Camera's Night Shot to detect shorts?
I have an old Sony TRV-14 with a built-in night shot mode for shooting videos in the dark. It is my understanding it works by using sensing infrared radiation which is also how thermal imaging cameras work. Unlike thermal imaging cameras, the images produces by my camera are in gray scale instead of color.
Is it possible to use my camera in some capacity for detecting shorts or overheating components? I figure hot areas would appear lighter and the cooler areas would appear darker. Am I correct?
|
Thermal radiation is still an electromagnetic radiation and the wavelength range of thermal radiation covers the IR area.
Your camera's sensor might be able to pick up IR signals just like an I² NV (Infrared-Illuminated Night Vision) so you would expect to detect (or distinguish) heat radiation. However, due to the limitations of your camera's sensor (sensitivity, contrast etc) it's unlikely possible.
> Unlike thermal imaging cameras, the images produces by my camera are in gray scale instead of color.
That's because thermal cameras have special sensors and these cameras **process** the incoming signals from those sensors to generate the heat difference maps.
**Here's a practical test:** A human body generates and radiates its own heat and it's not really low. If your camera can visualize this then yes, you can use your camera for heat detection.
Maybe, your camera can be used to detect very high temperatures such as 200+ °C.
|
stackexchange-electronics
|
{
"answer_score": 2,
"question_score": 2,
"tags": "infrared, camera, image sensor, thermal camera"
}
|
$f(x)=(\sin(\tan^{-1}x)+\sin(\cot^{-1}x))^2-1, |x|>1$
> Let $f(x)=(\sin(\tan^{-1}x)+\sin(\cot^{-1}x))^2-1, |x|>1$. If $\frac{dy}{dx}=\frac12\frac d{dx}(\sin^{-1}(f(x)))$ and $y(\sqrt3)=\frac{\pi}{6}$, then $y(-\sqrt3)=?$
$$f(x)=(\frac{x}{\sqrt{x^2+1}}+\frac{1}{\sqrt{x^2+1}})^2-1=\frac{2x}{1+x^2}$$ $$\frac{dy}{dx}=\frac12\frac d{dx}(\sin^{-1}(\sin(2\tan^{-1}x)))$$ $$y=\tan^{-1}x+c$$ Using, $y(\sqrt3)=\frac{\pi}{6}$, I get, $c=-\frac\pi6$. Thus, $y(-\sqrt3)=-\frac\pi2$. But the answer is given as $\frac{5\pi}6$.
|
$\sin(\cot^{-1}x)=\sin\left(\dfrac\pi2-\tan^{-1}x\right)=\cos(\tan^{-1}x)$
$$\implies f(x)=\left(\sin(\tan^{-1}x)+\sin(\cot^{-1}x)\right)^2-1=\sin2\left(\tan^{-1}x\right)$$
Now $\sin^{-1}\left(\sin(2\tan^{-1}x )\right)=\begin{cases} \pi-2\tan^{-1}x &\mbox{if } 2\tan^{-1}x>\dfrac\pi2\iff x>\tan\dfrac\pi4 \\\ -\pi-2\tan^{-1}x& \mbox{if } 2\tan^{-1}x<-\dfrac\pi2 \end{cases}$
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "trigonometry, inverse function"
}
|
Database connection using jquery mobile
iam very new to mobile jquery mobile app development.How can i connect to my database which is in godaddy and retrieve datas from one of the table and display it in tabular form in mobile.suppose databse name is funky,table name is funk_tab.so if any one can give the code for this specific problem? thank you... note:table in mobile should be scrollable as i have 10 to 11 columns in the table.
|
**Jquery mobile is client side language , you cannot connect to database directly from client side langauge**
You need to have page which will return json/xml result from database. Then you can parse that reponse via jquery.
Example
## php
$sql="select name,id from tbl";
$res=mysql_query($sql);
while($row=mysql_fetch_array($res)){
$arr=array("name"=>$name);
}
echo $json=json_encode($arr);
**javascript**
var obj = jQuery.parseJSON( '{ "name": "John" }' );
alert( obj.name === "John" );
you can look the link below to parse json and show it on table
Display JSON Data in HTML Table
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "jquery, jquery mobile, mobile"
}
|
Extracting first rows of .csv files into a single new .csv file
I have over 1000 .csv files in a folder on Debian Squeeze. I am trying to create a new .csv file containing ONLY the first rows of each of these 1000 .csv files.
I tried:
read -r firstline < sourcefile_1.csv > headers.csv
But that only created a blank file. (And even if it did work, I would have copied only the first row of just one file.)
How do I write a command that copies the first rows of all 1000 files in the folder and add it to the new .csv file?
Thanks in advance!
|
`head -q -n 1 *.csv > output.csv`
`-q` supresses the headers that normally get printed, `-n 1` prints only the first line
|
stackexchange-unix
|
{
"answer_score": 8,
"question_score": 2,
"tags": "debian, csv"
}
|
Is there a better way to implement search map?
I have a map of objects `Members`
public class Member {
int id;
String firstName;
String lastName;
String street;
String city;
...
with `id` as a key, which is doing job for me and I don't want to change structure of the map.
I need to implement **search by name** functionality. So far I can think only about 2 solutions:
1st is to iterate trough the map - not most time efficient way
2nd is to create another map with member's names as a keys and ids as values as reference to my main map and search trough this map to find the key - efficient with time but less in space, which not worry me too much
I want to ask if there is more efficient (better) way to implement search of map in my case?
|
There's no point in creating a second Map if it would require 2 lookups (first find the id for a given name and then find the `Member` of that id).
It would be more efficient if the second Map would map the name keys to the `Member` values (i.e `Map<String,Member>`). You might be thinking that such an approach would require more memory compared to a `Map<String,Integer>`, but you would be wrong. A reference to a `Member` instance takes the same amount of memory as a reference to an `Integer` instance. Just because you have two `Map`s that contain the same values, doesn't mean that the `Member` instances need to be duplicated. Only the references to those isntance would be duplicated.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "java, dictionary, collections"
}
|
living web page elements
I have a simple rails app with a model `Task`, which has 10 rows. It does not matter what's inside this table. On the `index` page I can see all 10 elements and I need to arrange them in proper sequence, when I did this, I should see a message "Done".
If I understand correctly this should be implemented in javascript, because page should not be reloaded, right?
I want to be able to rearrange the elements via drag and drop.
How I can realize that function?
|
I would start with here -> <
You can sort and its quite simple as there great examples on the site how to do this and hook into events.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, ruby on rails"
}
|
Logistic vs Cox PH model : different hypothesis for a single case
Let's say I'm interested in comparing the apparition of an event in 2 groups.
I could take the problem by 2 ways :
* consider the dates and compute a Cox PH model.
* consider only the proportion of event and perform a logistic regression.
I have the feeling that there is no "good" option here and that those cases answer to different problematics (and so I could perform both to answer those).
The problem is I'm not 100% sure of what is the exact difference between those problematics : null hypothesis in Cox model is that Hazard Ratio is 1 (so there is no association between risks and group), whereas null hypothesis in Logistic regression is that there is no association between apparition of the event and group).
I see there is a difference, but I cannot seem to find a crystal clear explanation of it. **What is the exact difference between these two hypothesis ?**
|
As I detail in my book _Regression Modeling Strategies_ , a binary model should only be used if (1) time to event is not important and (2) every subject who did not suffer the event of interest was followed the same length of time. The logistic model estimates the odds ratio for a risk factor in predicting occurrence of an event; the Cox model estimates a hazard ratio, which is the ratio of instantaneous event rates at a given time point. The hazard ratio is also the number such that you raise the survival curve to a power to get between risk factor levels. Study hazard functions to learn more.
Interestingly, both the binary logistic model and the Cox model were developed by D.R. Cox.
If follow-up (censoring) times vary or you want to distinguish between early and late events (you usually do) then the Cox model or another time-to-event model is for you.
|
stackexchange-stats
|
{
"answer_score": 2,
"question_score": 4,
"tags": "hypothesis testing, logistic, survival, cox model"
}
|
get values from HorizontalPicker
I'm using blazSolar's HorizontalPicker from this, how do I get values from item/number that I picked
|
If you have checked example provided with that library, it is given clearly how to get click events in it. This the code from example itself
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
HorizontalPicker picker = (HorizontalPicker) findViewById(R.id.picker);
picker.setOnItemClickedListener(this);
picker.setOnItemSelectedListener(this);
}
@Override
public void onItemSelected(int index) {
Toast.makeText(this, "Item selected", Toast.LENGTH_SHORT).show();
}
@Override
public void onItemClicked(int index) {
Toast.makeText(this, "Item clicked", Toast.LENGTH_SHORT).show();
}
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": -1,
"tags": "android"
}
|
django Built-in template tags and filter Cut command not removing second space
My `database` stored phone numbers as "(123) 456-7890 " I need to remove all spaces from a phone number so that I can make calls via Cisco phone.
`<td><a href="ciscotel:1{{contact.Phone|cut:" "}}" target="_self">{{` contact.Phone | cut:" "}}</a></td>
But django is displaying html as:
<a href="ciscotel:1(123)456-7890 " target="_self">(123)456-7890 </a>
I tried :
{{contact.Phone|cut:"("|cut:")"|cut:"-"|cut:" "}}
and
{{contact.Phone|cut:"("|cut:" "|cut:" "}}
The documentation makes it seem like one cut function should clear both spaces.
Thanks
|
Maybe there's another white character at the end? I'd recommend using `spaceless` tag. According to docs, it:
> removes whitespace between HTML tags. This includes tab characters and newlines.
{% spaceless %}{{contact.Phone|cut:"("|cut:")"|cut:"-"|cut:" "}{% endspaceless %}
**Edit:** as pointed by @iklinac in the comments below `|cut:" "` is still needed as `spaceless` is not allowed to modify variables you passed to the template.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, html, django"
}
|
Loading SSE registers
I'm working on homework project for OS development class. One task is to save context of SSE registers upon interrupt. Now, saving and restoring context is easy (fxsave/fxsave). But I have problem with testing. I want to put same sample date into one of registers, but all I get is error interrupt 6. Here is code:
// load some SSE registers
struct Vec4 {
int x, y, z, w;
} vec = { 0, 1, 2, 3 };
asm volatile ( "movl %0, %%eax"
: /* no output */
: "r"( &vec )
:
);
asm volatile ( "movups (%eax), %xmm0" );
I searched on internet for solution. All I got is that it might something to do with effective address space. But I don't know what it is.
|
I found out what is problem. Execution of SSE instructions must be enabled by setting some flags in CR0 and CR4 registers. More info here: <
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "gcc, assembly, sse, osdev"
}
|
Guitar Pedal Simulator with LtSpice
I'm trying to simulate a guitar pedal with LtSpice. Do you know how I can input a guitar recording to the circuit? I will then convert the output to a txt to listen to it from Matlab sound function.
|
Wave files can be imported directly.
1. Copy the .wav file to the directory of the project
2. For the voltage source that you want to output the wav file, ctrl+click and edit the value field
The value should say `wavefile=file.wav` (where file is the file name)
Source:
<
|
stackexchange-electronics
|
{
"answer_score": 4,
"question_score": 1,
"tags": "analog, ltspice"
}
|
Dynamic class for Html element breaking at space
On my ASP .Net project I have created the following function on a view (Razor):
@functions{
public string GetClassFromLevel_Global(decimal level)
{
return level >= Model.global_limit ? "progress-bar progress-bar-success" : "";
}
}
And then I use it like this:
<div class=@GetClassFromLevel_Global(total.Value) ...></div>
What I get in return:
<div class="progress-bar" progress-bar-success="" role="progressbar" aria-valuenow="1" aria-valuemin="0" aria-valuemax="100" style="width:100%"></div>
For some reason the returned string breaks at the space, how can I fix this?
|
Line breaks shouldn't be an issue in a well formed HTML. However, your Razor syntax is problematic:
<div class=@GetClassFromLevel_Global(total.Value) ...></div>
Will generate this html:
<div class=progress-bar progress-bar-success ...></div>
The first element `progress-bar` will be parsed as the value of the `class` attribute where as `progress-bar-success` will be parsed as an attribute with no value. I suspect the output you are giving in your questions is copied from a browser developpers tool HTML inspection. If you quote the function call, you will get the expected result:
<div class="@GetClassFromLevel_Global(total.Value)" ...></div>
Will generate:
<div class="progress-bar progress-bar-success" ...></div>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "html, asp.net, razor, twitter bootstrap 3"
}
|
redirect back two steps codeigniter
In codeingiter I have certain forms that when you submit it will then redirect back to the previous page using this.
redirect($_SERVER['HTTP_REFERER']);
I'm just wondering if there is a way to redirect back two steps for forms that have an actual page where they are editing information.
|
I don't think there is a server var that holds more than just the last URL. You'd need to store the URL's (either in a cookie, in the query-string, or in a server var) and then just redirect back as far as you'd want.
CodeIgniter Example: <
You could also use Javascript:
window.location.history.go(-2)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "codeigniter, redirect"
}
|
Pushing Stack Exchange Profile To Other Accounts
My global stack exchange profile is the way I want it. Can I push this profile to my other accounts?
|
Your global Stack Exchange site is not editable, and it is taken from the oldest Stack Exchange account you have. In my case, that is _Stack Overflow_ ; in your case, it is Programmers.
!screenshot
Just edit your oldest account, which is the one indicated in your global Stack Exchange account, and push those changes to your other accounts.
Anyway, you didn't put information that is visible to other users, in your account. None of your accounts shows anything different from the other ones.
|
stackexchange-meta
|
{
"answer_score": 5,
"question_score": 2,
"tags": "support, linked accounts"
}
|
Can git break up changes by default?
I like to use the `-p` flag on several git commands, such as `add`, `reset`, `checkout`, and `stash`. But git groups somewhat contiguous changes together in the same hunk. I know that `s` breaks up the changes but is there another option I could pass to have git break them up by default wherever possible?
|
There are no command line options to accomplish what you want, nor is there a config option. If there were a config option, I would expect to see it in the `git-config` documentation alongside the **interactive.singlekey** option.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "git, git checkout, git stash, git add, git patch"
}
|
Restricting function template types in Visual Studio 2012
Is there any way in Visual Studio 2012 to restrict function templates to specific types?
This one works in GCC, but MSVC generates `error C4519: default template arguments are only allowed on a class template`.
#include <type_traits>
template <class float_t, class = typename std::enable_if< std::is_floating_point<float_t>::value >::type>
inline float_t floor(float_t x)
{
float_t result;
//...
return result;
}
A cross compiler solution would be the best. Any alternative?
|
Normally, you would write this as
template <class float_t>
typename std::enable_if< std::is_floating_point<float_t>::value, float_t>::type
floor(float_x x) {...}
That's how `enable_if` is intended to be used.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 3,
"tags": "c++, visual c++, visual studio 2012, c++11"
}
|
How to display data labels in Illustrator graph function (pie graph)?
I am trying to make a pie graph that has both the data labels (e.g. 33%) _and_ the series name (e.g. "apples"). Here is an example below.
.HttpContext.User);
This feels kind of weird injecting it, however it is better than storing it in the `CallContext`.
|
stackexchange-stackoverflow
|
{
"answer_score": 63,
"question_score": 34,
"tags": "asp.net, .net"
}
|
Running NodeJS code in Tizen Studio?
Is there any way to run the server-side `nodeJS` code in `Tizen-studio` ? I need to use the `dns` module of nodeJS and I can't get to use `require.js` for using the `dns` module in my client-side javascript code ? So, can someone suggest how to use a `node` module using `require.js` ?
|
This Tutorial may help you to create and running NodeJS application on Tizen. Also follow this thread.
$ is isomorph to $N_G(H)/H$
If X is a G-set, an automorphism $G$-invariant is a map $f:X \to X$ such that $f(g*x)=g*f(x)$
I need to prove that $N_G(H)/H$ is isomorphic to $G$-automorphism invariants of $G/H$
I tried with two natural maps:
1. The map such that $\phi(gH)=f_{gH}$ where $f_{gH}(g'H)=(g'g)H$, but this map isn't homomorphish, and
2. $\phi(gH)=f_{gH}$ where $f_{gH}(g'H)= (gg'g^-1)H$, but this map isn't $G$-invariant.
please, can you give me some ideas?
|
The map $\phi\colon N_G(H)\to\operatorname{Aut}_G(G/H)$ defined by $\phi(g)(g'H)=g'g^{-1}H$ is well defined as $g\in N_G(H)$, and $$ \phi(g)(g'H)=g'g^{-1}H=g'\phi(g)(H) $$ and $$ \phi(gk)(g'H)=g'(gk)^{-1}H=g'k^{-1}g^{-1}H=\phi(g)(g'k^{-1}H)=\phi(g)\circ\phi(k)(g'H). $$ This implies $\phi(g)\phi(g^{-1})=\phi(e)=1_{\operatorname{Aut}_G(G/H))}$. So $\phi$ is a group homomorphism, and each $\phi(g)$ is an $G$-invariant automorphism of $G/H$.
It is surjective, because a $G$-invariant automorphism is determined by its image on $H$. So if $f(H)=kH$, then $f=\phi(k^{-1})$, as $\phi(k^{-1})(H)=kH=f(H)$. Also, $\phi(g)$ is the identity if it fixes $H$, that is, if $g^{-1}H=H$, i.e., iff $g\in H$. Thus $\ker(\phi)=H$. So by the first isomorphism, $\phi$ descends to an isomorphism $N_G(H)/H\simeq\operatorname{Aut}_G(G/H)$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "abstract algebra, group theory, automorphism group"
}
|
IBM DB2: Order by day
I have a column in my database that lists the days in the format "Monday", "Tuesday", etc:
Is there a way to order my result queries so that I get the result with Monday first, then Tuesday, then Wednesday, then Thursday and so on?
I checked a couple of answers but using case in order by doesn't seem to work.
Thanks in advance.
EDIT: I'm using this in a cursor in C
|
Probably the simplest method is a `case` expression:
order by (case dow
when 'Monday' then 1
when 'Tuesday' then 2
when 'Wednesday' then 3
when 'Thursday' then 4
when 'Friday' then 5
when 'Saturday' then 6
when 'Sunday' then 7
end)
You can shorted this using `locate()`, if you like:
order by locate(dow, 'Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday')
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "sql, db2"
}
|
caching plots in R/Shiny
Just wondering if there are tricks/ways in which I could cache the plots being generated through our shiny app.
_Background:_
We are doing somewhat compute intensive computations which finally result in a plot. I am already caching(using memoise) the computations done, globally in shiny but it still takes about .75 seconds to render a plot. I was just wondering if we can decrease that time by removing the time it takes to render an image and if there are slick ways of already doing it.
_More details:_
I am using grid to create the plot(heatmap in this case. Ideally would like the caching to be disk based as storing plots in memory wont scale up.
Thanks! -Abhi
|
Assuming you are using `ggplot` (which with Shiny, I would bet is a fair assumption).
1. Create an empty list to store your grob, say `Plist`.
2. When a user request a graph, create a string hash based on the shiny inputs
3. Check if the graph is already saved, eg `hash %in% names(Plist)`
4. If yes, serve up that graph
5. If no, generate the graph, save the grob to the list, name the element by the hash, eg, `Plist[hash] <- new_graph`
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 12,
"tags": "r, shiny, shiny server"
}
|
Will editing a title of the question result in a broken link?
If I was to edit the title of a question and someone was to accept the edit, would the question link become broken? Or would it redirect to the new link?
I haven't tried it myself.
|
`
|
stackexchange-meta
|
{
"answer_score": 9,
"question_score": 6,
"tags": "support, edits, hyperlinks, title"
}
|
A weaker condition than Lagrangian for groups
If $ G $ is a group that possesses the property that for every divisor $ n $ of $ |G| $, $ G $ contains a subgroup of order $ n $, then $ G $ is called a Lagrangian or CLT group.
But what about this property: whenever $ |G| = mn $ where $ m $ and $ n $ are coprime, then $ G $ contains a subgroup of order $ n $. Does this concept have a name? And is there a systematic way to figure out, for any given group (say $ A_5 $), whether it has this property or not?
|
These groups are called solvable.
Of course, being solvable is usually defined as having all composition factors be abelian, but it is a result of Hall that this is equivalent to your condition.
Such subgroups (i.e. ones whose order and index are coprime) are called Hall subgroups.
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 2,
"tags": "group theory"
}
|
How to argue with postdoc hired for a project, to work on tasks from another project
I have one postdoc hired on a H2020 project for 18 months. Fortunately, she worked rather well and all her tasks are going to finish soon (11th month of the project). I would like to reallocate her to other projects my group is working on now, and which fall a bit outside of the initial H2020 project, but in any case, she has the competence and capabilities to move to the other projects. I briefly talked her about this and she says it would be unethical and illegal to work on something she has not initially hired for. I think that even if these new tasks are not directly related to the H2020 project, if she works on them and gets new publications, it would be a clear benefit for her, and I told her, but she continues to refuse to work on them. How would you argue with her to move to the other tasks when the H2020 tasks are finished?
|
You can switch her to another project if you have the funding for it. What you cannot do is to have her work paid by one H2020 project to carry out work for some other separate project. If that's what your postdoc says, she is right.
However, even in your existing project, there should be sufficient leeway to do work on good publications, research etc. and improve the work that you have carried out on the core project. Research never stops.
Alternatively, if you have funding for another project, then you can ask for the budgets to be reassigned ( **Edit:** if she agrees) so that she is paid through the budget of the other project. That's perfectly acceptable, albeit you may have to return some of the budget of the original project she was hired for if that is not used in its entirety.
What you cannot do is to have the original project budget pay for work carried out on another project.
|
stackexchange-academia
|
{
"answer_score": 35,
"question_score": 13,
"tags": "projects, contract, research group"
}
|
Can't get Python SUDS to query a code with this WSDL
I am not getting a result when I run this. Somehow, I think I should be getting something other than 'nothing' when I query a valid HCPCS code (the 99213 code in the 4th line below). Not sure what I am doing wrong.
My code:
from suds.client import Client
url = "
client = Client(url)
print client
result = client.service.GetDetailsByCode('99213')
print result
**Question:** How can I get this to work? According to this site, 99213 is a valid HCPCS code, but I cannot get the description or any other details from the web service using this code. Help!
|
The code works fine. It returns a class. Put in T1000 instead of 99213 and you'll see what I mean.
HCPCS codes overlap with CPT codes, except HCPCS are used by Medicare (CPT tend to be used by private insurance). It appears this WSDL only returns values for valid HCPCS Level 2 codes. A more precise definition of HCPCS Level 2 codes can be found here. A general definition of HCPCS codes and their relationship with CPT codes can be found here.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "python, soap, wsdl, suds"
}
|
ggplot2 + scatterplot + geom_path
Do you know how to get the curved effect Jake Kaupp achieves on his plot?
) +
geom_xspline2(aes(s_open = TRUE, s_shape = 0.5))
Where `geom_xspline2()` comes from `library(ggalt)`
But don't ask me, here is his source code:
<
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "r, ggplot2, scatter plot"
}
|
jquery selectors
I need to select a class in my javascript and change one of its property. but since that class is being used with different divs, I need to change the property of the class I hover upon only and not the other ones. is that possible?
the html structure looks like this:
<div class="home_linkbox_href"><a href=""><div class="home_linkbox">
<h1>/h1>
<h2></h2>
</div></a></div>
the javascript:
$(".home_linkbox_href a").hover(function(){
//alert("u did it...");
$(".home_linkbox_href a .home_linkbox").css("background-color", "#ffe500");
},
function(){
$(".home_linkbox").css("background-color", "#000");
});
can someone help?
|
You can specify `this` as the context for the selector, which will find matches only in the currently hovered element:
$(".home_linkbox_href a").hover(function(){
//alert("u did it...");
$(".home_linkbox", this).css("background-color", "#ffe500");
},
function(){
$(".home_linkbox", this).css("background-color", "#000");
});
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "javascript, jquery, html, css"
}
|
Change camera aperture for PhotoCaptureDevice
# Context
I was looking at the PhotoCaptureDevice class in the Windows Phone 8 API docs and noticed that there's no property for setting the camera aperture on the device. I can specify a lot of other properties, such as EV compensation and white balance, but not the aperture.
# Question
Is it correct to assume that the cameras in Windows Phone 8 devices can't have their aperture changed? And more importantly, does this mean it's controlled automatically or do all pictures have the same aperture setting?
|
All the current Windows Phone cameras have a fixed camera aperture as far as I know, so this isn't possible.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "c#, windows phone 8"
}
|
.NET custom Json converter for list or single item
my goal is to use `System.text.Json` to parse a response from the rest api. The response returns one or more items - but if only one item is returned, there are no brackets `[]` surrounding it (which makes it hard to parse).
**The deserialization:**
// i need a list here to process data
var response = JsonSeralizer.Deseralize<IList<ExampleResponse>>(content);
**Example response 1:**
[
{
"Status": "Healthy"
},
{
"Status": "Healthy"
}
]
**Example response 2:**
{
"Status": "Healthy"
}
How can i write a custom converter using `JsonConverter<T>`, which can parse a single item or an entire list?
|
One option is to create a custom converter (inherit from JsonConverter)
Though with this case I would've probably just wrote
var isList = content.StartsWith("[");
var response = isList ? JsonSeralizer.Deseralize<IList<ExampleResponse>>(content)
: new IList<ExampleResponse> { JsonSeralizer.Deseralize<ExampleResponse>(content) };
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c#, json, .net core, serialization, system.text.json"
}
|
NSPredicate MATCHES anything but numbers
I have an array of data from which I would like to extract rows containing numbers and numbers only. Examples on rows:
15, +2, ' ', 7, 9, +21
(The ' ' represents one or more whitespaces).
In this case I would like to extract only 15, 7 and 9. I use a predicate in the following way:
NSString *pattern = @"[^0-9]";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern];
if (![predicate evaluateWithObject:myStringToMatch])
// Extract ...
I have tested my pattern using an online regex tester and found that [^0-9] does match anything but the numbers 0-9. However when I run the above code it only matches the whitespaces and not the eg +2, which I am pretty sure that it should do. Just to clarify, myStringToMatch is an NSString object.
I have no clue why it doesn't match my pattern. Can anyone give me a hint on what I'm doing wrong?
Thanks.
|
You regex matches anything but a single digit. If you are going to match rows containing numbers and numbers only, you need a regex which will _not_ match on rows containing non-numbers.
You can use the following regex: `^[0-9]+$`. It matches one ore more (`+`) digits (`[0-9]`) in a row and _nothing else_ (anchors `^` and `$` ensure that).
Then, instead of filtering rows that don't match, you process only the rows that do:
if ([predicate evaluateWithObject:myStringToMatch])
// note the absence of negation operator
// Extract ...
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 1,
"tags": "ios, regex, nspredicate"
}
|
WinDiff-like utility?
My boss is looking for a comprehensive solution something like WinDiff, but a little different. Mainly he wants to be able to take the state of a machine (including registry and _all_ files) on two different occasions and see the differences.
Are there any solutions out there? Preference to free, of course, but we're not opposed to commercial products.
|
Serverfault has a post asking the the same question.
TrackWinInstall looks like the best solution.
|
stackexchange-superuser
|
{
"answer_score": 0,
"question_score": 2,
"tags": "windows, software rec"
}
|
How do I add a root certificate to the WP7 Emulator?
I have a certificate, `cert.crt`, which I have exported to `cert-der.cer` to try and add to my WP7 emulator. I have them both at addresses < and < and locally within my project. When I try to navigate a WebBrowser to the internet addresses nothing happens, and when I try to navigate to the local addresses I only see the name. I tried to access the certificates through Gmail's web interface, but still nothing. Is there any way to make the WP7 emulator see my certificate?
For the record, I don't have access to an IIS server, so I can't use WP7CertInstaller.
|
Navigate to the < file with the Internet Explorer and not with an WebBrowser object. If you want to start the navigation process within your app use a WebBrowserTask or a HyperlinkButton
<HyperlinkButton TargetName="_blank" Content="SilverlightShow" NavigateUri=" />
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "windows phone 7, ssl certificate"
}
|
Deploying .war application in Tomcat to root
My .war application runs on TomCat
I am able to deploy my .war application to a specific directory e.g. www.abc.com/specific
I would do this by renaming my application specific.war and then going to Tomcat Web Application Manager and then going to "WAR file to deploy", select my WAR file and deploy it.
However I would like to deploy it so that if the user types www.abc.com he/she will go straight to the application, without specifying the directory.
How is this possible? Thanks [I have tried calling the application root.war]
|
I solved this by using forwarding/masking (through the domain name provider)
I **forwarded** www.abc.com to www.abc.com/specific and I **masked** so that "specific" is not shown
|
stackexchange-stackoverflow
|
{
"answer_score": -1,
"question_score": 2,
"tags": "java, tomcat, deployment"
}
|
Showing context variable within HTML table
What I am trying to do is to populate a html table with the same numbers of rows as entries in my dictionary. I am passing my dictionary items as a context variable to the html. I can show my dictionary items as follows:
{% for key,value in top_items.items %}
<ul>{{ key }}</ul>
{% endfor %}
But when I try an stick it into a table to create table rows, like below, it does not work. It seems to put them all in one row. Instead of making a new row for each item.
<table class="u-half-width">
<thead>
<tr>
<th>Column</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
{% for key,value in top_items.items %}
<tr>{{ key }}</tr>
{% endfor %}
</tr>
</tbody>
</table>
|
Your HTML is invalid; you can't nest a `<tr>` inside another `<tr>`, and you don't have any `<td>`/`<th>` elements.
Try:
<tbody>
{% for key,value in top_items.items %}
<tr>
<th scope="row">{{ key }}</th>
<td>{{ value }}</td>
</tr>
{% endfor %}
</tbody>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "html, html table"
}
|
An English copy of One Hundred Authors Against Einstein?
I've been trying to find the famous article, "One hundred authors against Einstein" (100 Autoren gegen Einstein), of various objections to special relativity, which is quite often referenced, but finding a copy proved to be quite hard (there is one available here), and I can't seem to find it in English at all.
Was this text ever translated, and where might I be able to find a copy of it?
|
Here is a link to online version in German. As for the English translation, according to Milena Wazeck's Einstein's Opponents: The Public Controversy about the Theory of Relativity " _nothing ever came of an English language version of 100 Autoren - no such book exists_ ". This is despite the fact that Reuterdahl (one of the contributors) and Ruckhaber (one of the German edition editors) wanted to publish one in the US already back in 1931. But they had great difficulty finding a publisher because of the Great Depression and lack of scientific backers. According to Reuterdahl it was because scientists were afraid " _of loosing scientific caste, and perhaps their position_ ". Einstein offered a different explanation in his response to 100 Autoren (source):
> If I were wrong, then one [author] would have been enough!
|
stackexchange-hsm
|
{
"answer_score": 8,
"question_score": 4,
"tags": "physics, biographical details, reference request, relativity theory"
}
|
Simple way to copy files
Is there a simple way to copy files using the standard OCaml library, or a widely-used lightweight library (preferably one that is actively maintained on opam)?
In module `Sys`, there are functions `file_exists`, `remove` and `rename`, but nothing to copy the contents of a file to a new file.
In module `Unix`, there are `mkdir`, `unlink`, `rename` and `link`. This last one creates a hard link, which is close, but not really a copy.
Note that something like `Sys.command("cp source dest")` is not a good solution, since it is not portable and brings other issues.
|
ocaml-fileutils is a library to provide pure OCaml functions to manipulate real file and filename.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 3,
"tags": "ocaml"
}
|
Code ran before every action within symfony
I have code that I want to be executed before every action is called. Are there action hooks I can use for this?
|
In a module:
public function preExecute()
{
}
If you want it to be global for all modules, put it in the appConfiguration class, or create a filter.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 2,
"tags": "php, symfony1"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.