INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Parallel disk seek with JBOD
I'm looking to build a 80 TB file based storage system. Ideally, I'd like to do this with a large JBOD and one server with a lot of cores.
My question is: Will JBOD containers (like Intel's) allow parallelization of disk seeks? Imagine process 1 asks for sector X, while process 2 asks for sector Y. If these are totally independent storage systems, disk A (which has X) and disk B (which has Y) can seek at the same time. Will the drive controller in JBOD systems support that?
Note that I'm planning on using a JBOD container such as Intel's. | JBOD used generally means exactly what it says on the tin - just a bunch of disks. There's no raid, no disk consolidation, nothing. You'll see a whole bunch of separate devices down your controller.
Intel's 'JBOD' unit needs a RAID adaptor if you want to do anything more clever. For example: <
Includes examples that:
* Don't RAID
* do 'easier' RAID ( 0, 1, 10 )
* do 'harder' RAID ( 5, 6, 50, 60 )
The RAID controller will let you do more clever things - exactly how clever is directly related to how expensive it'll be.
So the short answer to your question: No. The point of JBOD is that it's the lowest common denominator for getting a 'bunch of disks'. However, you could install a RAID card, and implement a higher order RAID system, like RAID 10 or RAID 50 and get some degree of parallelism as suited t oyour workload. | stackexchange-serverfault | {
"answer_score": 1,
"question_score": 0,
"tags": "performance, hardware, storage"
} |
Objective C, A Question about xpath
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>topic_id</name>
<value>
<string>102</string>
</value>
</member>
<member>
<name>topic_title</name>
<value>
<string>Login test</string>
</value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>
I have this xml.. How to get the value of topic_title using xpath? | /methodResponse
/params
/param
/value
/struct
/member[name='topic_title']
/value
/string | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "objective c, xpath, touchxml"
} |
Is there a list of OpenGL extension support?
I am looking for a list that states which vendor does support which OpenGL extension.
For example I wanted to use `ARB_shading_language_include`, which was accepted in 2013, but from various forums on the internet I assume it isn't implemented on AMD drivers. But I can't find any official document that states where this extension is supported.
Does such a list exist? | There is no official list, but a community driven one. It is largely up to date: <
As can be seen here AMD doesn't support the `ARB_shading_language_include` extension at the time I wrote this answer. | stackexchange-computergraphics | {
"answer_score": 1,
"question_score": 1,
"tags": "opengl"
} |
_mm_set_epi8 - what does "set" mean?
What does the `_mm_set_epi8` do?
I'm reading the documentation but I can't understand it, what is r0..r15? | `_mm_set_epi8` is just a convenience macro which initialises a 128 bit SSE `__m128i` vector to a specified set of values (16 x 8 bit values in this case), e.g.
__m128i v = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
will set `v` to the 128 bit value: `0x000102030405060708090a0b0c0d0e0f`.
There are other similar macros for different vector element types, e.g. `_mm_set_epi16`, `_mm_set_epi32`, `_mm_set_ps`, etc.
(Note: the documentation you linked to in your question is not very good, but r0..r15 apparently just refer to the individual 8 bit fields within the returned vector). | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 10,
"tags": "x86, sse, simd"
} |
remove duplicate name submenu link from the custom post type
I was wondering what would be the proper way to remove submenu with duplicate name in custom post type in the admin. I tried to use `remove_submenu_page()` however since its a duplicate it is showing same slug for menu and submenu `/wp-admin/edit.php?post_type=portfolio` and to use that function my understanding slugs should be different
 | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "custom post types, admin menu"
} |
Can I recharge my Android smartphone at any USB port?
My girlfirend has just installed a new CD Player on her car that comes with a USB port to connect external devices(Flash card, external hard drive, etc). My question is based due the fact that I told her that if she want to recharge her Android smartophone on her car, she must buy a 12V car adapter to USB(which is very expensive on Brazil). Now, with the new CD Player, I'm wondering if she can use it's USB port to recharge her cellphone with the USB cable. It is feasible? There is any limitations on recharging an Android smartophone on another types USB ports(I mean from another host not only the CD player)? | There're two flavors of USB ports - powered and unpowered. Unpowered ports can't supply power to the devices and are rather rare. You identify them easily - connect the smartphone to them and see if it starts charging. If it starts charging the port is powered and you're okay. | stackexchange-android | {
"answer_score": 14,
"question_score": 8,
"tags": "usb, charging"
} |
How can I assign a custom color to a cell in Aspose Cells?
In the legacy (Excel Interop) code, this can be done to assign a custom color to a cell:
contractCell.Interior.Color = ColorTranslator.ToOle(Color.FromArgb(202, 134, 250));
Using Aspose Cells, I'm trying to find the corresponding way to do it. This code:
styleContractRow2.ForegroundColor = ColorTranslator.ToOle(Color.FromArgb(202, 134, 250));
styleContractRow2.Pattern = BackgroundType.Solid;
...does not compile, telling me, " _Cannot implicitly convert type 'int' to 'System.Drawing.Color'_ "
So how can I assign a custom color in Aspose Cells? | Please check the reply and sample code in your Aspose.Cells forum thread.
**_Note:** I am working as Developer Evangelist at Aspose_ | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "excel interop, aspose, aspose cells, argb, colortransform"
} |
How to slide an entire page on load with jquery
I'd like to slide my entire page down when it's changed. I'm thinking the way to do this will be to create a vertical slide that plays when a link is clicked and again when the page loads? So far, I've only been able to create a slide that affects a particular DIV. I'd also like it to slide in vertically. Any ideas will be greatly appreciated! | Just wrap all your content inside a div and slide that down.
**CSS**
#bodyContent {
display:none;
height: 100%;
}
**HTML**
<div id="bodyContent">
//all your stuff goes in here
</div>
**Javascript/JQuery**
$(document).ready(function(){
$('#bodyContent').slideDown();
}); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 5,
"tags": "jquery, load, slide"
} |
Why is this true? $\cos\left(\left(n+ \frac{1}{2}\right)\pi\right)=\cos\left(\frac{1}{2} \pi\right) = 0$
> Why is the following true? $$ \cos\left(\left(n+ \frac{1}{2}\right)\pi\right)=\cos\left(\frac{1}{2} \pi\right) = 0 $$ | Because $\cos(\pi+x)=-\cos(x)$. If $\cos(\pi/2)=0$, then $\cos(\pi/2+\pi)=-0=0$, $\cos(\pi/2+2\pi)=\cos(\pi/2)=0$. For the last one I've used the periodicity of the cosine function. All the rest of the terms you get from periodicity as well. | stackexchange-math | {
"answer_score": 1,
"question_score": -3,
"tags": "real analysis, calculus, trigonometry"
} |
Identifying a device by retrieving its USB ID
I'd like my application to be able to detect a where a particular USB device has been mounted, and adapt accordingly. Ideally, I'd associate paths with a USB serial number, rather than with a given path. However, I cannot figure out a simple way to access these unique IDs from VB.Net code.
Has anybody succeeded in doing this? | You should use WMI to query for the Win32_USBControllerDevice class. Here is a blog entry showing some sample code with Powershell which you should be able to adapt easily. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "vb.net, usb, usbserial"
} |
fill line up to specific length regex
This is part of a list. All lines need to be filled up with zeros up to 12 characters at the start of each line. Some lines already are length 12...
801095126710
2227121
19472168
21521070
21945110
25260089
92000077
93400015
132300300
132405100
211304212
934000107
934000108
934000110
934000120
934000144
93400138
160908013840
822100052908
822100053358
How can this be done with regex? | **Warning** this is ugly.
You can look for:
^(.{0,11})$
and replace with `0$1`. Click on `replace all` 11 times and _voilà._
* * *
You _can't_ do math with regex. Regex are for string matching. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "regex, notepad++"
} |
Repeat function for results from a mysql database
I have a mysql database with 2 clips in it. This is the code which show me the clip
if( $result = mysqli_query($con, "SELECT Widget FROM clipuri WHERE Data='$data[mday].$data[mon].$data[year]'", MYSQLI_USE_RESULT))
$row = mysqli_fetch_array($result);`
And that code show the clip in html
<table border="0">
<tr><td><?php echo $row['Widget']; ?></td></tr>
</table>
How to make a repeat function to show me all clips from that database?! | You must use a while loop in your code.
echo '<table border="0">';
while ($row = mysqli_fetch_array($result))
{
echo '<tr><td>'.$row['Widget'].'</td></tr>';
}//while
echo '</table>';
Get all rows with while loop and echo them.
**3 in a row:**
$counter = 0;
echo '<table border="0">';
while ($row = mysqli_fetch_array($result))
{
if($counter % 3 == 0)
{
echo '<tr>';
}
$counter++;
echo '<td>'.$row['Widget'].'</td>';
if($counter % 3 == 0)
{
echo '/<tr>';
}
}//while
echo '</table>'; | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -2,
"tags": "php, html, mysql, sql, mysqli"
} |
What's the difference between TypeName="API.MyClass+Clients" and TypeName="API.MyClass.Clients" in asp:ObjectDataSource?
I have the following `asp:ObjectDataSource` declaration :
<asp:ObjectDataSource runat="server" ID="ODS_Data"
SelectMethod="GetData" TypeName="API.MyClass+Clients"/>
What's the difference between `TypeName="API.MyClass+Clients"` and `TypeName="API.MyClass.Clients` ?
The `.` vs the `+` .
Thanks | The `.` is for a class that belongs to a namespace directly. the `+` is for a nested class, eg:
public namespace MyClass
{
public class Clients{}
}
Would lead to: `Myclass.Clients`
While
public class MyClass
{
public class Clients{}
}
Would lead to: `MyClass+Clients` | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "c#, asp.net, visual studio, visual studio 2013, objectdatasource"
} |
Adding Multiple buttons in Toast or Snackbar
Is it possible to display multiple buttons/actions in a **toast** or **snackbar** using the .Net Maui Community Toolkit? If so, can you provide an example please? if not, is there another way to achieve this. I have looked at all the documentation I can find but have not been able to find a way | Unfortunately this is not possible. On Android it uses the platform implementation as this concept is actually something that comes from Android. And on Android you cannot have more than 1 button on it. On other platforms we draw our own SnackBar/Toast, but to make sure it is consistent across platforms, we only allow 1 button to be on there. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "maui, .net maui, maui community toolkit"
} |
c# Removing an object from list based on 2 variables
I'm trying to remove an object from a list, First I need to get all the entries in it with the id == 0(for now) and then remove the first entry. At the moment I'm trying:
coursework.Where( x => x.Id == moduleList.SelectedIndex).remove(coursework[testList.SelectedIndex]) // Doesnt exist in this context
But that doesn't work and I've tried many things but can never find anything that works. | `.Where()` returns an `IEnumerable<T>` containing matched items.
It cannot be used to modify the original list.
Instead, you should call `.RemoveAll()`. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c#, arrays, linq, list"
} |
Combine key-chord and an input method
I would like to be able to use simultaneously `key-chord` and an input method such as `rfc1345`.
Presently I use
> `C-x RET C-M-\ ` `rfc1234 RET `
to activate the input method.
and
> `M-x ` `key-chord-mode RET ` `M-x ` `key-chord-mode RET ` (yes, two times)
to re-activate key-chord.
This switch is rather cumbersome. Any idea about how to have them both ativated? Or maybe a way to switch more quickly? | There is a built-in function `toggle-input-method`, bound to `C-\` by default that conveniently allows to switch from the set input method and key-chord support. | stackexchange-superuser | {
"answer_score": 1,
"question_score": 1,
"tags": "emacs"
} |
How to type こんにちは (not こんにちわ) with windows Japanese keyboard
Google spells as but when I type "konnnichiwa" I've got and if I do space I've got : ...
maybe don't need to trust google here ? or there is some another way to write it | is always entered into an IME as "ha", even if it is romanized as "wa" due to use as a particle. | stackexchange-japanese | {
"answer_score": 8,
"question_score": 1,
"tags": "input method"
} |
Modelling a robotic arm motion in 3D, ideas?
I hope you don't mind if I ask for a bit of advice regarding modelling robotic systems. I've recently become rather interested in using inverse kinematics (IK) to control a 5 dof robotic manipulator. I have a solid foundation in IK but what I'm having trouble with is a way to visualize how the manipulator moves with respect to joint angles.
I've looked into using 3D toolkits (such as Blender, Panda3D, vPython) to create a 3d model of the arm, but I'm not sure if I should be looking something with physics support. I'm also not sure how well I can model motion with these packages. Anyone have any suggestions? What I'm NOT looking for is a full blown robotic simulator like Microsoft's Robotic Studio, I'd like to start with the basics and learn how everything works first, ie code the IK in Python, then visualize the motion in 3D. I'm very familiar with Python, so something that interfaces with Python would be preferable.
Thanks! | Well the great thing about Blender is that its API is actually in python!
In addition, it supports inverse kinematics (IK) quite well in addition to many other modeling tools.
Blender Cookie is a great resource.
Here is a tutorial on making IK rigs in Blender.
Blenders python api is documented quite extensively, and it even has an interactive python shell built right in so that you can see the effects of your script as you go along.
The physics engine that blender uses is the popular bullet physics engine, which has been used in many commercial games as well as a few feature films (2012 among them). | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "python, modeling, robotics, robot, inverse kinematics"
} |
Drawing lines in <li> tag
I do have an li element that looks like this:
| Link |
I want it to become like this with a SOLID line:
|----Link----|
Here is a link to the code: <
I have tried putting a hr tag inside the li element and making the hr inline but that failed. The problem im having is that I need the line to wrap around the text. Im clueless on this one. | Here's another alternative.
<hr/><span>Link</span>
li span {
background-color: #fff;
color: #000;
}
hr {
border: none;
color: #000;
background-color: #000;
height: 1px;
margin-top: 9px;
position: absolute;
display: block;
width: 100%;
z-index: -1;
} | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "html, css"
} |
No option to upgrade from 7.6.x to 8.7.x in Install-Tool Core update or upgrade wizard
why the Core update shows me "No regular update available" and upgrade wizard shows me " _No updates to perform!_ "?
I'd like to upgrade from 7.6.31 LTS to the latest 8.7.x LTS version. | The wizards for upgrading in the TYPO3 install tool always only performed upgrades on the same main-branch. So a change from version 7 to 8 or 8 to 9 was never considered and has to be done manually. One reason might be that also some extensions follow the same concept and it will be hard to keep the site running with automatic updates between branches.
Especially problematic would be an automatic upgrade from 8 to 9, because many things changed technically (t3_ckeditor instead of rte_htmlarea, Doctrine Dbal instead of the old TYPO3 database-layer).
So, currently there is just no option to upgrade from 7 to 8 and you've to accept to have to do that upgrade manually.
Nevertheless the upgrade-wizard is still supporting you with required database-updates and other actions to perform.
Some upgrades also require an update of PHP which would be impossible for the wizard. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "typo3, upgrade, typo3 7.6.x, typo3 8.x"
} |
Shell script not running on Mac OS
I have what amounts to a very simple bash script that executes a deployment. Here is my code:
#!/usr/bin/env bash
function print_help
{
echo '
Deploy the application.
Usage:
-r reinstall
-h show help
'
}
reinstall=false
while getopts "rh" opt; do
case ${opt} in
r)
echo "clean"
reinstall=true
;;
h)
echo "help"
print_help
exit 0
;;
esac
done
I am calling the script as follows:
. deploy.sh -h
No matter what I do, neither option (i.e. -r, -h) results in the respective `echo` and in the case of `-h` the `print_help` function isn't called.
What am doing wrong? | `getopts` uses a _global variable_ `OPTIND` to keep track about which argument it processes currently. Each option it parses, it increments/changes `OPTIND` to keep track which argument will be next.
If you call `getopt` without changing `OPTIND` it will start from where it last ended. If it already parsed first argument, it would want to continue parsing from the second argument, etc. Because there is no second argument the second (or later) time you source your script, there is only `-h`, `getopt` will just fail, because it thinks it already parsed `-h`.
If you want to re-parse arguments in current shell, you need to just reset `OPTIND=1`. Or start a fresh new shell, which will reset `OPTIND` to `1` by itself. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "bash, shell"
} |
Modifying \answerline in the exam class
When using the exam class, is there a way to change the formatting of the item answer blanks created by `\answerline`?
For a question, the label is 1.
For a part, the label is (a)
For a subpart, the label is i.
I would like them all to be (1), (a), and (i) respectively.
For example
\documentclass[answers]{exam}
\begin{document}
\begin{questions}
\question First one \answerline
\begin{parts}
\part first part \answerline
\begin{subparts}
\subpart A subpart \answerline
\end{subparts}
\end{parts}
\end{questions}
\end{document} | You can redefine `\questionlabel` and `\subpartlabel` which control the decorations around the numbers corresponding to questions and subparts, respectively:
\documentclass[answers]{exam}
\renewcommand\questionlabel{(\thequestion)}
\renewcommand\subpartlabel{(\thesubpart)}
\begin{document}
\begin{questions}
\question First one \answerline
\begin{parts}
\part first part \answerline
\begin{subparts}
\subpart A subpart \answerline
\end{subparts}
\end{parts}
\end{questions}
\end{document}
!enter image description here | stackexchange-tex | {
"answer_score": 6,
"question_score": 6,
"tags": "formatting, counters, exam"
} |
ICMPv6 RA to make it as default gateway in the Network
Hey guys if you are familiar with ICMPv6, i have a problem right now considering RA. I am trying to come up with a mitigation for last hop router attack, so i thought of how about sending a packet identical to the attack except the lifetime is 0. Will that work?
Also is it possible to have the computer consider me the router with just RA. Like my victim does not have any neighbor cache with myself? | Yes that will work. Take a look at `ndpmon` which can do exactly what you describe. | stackexchange-networkengineering | {
"answer_score": 2,
"question_score": 1,
"tags": "ipv6"
} |
Enable Task Tags in Scala IDE for Eclipse
Is there a way to enable TODO/FIXME/etc type tasks in the Scala IDE for eclipse? The only TODO's that I see are for .java files. | This was discarded by Scala's compiler until recently. If you use a nightly trunk, it ought to work. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 4,
"tags": "eclipse, scala, eclipse plugin, comments, scala ide"
} |
Problem in understanding Python list comprehensions
What does the last line mean in the following code?
import pickle, urllib
handle = urllib.urlopen("
data = pickle.load(handle)
handle.close()
for elt in data:
print "".join([e[1] * e[0] for e in elt])
My attempt to the problem:
* "".join... uses join -method to empty text
* e[1] * e[0] multiplies two subsequent values in the sequence, e
* I am not sure what is e
* I am not sure, what it means, when you have something before for -loop, like: `e[1] * e[0] for e in elt` | Maybe best explained with an example:
print "".join([e[1] * e[0] for e in elt])
is the short form of
x = []
for e in elt:
x.append(e[1] * e[0])
print "".join(x)
List comprehensions are simply syntactic sugar for `for` loops, which make an expression out of a sequence of statements.
`elt` can be an arbitrary object, since you load it from pickles, and `e` likewise. The usage suggests that is it a sequence type, but it could just be anything that implements the sequence protocol. | stackexchange-stackoverflow | {
"answer_score": 21,
"question_score": 9,
"tags": "python, list comprehension"
} |
Undefined variable of a sum in PHP
I am making a shopping cart in php, its almost done and now i'm making the total of all items in the cart with:
while ($data=mysql_fetch_array($result)){
$total=$price+$total;
}
It returns "Undefined variable:total" but it works anyways and i got the correct result. Its very strange and i don't want this error showing up.
When i define the variable like in the example below it doesn't give me the right result, just gives me the last value of the '$price' variable and not the sum.
$total=0;
$total=$price+$total;
Can someone give me a hint, seems very simple to solve but i can't do it. Thanks in advance. | move your
$total=0;
above your while and the **undefined** error should be gone. The reasons is clear, you're trying to add `$price` to **undefined** variable. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -3,
"tags": "php"
} |
Riddle: 3 people with the same name
In the Torah - 3 people with the same name - One is Jewish - One is a Ger - One is a Non-Jew? | Reuel.
Jewish: the father of Elyasaf, nassi of the tribe of Gad (Num. 2:14 - elsewhere his name is given as Deuel, but Ramban there comments that they both have the same basic meaning and therefore are interchangeable). Also a Benjaminite (I Chron. 9:8).
Ger: it's one of Yisro's names (Rashi to Ex. 18:1).
Non-Jew: one of Eisav's sons (Gen. 36:4 passim). | stackexchange-judaism | {
"answer_score": 13,
"question_score": 5,
"tags": "parshanut torah comment, riddle"
} |
HighCharts on hover change dataLabel's font size
I have a pie highchart and what i want is to change dataLabels font size when i hover over the specific part of the pie.
I found that the hover event is established like this:
plotOptions: {
series: {
shadow: {
color: '#000',
offsetX : 5,
offsetY : 5,
opacity : 0.5
},
events: {
mouseOver: function(event) {
},
mouseOut: function(event) {
}
}
}
but i dont know how to access dataLabel from inside the mouseOver/Out. | You can reach the `dataLabel` via `this.dataLabel` within the `point` events for the `series`:
series: {
point: {
events: {
mouseOver: function (e) {
this.dataLabel.css({
fontSize: "30px",
});
},
mouseOut: function (e) {
this.dataLabel.css({
fontSize: "12px",
});
}
}
}
}
Demo | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 2,
"tags": "javascript, highcharts"
} |
CSS Slaint edges on bootstrap menu
I am trying to create this in bootstrap with a menu, how would i get those slant edges in css?
Here's a JsFiddle so far i have gotten one corner to be slanted, but i just cant seem to get another in the opposite direction.
Here's CSS i used for the on Edge:
.navbar .nav {
float: right;
right: 0;
/*Slant Edges*/
height:0;
border-bottom: 40px solid #000;
border-right: 40px solid white;
/*Slant Edges*/
}
Any Help Greatly Appreciated. | I would totaly use a `pseudo-element`
CSS:
.nav-collapse:before {
content:'';
border-top: 40px solid white;
border-right: 40px solid #000;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
height:40px;
position: absolute;
top: 0;
left: 0;
height:100%;
width: 40px;
}
.nav-collapse:after {
content:'';
position: absolute;
right: 0;
height:0;
border-top: 40px solid #000;
border-right: 40px solid white;
}
.nav-collapse{
padding:0 40px 0 0 ;
}
DEMO: < | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "css, twitter bootstrap"
} |
Prove that inequality is true for $x>0$: $(e^x-1)\ln(1+x) > x^2$
I was given a task to prove that inequality is true for x>0: $(e^x-1)\ln(1+x) > x^2$. I've tried to use derivatives to show that the $f(x) = (e^x-1)\ln(1+x)-x^2$ is greater than zero, but has never succeeded.
Any help will be appreciated. | The exponential makes your approach somewhat impractical: get rid of it. You have $e^x = 1+x+\frac{x^2}{2}+\sum_{n=3}^\infty \frac{x^n}{n!}$, so for $x > 0$ it holds that $e^x - 1 > x+\frac{x^2}{2}$.
Then it suffices to show that for any $x> 0$, $$ \left(x+\frac{x^2}{2}\right)\ln(1+x) > x^2 $$ or equivalently $$ \left(1+\frac{x}{2}\right)\ln(1+x) > x. $$ Define $f$ on $[0,\infty)$ by $f(x) = \left(1+\frac{x}{2}\right)\ln(1+x) - x$. It is $C^\infty$, with $f(0)=0$, and derivative $f^\prime(x) = \frac{(x+1)\ln(x+1)-x}{2(x+1)}$. From there, we get $f^\prime(0) = 0$ and $f^\prime(x) > 0$ for all $x>0$, so $f$ is increasing on $[0,\infty)$ and the inequality holds. | stackexchange-math | {
"answer_score": 5,
"question_score": 3,
"tags": "real analysis, derivatives, inequality, logarithms, exponential function"
} |
Use UPX (executable compresser) on release builds?
I was wondering if it's normal/acceptable to use UPX (or any other executable compressor for that matter) on a release build for a project.
For example, I have this executable which normally is 1.7MB when shipped, but when packed it's 426KB. Not that I care about 1.2MB of storage, but 426KB looks much nicer when downloading and in general.
Also, I have heard - not tested - that some programs perform better on startup when compressed because reading from the harddisk is more expensive than decompressing.
So is it recommended to compress your executables on a release build? | > I have heard - not tested - that some programs perform better on startup when compressed because reading from the harddisk is more expensive than decompressing.
Sometimes the opposite is true because the program only needs to load code pages on demand. But it can't do this is the exe is compressed.
If you have multiple instances of your executable running, then the memory will be shared between each instance. But if you compress them this is no longer the case.
As for downloading, surely what is downloaded is an install package which is compressed.
In short, I really don't think executable compressors are worthwhile. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "compression, executable, upx"
} |
Celery: How to batch produce tasks?
I have a large loop to produce tasks:
for i in range(1000):
receiver.apply_async(args=(i), kwargs={}, exchange=topic_exchange, routing_key=topic_key)
And I found there is a module `celery.contrib.batches` before celery 3.X or `celery_batches` after celery 4.X. But this module doesn't seem to support such params. So how can I do it?
I'm using celery 4.4.7 with rabbitmq. | If by "batch" you mean a small subset (chunk) of the all tasks, then you could look into Chunks. Instead of using chunks (they are after all made for different purpose), I suggest you use Chord if you care about results. If you do not, then just simply create a Group. Thousand tasks is nothing - we have had chords/groups made of tens of thousands of tasks and Celery copes with that load pretty well. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 4,
"tags": "python, rabbitmq, celery"
} |
Free screen saver for dual monitor system
Finally I outfit my system with dual screens, After I spent over hour and half for setting good looking desktop background, Now I want to try some cool screen saver that can use dual motors individually. My OS WINXP and graphic card is Nvidia 5800. Is there any recommendation. | Sometime I need say to myself Let Me Google That for You,
So far I found this Really Good sets of open source screensavers. | stackexchange-superuser | {
"answer_score": 1,
"question_score": 1,
"tags": "software rec, multiple monitors, screensaver"
} |
SQL Import to update existing records?
I've got a table in a database that contains costs for items that gets updated monthly. To update these costs, we have someone export the table, do some magic in excel, and then import the table back to the database. We're running MSSQL 2005 and using the built in SQL Management Studio. The problem is that when importing back into the table, we have to delete all the records before we import or else we'll get errors. The ideal situation would be for the import to recognize the primary keys and then update the records instead of trying to create a second record with a duplicate key- halting the import. The best illustration of the behavior we're trying to get can be found at < the update or insert example. Is something like this possible with the built in tools or do we have to get third party software to make it happen? | In SQL Server 2008 you could put the data into a new table and use the MERGE statement with your existing table as the target, and your new table as your source.
Instead, you might prefer to put it into a new table and use that as your source with an old method (using two steps unfortunately):
UPDATE t SET col1 = s.col1, col2 = s.col2
FROM targetTable t
JOIN
newTable s
ON s.id = t.id ;
INSERT targetTable (columnlist)
SELECT s.col1, s.col2, ...
FROM sourceTable s
LEFT JOIN
targetTable t
ON s.id = t.id
WHERE t.id IS NULL;
Bear in mind you may need to turn on IDENTITY_INSERT on your target table if you're trying to insert into an identity column as well. | stackexchange-serverfault | {
"answer_score": 2,
"question_score": 4,
"tags": "sql server, sql, import"
} |
Building rpm
Is there an easy procedure to build an RPM.If so Please explain or provide the link.........
My requirement is very simple ..
I have two other RPMs which should be combined into one single RPM....
Please explain the process....
Thanks in advance.......... | Building an RPM itself is rather easy, you just need to run
rpmbuild -ba <mypackage.spec>
The more complex task is creating the `.spec` file, which controls how the rpm itself is built. A good explanation is the book Maximum RPM, which is available on the rpm homepage. Creating a `.spec` file is handled here. From my own experience building a `.spec` file is something that's not easy -- but not too complicated either unless you want to make special things. The standard `./configure && make && make install` is usually not too complicated. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 2,
"tags": "linux, rpm, rpmbuild"
} |
Is there a way to find nth largest value with multiple criteria in excel?
I am trying to extract a summary of information for a particular client. Using the following formula:
{=LARGE(IF('claims history'!$B:$B=$C$2,'claims history'!$AF:$AF),1)}
I am able to extract the largest claim (`$AF:$AF`) within a client's (`$B:$B=$C$2`) claims history.
However, I want to add an additional criteria to this, so that I can pull out the largest claim per defined year (`'claims history'!$J:$J`).
How to implement this into the above formula? | There is a trick with array formulae when using `AND` doesn't work - that is to multiply your conditions in the `IF` expression.
In your example, assuming that the year is in cell `D2` you would do:
{=LARGE(IF(('claims history'!$B:$B=$C2)*('claims history'!$J:$J=$D2),('claims history'!$AF:$AF)),1)}
Note: If you think that `TRUE` is **1** and `FALSE` is **0** then you can see that multiplying gives us an `AND`... and also adding will give an `OR` | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "excel formula"
} |
Count number of "true" booleans in array
I have an BooleanArray filled with 17 values. I want to loop through that array and count how many of them are true, or break and set a flag when it reaches a certain amount of true values. So if the array containes 6 booleans that are "true" I want to break the loop and do something.
BooleanArray booleanArray = new BooleanArray(17);
booleanArray.add(handler.get(0).getStatus());
booleanArray.add(handler.get(1).getStatus());
booleanArray.add(handler.get(2).getStatus());
booleanArray.add(handler.get(3).getStatus());
booleanArray.add(handler.get(4).getStatus());
//etc...
It's how to build this loop I'm not sure on how to. | You can try something like this:
int trueCount = 0;
for (int i = 0; i < array.length; i++) {
if (array.get(i) /* or array[i] */) {
trueCount++;
}
if (trueCount >= 6) {
break;
}
} | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": -2,
"tags": "java, arrays"
} |
What does the 'export' command do?
I happen to run some commands blindly, in order to get things done.
I started to work with Jenkins recently, and then I had to use this `export` command to run the Jenkins WAR archive. What does the `export` command do in general, and why do we need to run this command, while running Jenkins (after the Jenkins home is set)? | `export` in `sh` and related shells (such as Bash), marks an environment variable to be _exported_ to child-processes, so that the child inherits them.
`export` is defined in POSIX:
> The shell shall give the export attribute to the variables corresponding to the specified names, which shall cause them to be in the environment of subsequently executed commands. If the name of a variable is followed by = word, then the value of that variable shall be set to word. | stackexchange-stackoverflow | {
"answer_score": 104,
"question_score": 90,
"tags": "shell, unix, command, environment variables"
} |
Joint probabilities, conditional probabilities with the chain rule.
I'm reading through a book, and it walks through a problem. We need to compute $p(a | e, f)$. It says that by applying the chain rule we can see:
$$p(a|e,f) = \frac{p(e,a|f)}{p(e|f)}$$
Looking at the chain rule, I do not understand how that was arrived at.
I imagine there is a simple explanation (since no further working was shown in the book), is anyone able to provide one? | $$p(a\mid e,f)=\frac{p(a,e,f)}{p(e,f)}=\frac{\frac{p(a,e,f)}{p(f)}}{\frac{p(e,f)}{p(f)}}=\frac{p(a,e\mid f)}{p(e\mid f)}$$ | stackexchange-math | {
"answer_score": 7,
"question_score": 4,
"tags": "probability"
} |
Find two different pattern and match count
I need to find how many 10 and 01 s are there in the sting. for ex: 10101 in this, two 10 are there and two 01 are there like that use reg ex and find it ? and print the 10 is match 2 times and 01 match the 2 times | Use the goatse operator `=()=`:
$string = '10101';
$a =()= $string =~ m/10/g;
$b =()= $string =~ m/01/g;
print "a: $a\nb: $b\n";
The output is:
a: 2
b: 2 | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -1,
"tags": "perl"
} |
Does "improper" imply that a system cannot be stable and causal?
This answer and the comments in it made me wonder whether the following statement is true:
> If a transfer function is improper, then that system cannot be causal and stable at the same time.
I had thought that this was true for a while. But the other day I wondered why. For example, the transfer function
$$H(s)=\frac{s^2}{s+1}$$
is improper, but the ROC $\\{s:\mathrm{Re}(s)>-1\\}$ would make it stable (it contains the imaginary axis) and causal (it consists of a left-sided plane).
So how are causality and stability related in improper systems? | An improper system cannot be causal and stable. If the order of the numerator is greater than the order of the denominator, you'll always have at least one pole at infinity. Consequently, not all poles are in the left half-plane (or inside the unit circle in the case of discrete-time systems).
The system in your example is clearly unstable:
$$H(s)=\frac{s^2}{s+1}=s-1+\frac{1}{s+1}\tag{1}$$
Part of it is an ideal differentiator ($s$), which is unstable.
Also take a look at this related answer. | stackexchange-dsp | {
"answer_score": 4,
"question_score": 5,
"tags": "linear systems, transfer function, stability, causality"
} |
Adding all rows values in php
This is the table
store_reviews
id rev_star
1 2
2 5
3 4
What I want to do is to get all the rows and add stars and divide by the count of rows (average) like `2+5+4/3`
I wrote a code but it doesn't get all the rows added.
<?php
$stmtrev = $mysqli->prepare("SELECT * FROM store_reviews WHERE store_id=?");
$stmtrev->bind_param("i", $_GET['storeid']);
$stmtrev->execute();
$revrows = $stmtrev->get_result();
$stmtrev->close();
$total=0;
while ($stars = $revrows->fetch_assoc())
{
$count = ($total + $stars['rev_star']);
}
$count/count($revrows->fetch_assoc());
?>
Can anyone explain what's wrong and what could be done? | This is one of those places where your database can do the work for you
SELECT AVG(rev_star) as average,
FROM store_reviews
WHERE store_id=?
As to why your PHP script isn't working properly, you're counting the number of columns in your database, not the number of rows. Worse, you're doing this by trying to pop a result set off the result stack after having looped through the full result stack. The result object tells you how many rows were returned
$total = 0;
while ($stars = $revrows->fetch_assoc()) $total += $stars['rev_star'];
$avg = $total / $revrows->num_rows; | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "php"
} |
Query Formula excludes results with new line character
It seems there may be a bug in Google Sheets' Query formula where results with a new line character (char 10) are excluded when the column is filtered. Is there any way around this or am I doing something wrong?
`** nor bug
* by examining the whole range with **`=ARRAYFORMULA(ISNUMBER(A2:C7))`** you can see that **`CHAR(10)`** causes cells with numbers to act like **`TEXT`** which makes sense because there is not a number like **`19 68`** it's either **`19`** , **`68`** or **`1968`**

**
 | stackexchange-ell | {
"answer_score": 2,
"question_score": 1,
"tags": "informal language"
} |
SQL syntax: outer table_name
I have a project with this query that I don't get something in it.
Select
c.prop_table1,
(SELECT max(t.taux_table_x) FROM DB3:table_x t
WHERE month(t.date_prop_x) = month(c.prop_of_x)
AND year(t.date_prop_x) = year(c.prop_of_x)
)*1 table_x,
''||date(c.prop_of_x) Alias
FROM DB1:table_name1 d, DB1:table_name2 c, outer DB2:table_name a
WHERE
c.value_i = d.value_i AND
c.property =d.property AND
(c.num_table_name2 =a.no_dos_adh OR c.ref_cred=a.no_dos_adh) AND
c.abcd not in ('P','S')
I don't know what `outer` is expressing exactly. Is it a left/right or full join? Or is it something else? **thanks for the help everyone** | It looks a lot like your query is written using the (IBM) Informix SQL dialect. If that is the case then the `outer` should be a left outer join as it has a table on its left side (I believe a right join would be `from outer tab1, tab2`)
The syntax predates the SQL-92 standard but should still be valid (?) with Informix.
Rewritten as standard SQL it would probably look like this:
SELECT
c.prop_table1,
(
SELECT max(t.taux_table_x) FROM DB3:table_x t
WHERE month(t.date_prop_x) = month(c.prop_of_x)
AND year(t.date_prop_x) = year(c.prop_of_x)
)*1 table_x,
'' || date(c.prop_of_x) Alias
FROM
DB1:table_name1 d
INNER JOIN
DB1:table_name2 c ON c.value_i = d.value_i AND c.property = d.property
LEFT JOIN
DB2:table_name a ON (c.num_table_name2 = a.no_dos_adh OR c.ref_cred = a.no_dos_adh)
WHERE
c.abcd not in ('P','S') | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "sql"
} |
How to check if window is already open before opening a new one
I am creating a window on click of a button. If I click the button more than once, it opens a window each time I click on it. How can I check first if the window is already open? If open close it and if not open a new one.
I am using following code to show window using extjs.
var modiwin = Ext.create('widget.window', {
height: 70,
width: 110,
title: 'Editing',
closable: true,
autoScroll: false,
collapsible: true,
//modal:'True',
maximizable: false,
resizable:false,
items: [mdsavebtn,mddelbtn]
});
modiwin.setPosition(175,55);
modiwin.show(); | If your code is inside a handler function or something, here is what I typically do:
handler: function(button){
if(!button.modiwin)
{
button.modiwin = Ext.create('widget.window', {
height: 70,
width: 110,
title: 'Editing',
closable: true,
autoScroll: false,
collapsible: true,
//modal:'True',
maximizable: false,
resizable:false,
items: [mdsavebtn,mddelbtn]
});
}
button.modiwin.setPosition(175,55);
button.modiwin.show();
}
This way, the button can hold on to a reference to the window and always check if it exists before creating it again. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "extjs, extjs4"
} |
Como pasar parametros desde un href a una ruta get en laravel 4.2?
Saludos comunidad
Estoy trabajando con esta ruta en laravel
Route::get('/{tienda}/{ruta}', array('before' => 'validar_tienda', function($tienda, $ruta)
{...}
para invocarla desde la barra del navegador no tengo mayor problema con los parametros dinamicos "tienda y ruta"
La pregunta es como se podria invocarla desde un href?.. algo como lo siguiente
href="{{ Route ('/',['mitienda'],'/',['sesionproducto']) }}" | Normalmente deberías poder utilizar el helper route() , siempre y cuando le hayas asignado un nombre a tu ruta:
href="{{ route('miruta', ['tienda' => $tienda, 'ruta' => $ruta]) }}"
Más información u opciones en la documentación de Laravel: < | stackexchange-es_stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "php, laravel, laravel 4"
} |
Use residues to evaluate the improper integral $\int_0^\infty\frac{x^3\sin(x)}{(x^2+4)(x^2+16)}dx$
I am trying to solve the below problem using residues,
$$\int_0^\infty\frac{x^3\sin(x)}{(x^2+4)(x^2+16)}dx$$
This is what I have so far:
Firstly, Change the equation to $z$ as follows
$$f(z)=\frac{z^3}{(z^2+4)(z^2+16)}dz$$
Then, Identify the singularities in the upper half plane - these being $2i$ and $4i$ where $R>4$.
This brings us to the 2 equations:
$$\operatorname*{Res}_{z=2i} [f(z)e^{iz}]=\frac{z^3e^{iz}}{(z+2i)(z^2+16)}\biggr]_{z=2i}$$
and
$$\operatorname*{Res}_{z=4i} [f(z)e^{iz}]=\frac{z^3e^{iz}}{(z^2+4)(z+4i)}\biggr]_{z=4i}$$
Now when I try to solve each of these equations I am going wrong somewhere and ending up with some ridiculous answer... any help with this would be greatly appreciated! | Since you seem to have trouble with calculating the residue part, here's a brief outline on how they're calculated. Obviously, you need to consider when $z=2i$ and when $z=4i$ because they lie inside the contour.
Therefore$$\operatorname*{Res}_{z\, =\, 2i}\frac {z^3e^{iz}}{(z^2+4)(z^2+16)}=\lim\limits_{z\,\to\, 2i}\frac {z^3e^{iz}}{(z+2i)(z^2+16)}=-\frac 1{6e^2}$$$$\operatorname*{Res}_{z\, =\, 4i}\frac {z^3e^{iz}}{(z^2+4)(z^2+16)}=\lim\limits_{z\,\to\,4i}\frac {z^3e^{iz}}{(z^2+4)(z+4i)}=\frac 2{3e^4}$$The contour integral then evaluates to$$\oint\limits_{\mathrm C}dz\,\frac {z^3e^{iz}}{(z^2+4)(z^2+16)}=2\pi i\left(\frac 2{3e^4}-\frac 1{6e^2}\right)=\frac {\pi i(4-e^2)}{3e^4}$$ | stackexchange-math | {
"answer_score": 0,
"question_score": 2,
"tags": "complex analysis, complex numbers, improper integrals, residue calculus"
} |
WAMP Server Issues and Suggested Solutions
I have a working WAMP server with no problems on a Windows 8.1 Pro platform but i need to implement WAMP on several other machines all running a version of Windows (classroom environment). Some machines work perfectly fine, but others not so much. We are trying to reinstall WAMP but nothing seems to be working. The issue is
1.) every time i want to use WAMP i have to install all services before they can run. Then when i attempt to open a file on localhost i get an error that says service not found. Files are all in the right location (\www)
I have read that port 80 might be an issue but when we execute the port 80 test, no traffic issues. To be safe, we changed the port to 8080 and the same issues arrise.
Anybody have an issue like this or anything similar. | The soluton above will probably aslo do the job. When I was dealing with the same issue with Wamp on Win 10. All resolved by following steps:
* open command line under as an administrator
* make sure it is process with PID 4 listening to port 80:
netstat -o -n -a | findstr 0.0:80
* change http process to use another port (i.e. 8000):
netsh http add iplisten ipaddress=0.0.0.0:8000
* restart http service
net stop http
net start http
* restart Xamp processes | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "php, apache, wamp"
} |
Implementation of jump sequence
I am trying to implement the jump instruction to my Pipeline Simulator in the **C** language. I have been reading up on the J-Instruction for mips and seen its constructed by 26 bits imm and 6 bits opcode. After some further reading I found that the address to the jump instruction can be calculated using this
PC <- PC31-28::IR25-0::00
I am not completely sure how I would implement this in the **C** language though. While calculating the ex stage I have been trying something like the code below but it doesn't work for me.
if(idStage.instruction.type == J)
{
ifStage.pc = ifStage << idStage.instruction.imm;
ifStage.pc = IfStage << 2;
}
How could I implement the PC <\- PC31-28::IR25-0::00 in the **C** language? | It would be
ifStage.pc = (ifStage.pc & 0xF0000000) | (idStage.instruction.imm << 2);
that is: take current PC, apply an AND mask to keep bits 28..31, and then apply an OR mask with the immediate shifter 2 places left. This assumes idStage.instruction.imm is a 26 bit immediate. If it can hold "garbage" in the high order bits (26..31) then you would apply another AND mask:
ifStage.pc = (ifStage.pc & 0xF000) | ((idStage.instruction.imm & 0x3FFFFFF) << 2); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "c, mips, pipeline"
} |
Animate position of items in CSS3 Column layout
I've created a CSS column layout with some rectangle `divs` inside. **This is my code.**
When user clicks on each of them, it should remove. I've added CSS3 transition to it:
-webkit-transition: all 0.3s ease-in; /*Safari & Chrome*/
-moz-transition: all 0.3s ease-in; /* Firefox 4 */
-o-transition: all 0.3s ease-in; /* Opera */
transition: all 0.3s ease-in;
now the item which is clicked removes with effect, but other rectangles (after this div) changing their places without any effect.
How to add effect to other items when they are changing places? Is it possible with CSS3 Columns? If not, Which method should I prefer? How?
* * *
_Note: I'm going to create something like Windows 8 Start menu; when you remove a tile inside it, other items will move to their new position with animation._ | I made the divs `display: block` and gave them `float: left`, is this the effect you are looking for? < | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "html, css, css transitions"
} |
Application.Eval() Not working with expression
This line of code won't evaluate:
If(StrComp(Left("Campaign", 5), "IMS :") = 0
I'm using it like this:
strHolder = "If(StrComp(Left("Campaign", 5), "IMS :") = 0"
myVar = Application.Eval(strHolder)
This is the error I'm receiving:
>
> Run-time error '2425':
>
> The expression you entered has a function name that Microsoft Access can't find.
>
I'm guessing that `Application.Eval` can't read either the `If` , `StrComp` , or `Left`
Not sure what to do here, and I can't find the much in-depth info on the `Eval` method. | > This line of code won't evaluate:
>
>
> If(StrComp(Left("Campaign", 5), "IMS :") = 0
>
And it wouldn't compile either due to unbalanced parentheses and `If` without `Then`.
There should also be a compile error at this line ...
strHolder = "If(StrComp(Left("Campaign", 5), "IMS :") = 0"
If you want something like this Immediate window example ...
? StrComp(Left("Campaign", 5), "IMS :") = 0
False
... then double up the `"` characters within the string which you submit to `Eval()` ...
strHolder = "StrComp(Left(""Campaign"", 5), ""IMS :"") = 0"
? strHolder
StrComp(Left("Campaign", 5), "IMS :") = 0
myVar = Application.Eval(strHolder)
? myVar
0
? CBool(myVar)
False | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "ms access, vba"
} |
Image style is not working for larger size image
I am working on a drupal 7 site < where I have defined multiple image styles. I have a content type called gallery with image cck field. Everything works fine if I upload image of lower resolution like 800px (around 1 MB) file. When I upload larger resolution image, image style won't work but image file is getting uploaded successfully. I don't see any error reported in log file or log messages page.
What could be the issue? | You are most likely hitting a PHP memory limit. When an image style tried to create a derivative image using the default GD library, the image is processed in the PHP thread and uses the PHP memory. The larger the image, the more memory the process will need. This would make sense why it works with smaller images, but not larger ones.
You could also just be running up against the timeout. The image process for the image could be taking longer then processes are allowed to run, but I'd bet on memory.
Another option is to switch to ImageMagick (< to replace GD. I believe this takes the image processing out of the PHP process. | stackexchange-drupal | {
"answer_score": 0,
"question_score": 1,
"tags": "7, media"
} |
Отступы между элементами в RecyclerView
Как сделать отступы между итемами в `RecyclerView`? | Смотря что понимать под отступами. Есть 2 атрибута, которые влияют на "отступы" - _margin_ и _padding_ , соотношение между ними лучше всего показывает следующая картинка:

- (BOOL)isToday {
NSUInteger desiredComponents = NSEraCalendarUnit|NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit;
NSDateComponents *myCalendarDate = [[NSCalendar currentCalendar] components:desiredComponents fromDate:self];
NSDateComponents *today = [[NSCalendar currentCalendar] components:desiredComponents fromDate:[NSDate date]];
return [myCalendarDate isEqual:today];
}
@end | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 3,
"tags": "iphone, objective c, calendar"
} |
Generating sorted data with test.check
I'd like to use test.check to generate **sorted** time series data of the form
`[ [timestamp value] [timestamp value] ..]`
where the timestamp, value -pairs are in ascending order by the timestamp.
I can easily generate such data in random order with
`(gen/tuple timestamp gen/int)` where `timestamp` is e.g. `(gen/choose 1412664660 1423419720)`
How should I go about generating sorted data? | So it came to me while brushing my teeth..
When I asked the question I was thinking "one level too low" about the data I want to generate.
`(gen/tuple timestamp gen/int)` generates individual tuples and my attempts of doing `(gen/fmap sort .. )` on them didn't work because it just sorted the contents of the tuples. What I need to generate is vectors of those tuples.. and `fmap sort` on those of course works:
(def entry (gen/tuple timestamp gen/int))
(def timeseries (gen/fmap sort (gen/vector entry))) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "clojure, test.check"
} |
How to get webform title and category with no submissions in view or hook?
I have a survey form created with webform module. I have to display all survey form title with submissions and without submissions with webform category on home page. But it displaying only submitted survey forms title. How can I display webform title with zero submission in drupal 8? | use below code as a function in your module file and call it on your custom block.
function module_name_webformtitle(){
$query = Drupal::service('entity.query')->get('webform');
$query->condition('category', 'survey_name');//your survey name
$entity_ids = $query->execute();
$webform_id=array();
foreach($entity_ids as $webid){
$webform_id[]=$webid;
}
$webform = Webform::loadMultiple($webform_id);
foreach($webform as $webforms){
$webformtitle=$webforms->get('title');
}
} | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "drupal 8, drupal webform"
} |
sql raiseerror error.number wrong in VB
I wrote a T-SQL query which includes a test for valid EmployeeNo. If the EmployeeNo is not valid, I do the following:
RAISERROR(5005, 10, 1, N'Invalid Employee No')
return @@Error
Back in VB.Net I test the sql exception and found that when the Employee No is invalid the error.number is not 5005 as I would expect, but 2732.
What is the explanation for this?
Thank you. | You can't raise an error 5005 in your own code. Only the DB Engine can do this.
Error 2732 is the error that says you can't raise messages < 50000
SELECT description FROM sys.sysmessages m WHERE m.error = 2732 AND msglangid = 1033
Error number %ld is invalid. The number must be from %ld through %ld and it cannot be 50000. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "sql server, tsql, raiserror"
} |
¿Cómo mostrar un MessageBox al terminar la carga de una ProgressBar?
Necesito hacer un programa en c# donde muestre el comportamiento de una ProgressBar para la carga de un MessageBox. Es decir, que cuando finalice la carga en la barra de progreso, aparezca el cuadro de mensaje.
private void btncargar_Click(object sender, EventArgs e)
{
tmrcargar.Start();
}
private void tmrcargar_Tick(object sender, EventArgs e)
{
this.prbmensaje.Increment(10);
if (prbmensaje.Value==100)
{
tmrcargar.Stop();
MessageBox.Show("HOLA MUNDO");
}
}
Si, la idea es crear un progressbar falso para mostrar un messagebox pero cuando ejecuto el programa me sale el messagebox antes de que llegue al maximo el progressbar | Me temo que lo que quieres hacer no es facil de conseguir. El problema es que, cuando tu aumentas el valor del progressbar, este incremento no se dibuja inmediatamente, si no que se produce una animación que tarda un tiempo en dibujarse. Por eso ves como el `MessageBox`aparece antes, porque realmente su valor ya es 100 en ese momento pero aun no se ha producido la animación.
Hay algun "hack" que puede simular lo que tu quieres, por ejemplo el código que te pongo a continuación lo que hace es, al llegar al maximo valor del `ProgressBar`, hace una pausa para esperar a que se dibuje la animación:
if (prbmensaje.Value == 100)
{
tmrcargar.Stop();
for (int i=0;i<10;i++)
{
System.Threading.Thread.Sleep(50);
Application.DoEvents();
}
MessageBox.Show("HOLA MUNDO");
}
Espero que esto te ayude a conseguir el efecto deseado. | stackexchange-es_stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "c#, progressbar"
} |
How to call the event of one element in another element in JQuery
Here I have some CSS buttons over an image. Basically what is happening now is when I click on the image, the image is zooming onto one position. Now I need the same. The CSS buttons are in a different position on the image. Now when I click the buttons over the image, it should zoom onto that portion of the image.
I also want the same to happen onclick on another div.
Here is my code..
<script>
$(document).ready(function(){
$('#ex4').zoom({ on:'toggle',duration: 500 });
$('.frame').css('width','100%');
$('#f1').zoom({ on:'toggle',duration: 500 });
});
</script>
In the above code, I have a element that has `id="ex4"` and an image. When I click on the ex4 element the image zooms up. Similarly, when I click the #f1, the image in ex4 should zoom up. How can I do this? | You need to Use **trigger()** :
$("#ex4").trigger("click"); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "javascript, jquery, html, css"
} |
Any special way to integrate $\int_{0}^{\infty}t^2\exp(-t)\sin(t)$ quickly?
Is there some trick to quickly integrate
> $$\int_{0}^{\infty}t^2\exp(-t)\sin(t)$$
or is there a way one can see that this integral equals $\frac{1}{2}$?
I'm asking because I am preparing for a test and it seems like integration by parts would take far too long. | Since $\int_0^\infty t^2 e^{-zt}dt=\frac{2}{z^3}$ if $\Re z>0$, the desired integral is $$\Im\int_0^\infty t^2\exp\Big[-(1-i)t\Big]dt=\Im\frac{2}{(1-i)^3}=\Im\frac{1}{\sqrt{2}}e^{3\pi i/4}=\frac{1}{\sqrt{2}}\sin\frac{3\pi}{4}=\frac{1}{2}.$$ | stackexchange-math | {
"answer_score": 5,
"question_score": 6,
"tags": "integration, analysis, improper integrals"
} |
combining two plots
I have the following two expressions:
v1[z]=(39 z^2)/160 - (23 z^3)/480
and
v2[z]=47/240 - (131 z)/480 + (17 z^3)/480 + z^4/24
I would like to calculate both for z that goes from 0 to 1, but I would like to plot both consecutively, i.e., `v1[z]` from 0 to 1 and `v2[z]` from 1 to 2 but evaluated from 0 to 1. How can I do this? Thanks | One way is to join the two functions together into a single Piecewise function:
v1[z_] := (39 z^2)/160 - (23 z^3)/480;
v2[z_] := 47/240 - (131 z)/480 + (17 z^3)/480 + z^4/24;
v[z_] := Piecewise[{{v1[z], 0 <= z <= 1}, {v2[z - 1], 1 <= z <= 2}}]
Plot[v[z], {z, 0, 2}]

gsub("^0", "", myvector) #The caret (^) makes sure only a starting 0 gets removed
[1] "SOME" "WORDS" "HAVE" "ZEROS" "IN" "THEM" | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -2,
"tags": "r, string, apply"
} |
How to create a script which adds role="presentation"
I want to create script which adds to all images on my page `role="presentation"` dynamically, but I dont know what type of function use for this. The image are added dynamically so I cant just add manually. Below I am uploading my source code.
//.attachment-large(class that img has)
//.elementor-inner-section (class that the div with images has)
(()=>{ function AddRole() {
const imageHook = document.querySelectorAll(".attachment-large");
const boxHook = document.querySelector(".elementor-inner-section");
boxHook.forEach((box) => {
imageHook.setAttribute("style","role: presentation") });
} AddRole() })(); | `role` is an attribute itself (as well as the `style`). So you need to run:
imageHook.setAttribute('role', 'presentation');
By the way, running it for `imageHook` must be enough, without a loop traversing the `boxHook` \-- you seem to have no dependency for that. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -2,
"tags": "javascript, attributes"
} |
Inspect Java HTTP connection pool
HttpUrlConnection uses persistent connections by default ( Is there any way to inspect Java HTTP connection pool? Eg check how many open connections in the pool? | Unfortunately no. In Oracle's VM, you can in theory inspect the static cache in `sun.net.www.http.HttpClient.kac` using reflection. This is a `Map`, which values are `Stack`s of cached `HttpClient` instances. The cache however also contains already closed or timed out connections and it does not seem to be a reasonable easy way to filter these out, without actually performing a real HTTP request, in which case abandoned connections will automatically reconnect. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "java, http, persistent, connection"
} |
Is it possible through group policy to disable NLA for specific computer
I have a test environment consisting of a windows server (2019) install that I am trying to remote into from a windows xp sp2 install. (the reason I am doing this is simply a testing grounds to better understand how rdp works) Because the 'client' is XP SP 2, it doesn't have NLA with it's RDP. I know that in server 2019 NLA can be disabled totally with group policy, but what I am trying to achieve is disabling NLA ONLY for the windows XP SP2 client while retaining it for all other potential clients. Is this possible? Thanks in advance. | The NLA option in the RDP server/service is a computer wide setting. Disabling it for one user account to connect is not possible.
If your server(s) cannot have NLA disabled, I would recommend upgrading Windows XP to SP3 and enabling NLA (link) or replacing it with a modern OS that supports NLA (amongst also not being a big security hole).
You can however use an alternate remote connection program to connect to the 2019 server, like VNC. If your goal however is to learn more about RDP, then learning how Network Level Authentication works would be a wise starting point. | stackexchange-superuser | {
"answer_score": 1,
"question_score": 1,
"tags": "windows, windows xp, remote desktop, windows server 2019"
} |
XSD choice inside sequence
I understand and use `xs:choice` and `xs:sequence` separately but I do not understand what `xs:choice` inside `xs:sequence` mean?
<xs:element name="sports-content">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="sports-metadata" />
<xs:element name="sports-event" />
<xs:element name="tournament" />
<xs:element name="schedule" />
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
Ok. This XML will be valid.
<sports-content>
<sports-metadata />
<tournament />
</sports-content>
Will this XML be valid or not?
<sports-content>
<sports-metadata />
<tournament />
<sports-metadata />
</sports-content> | The `xs:sequence` element in your XSD is superfluous; it can be removed without affecting validity of any XML document. An `xs:sequence` around an `xs:choice` would be useful, for example, if you wanted the choice to always be preceded or followed by one or more elements in sequence.
Yes, both of the XML documents in your question are valid against your XSD (and will continue to be if you remove the `xs:sequence` wrapper around `xs:choice`. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 4,
"tags": "xml, xsd, xsd validation, xml validation"
} |
ObjC animation won't run
I'm trying to change my view background color with this animation, it should change from blue to red to green but it won't run, I can't figure out what I'm doing wrong.
CAKeyframeAnimation * anim = [ CAKeyframeAnimation animationWithKeyPath:@"backgroundColor" ] ;
anim.values = @[ [UIColor blueColor],[UIColor redColor],[UIColor greenColor] ] ;
anim.autoreverses = NO;
anim.repeatCount = 7.20f ;
anim.duration = 0.1f ;
UIWindow *win = [[UIApplication sharedApplication]keyWindow];
[win.rootViewController.view.layer addAnimation:anim forKey:nil]; | You are trying to add animation to CALayer. CALayer's backgroundColor property have type CGColorRef, not UIColor. I've modified your code in the following way to make it work:
CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"backgroundColor"];
anim.values = @[(__bridge id)[[UIColor blueColor] CGColor],
(__bridge id)[[UIColor redColor] CGColor],
(__bridge id)[[UIColor greenColor] CGColor]];
anim.repeatCount = 7.20f ;
anim.duration = 10.0f ;
[self.window.rootViewController.view.layer addAnimation:anim forKey:nil]; | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "ios, objective c, animation"
} |
Are there any frameworks that allow me to write games in C# on Linux?
I'm looking for something like an alternative to XNA - I don't care whether it's a 2D or 3D engine. It's not because I dislike Windows or am anti-Microsoft; it's because I like running Linux, code in Linux completely (for C# I use Mono, obviously), and by no means have any hardware to actually support programming in XNA, simply because my video card is 6 years old. I also don't have a Windows 7/Vista CD for DirectX 10.
Thus, for game development I'm kind of stuck in the stone age. Yet, I like C# very much and would hate to have to drop it as a language due to this.
Is there anything I can do? | I'm afraid there is no such thing as a complete alternative to XNA in the world of C#-based cross-platform frameworks. Monoxna is long dead, and very few other cross-platform tools use C# as their language of choice.
However, this soon-to-be port of XNA on iOS and Android looks very promising: ExEn. Don't know about requirements though.
Since you've used word "engine" you may want something more complex. I can remember only one cheap full-fledged C# engine that can run on Linux and has pretty forgiving hardware requirements: NeoAxis.
However, if your primary target is 2D games, then you may check out this little cross-platform game library: AgateLib. Two years ago it was nice to use yet somewhat buggy, maybe now things are better.
Anyway, if anything else fails, you can always use OpenGL with SDL via OpenTK or SDL.Net. | stackexchange-gamedev | {
"answer_score": 9,
"question_score": 10,
"tags": "xna, c#"
} |
Rake RSpec Tasks are not showing up
I have an inherited app, running on Rails 3 in Ruby 1.9, and its working fine, but for some reason, when I installed both rspec and jasmine, neither of their rake tasks are showing up when I run rake -T. The Rakefile for the app is just the standard one, and in fact, when I installed Cucumber, its rake tasks show up just fine.
If I type in rake spec, there is no error, but none of my specs are run. But, if I type rspec spec, they all run, just fine. the jasmine tasks error out, saying there is no such tasks.
Any idea why these wouldn't be showing up, but other tasks would? | Do you have rspec-rails in the development group?
< | stackexchange-stackoverflow | {
"answer_score": 32,
"question_score": 11,
"tags": "ruby on rails, ruby, rspec, rake"
} |
Fetching all Git repositories in the background
I'm thinking about setting up a cronjob for fetching all my repositories every once in a while, to have the current status ready in case I'm offline. Something like the following (wrapped for better readability):
find $HOME -name .git -type d -printf "%h\0" |
parallel --gnu -0 --delay 0.2 --jobs 100 --progress \
'cd {}; git fetch --all --quiet'
I don't really care what happens if the fetch fails -- it might succeed the next time. Perhaps error output could be logged. My questions are:
* What if the background process fetches into a Git repository while I'm committing to it?
* Can you recommend other switches to `parallel` to make this really fail-safe? | I've been fetching my local Git repos in the background for two years now, without any sign of trouble. Currently, crontab contains something like
savelog -n -c 400 ~/log/git-fetch.log
find ~/git -type d -execdir [ -d '{}/.git' ] \; -print -prune |
parallel --gnu --keep-order \
"date; echo {}; cd {}; git fetch --all --verbose" \
>> ~/log/git-fetch.log 2>&1
(but in one line). | stackexchange-unix | {
"answer_score": 6,
"question_score": 5,
"tags": "cron, git"
} |
Ubuntu phone, Back to images overview button missing?
I've bought the new ubuntu phone last week, still figuring out how to accomplish one specific thing.
Steps to reproduce:
1. Launch the gallery app
* list with all pictures appears
2. Click on one of the pictures
* The image is loaded in fullscreen
I can't go back to the screen with all the pictures. Any thoughts how that can be accomplished ?
Best regards, Oleg | Touch somewhere on the screen and the back option will appear in the upper left corner. | stackexchange-askubuntu | {
"answer_score": 1,
"question_score": 1,
"tags": "ubuntu touch, phone"
} |
Do I need an amplifier to listen to the signal audio coming from a DAC?
I'm planning to use a DAC (digital-analog converter) to convert signal from an optical/toslink connection (Apple TV) to my speakers with 3.5 analog jack.
I'm wondering if I need an amplifier or if I can just connect the speakers (or eventually headphones) to the converter. | The 3.5mm analog jack should be an output at line level. This means that most headphones (not high-end audiophile headphones) should work well.
If you mean computer speakers, yes, they will work from that output as they are equipped with an internal amplifier. Larger speakers for home listening use will require a separate amplifier, as is the case with CD players, FM tuners, etc.
Just a note, this question may be considered off-topic for this forum as it is more concerned with home audio than audio production. I am not sure if stack exchange has a home entertainment forum. If not, it may be possible to suggest one. | stackexchange-sound | {
"answer_score": 0,
"question_score": 1,
"tags": "audio, conversion, signal processing"
} |
How to remove the top two empty rows in the excel sheet?
Below the sample codes. It's may help you.. When i'm change the row number(1) into 5 then seven rows are empty in excel sheet. **(LOCATION : setCellValueByColumnAndRow($col, 1, $field);)**
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setTitle("export")->setDescription("none");
$objPHPExcel->setActiveSheetIndex(0);
$fields = array('ram','one','two');
$col = 0;
foreach ($fields as $field)
{
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, 1, $field);
$col++;
}
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename="Export.csv"');
header('Cache-Control: max-age=0');
$objWriter->save('php://output'); | $objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setTitle("export")->setDescription("none");
$objPHPExcel->setActiveSheetIndex(0);
$field = array('ram','one','two');
$col = 0;
foreach ($fields as $field)
{
if(empty($field)){
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, 1, $field);
$col++;
}
}
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename="Export.csv"');
header('Cache-Control: max-age=0');
$objWriter->save('php://output'); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "php, phpexcel"
} |
Effects of Rings; Social effects
In my earth-like world, there is one thing that separate it from earth; this world has a single rocky ring, around 10.6 meters thick, 5(ish) miles wide and starts at the outer limits of the atmosphere. A less important feature that might be used in your answer, is that they have two small moons; one is 1/3 the size of our moon and the second is 1/4 its size.
We from our own Earthen cultures that small geographical features such as mountains, rivers, oceans or deserts can greatly affect cultural traits and beliefs. What effects would the ring add into society and cultural traits? | That would be quite low for a planetary ring but author fiat and all that. so 17 km to 2,017 km is rocky ring. earth is 12,742 km in diameter
1) it would be spectacular when near the equator and would most likely dominate equatorial religion. Looking like a wall or road in the in the sky visible 565.3 km away. underneath it would be a band across the center of the sky. later at night, it would be a black band blocking the stars but at dusk it would lit-up . I am thinking road deity. The flaming path something along those lines. limited to the equatorial region.
3) it would be under the horizon and hidden from most of the rest of the world 4) from space it would look like this.  | From the Horse's mouth:
> Operator `.` (dot) could in principle be overloaded using the same technique as used for ->. However, doing so can lead to questions about whether an operation is meant for the object overloading `.` or an object referred to by `.` For example:
class Y {
public:
void f();
// ...
};
class X { // assume that you can overload .
Y* p;
Y& operator.() { return *p; }
void f();
// ...
};
void g(X& x)
{
x.f(); // X::f or Y::f or error?
}
> **This problem can be solved in several ways. At the time of standardization, it was not obvious which way would be best.**
AFAIU the same reasoning applies for `.*` | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 2,
"tags": "c++, operator overloading"
} |
Consciousness and computation
What are the links that are proposed between consciousness and computation? I.e. what are the theories of how computation creates consciousness? | See James A. Reggia: **The rise of machine consciousness: Studying consciousness with computational models.** Neural Networks 44 (2013) 112–131 - The paper surveys some of the currently discussed models namely
* Global workspace
* Information integration
* Internal self-models
* Higher-level representation
* Attention mechanisms
I can send you the paper on request. | stackexchange-philosophy | {
"answer_score": 1,
"question_score": 0,
"tags": "consciousness, computation, theory of mind"
} |
Blocks overlapping in css
I have 2 blocks within a block that needs to be displayed-inline but it does not work when I give display-inline.
Fiddle: <
I need the 2 blocks to be displayed side by side instead of overlapping
HTML:
<div class="outer-container">
<div class="inner-container">
<div class="innermost-container" />
<div class="innermost-container" />
</div>
</div>
CSS
.innermost-container{
background-color:green;
width:100px;
height:100px;
border-style:solid;
border-width:5px;
} | Change
<div class="innermost-container" />
to
<div class="innermost-container"></div>
`<div />` is not valid HTML markup.
Write:
.innermost-container{display:inline-block;}
Note:
`inline-block` leavers white-space between elements. Write elements on same line to avoid white-space.
write:
<div class="innermost-container"></div><div class="innermost-container"></div>
instead of
<div class="innermost-container"></div>
<div class="innermost-container"></div>
**DEMO here.** | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "html, css"
} |
Do people use 刻苦 nowadays?
I'm trying to figure out two things.
1. Is still commonly used in China? Is it colloquial? For example, could I say “”
2. If it is used, are there any clear differences with “”? Or are they pretty close synonyms? | 1. Yes is still commonly used in colloquial language.
2. “” is grammatical. In spoken language it sounds more natural to say “” .
3. is 'hardworking' while is 'take seriously'. They are idiomatically used together (''), but they are not synonyms. Actually you can say things like '' meaning he is taking it seriously enough but he needs to devote more time. | stackexchange-chinese | {
"answer_score": 10,
"question_score": 3,
"tags": "vocabulary"
} |
How to make a WPF TextBox use password characters?
i need to set it it dynamicaliy..
Can i make password Box to as normal text- i mean- user could see the text what he entered.???
its for-> i need to use same control for " password sesion" and also the "item count entering" session ..?? | You have to use `PasswordBox` instead of `TextBox`:
<PasswordBox Height="42" Width="200" Margin="22,28,28,0"
Name="passwordBox1" VerticalAlignment="Top"
Background="LightBlue" Foreground="DarkBlue"
MaxLength="25" PasswordChar="*"
/> | stackexchange-stackoverflow | {
"answer_score": 55,
"question_score": 30,
"tags": "wpf, vb.net, winforms, textbox, passwords"
} |
How to execute the code of VB 6 from Visual Studio 2010, or I need to download VB 6?
Can anyone guide me ,whether is aany method to open a VB6 code from Visual Studio 2010? Or i need to download VB 6 Compiler separately?(If yes, then please send the link from where i can download the VB6 or guide me from where i can download it?) | Visual Studio (starting with Visual Studio .NET 2002) does not compile Visual Basic 6.0 projects. You will need to legally obtain Visual Basic 6.0 to compile the code.
If you just need the Visual Basic 6.0 runtime, most modern Windows versions have it installed. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 0,
"tags": "visual studio 2010, vb6"
} |
Generate n consecutive dates with even day-part after today's date (for example for 2020-06-08 it will be 2020-06-10, 2020-06-12, 2020-06-14 ect.)
i need a bit help i dont know wat is wrong in my code . Plz help.
create procedure consecutive_N_even_day
@n int
as
begin
declare @na int
set @na = 0
declare @nexndate date
declare @date date
set @date=GETDATE()
declare @datepart int
while(@na<@n)
begin
set @nexndate=DATEADD(DAY,@na,@date)
set @datepart=DATEPART(day,@nexndate)
if @datepart%2=0
begin
print @nexndate;
end
set @na=@na+1
end
end | You can use a recursive query for this:
with cte as (
select dateadd(day, day(getdate()) % 2, cast(getdate() as date)) dt, 0 n
union all
select dateadd(day, 2, dt), n + 1 from cte where n < @n
)
select * from cte
The query starts from today (if it is an even day) or tomorrow, and then produces a series of dates with a 2 days increment. It iterates `@n` times.
You don't specify what to do if we reach the end of a month that has an uneven number of days. It is always possible to adapt the logic of the recursive part of the query to what you actually need in this case.
If `@n` is greater than `100`, you need to add `option (maxrecursion 0)` at the very end of the query. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "sql, sql server, date, stored procedures, recursive query"
} |
Hibernate limit result inquiry
How does maxresult property of hibernate query works? in the example below :
Query query = session.createQuery("from MyTable");
query.setMaxResults(10);
Does this get all rows from database, but only 10 of them are displayed? or this is same as `limit` in sql. | It's the same as `LIMIT`, but it is database-independent. For example MS SQL Server does not have LIMIT, so hibernate takes care of translating this. For MySQL it appends `LIMIT 10` to the query.
So, always use `query.setMaxResults(..)` and `query.setFirstResult(..)` instead of native sql clauses. | stackexchange-stackoverflow | {
"answer_score": 11,
"question_score": 7,
"tags": "java, hibernate"
} |
Magmi blank page while importing products
I am using Magmi on a regular basis to mass import products.
Unfortunately, every 100-like products the application freezes as shown on the following image: ?"--- One day I asked this question to my friend and he replied that the statement is not correct but didn't give me any reason and I couldn't find any proper justification online. I was confused as I just transformed the sentence "I have my mobile phone inside" into an interrogative one. Is it grammatically wrong? | > "Do I have my mobile phone inside the restroom?" or "Do I have my phone there(some place)?"--- One day I asked this question to my friend and he replied that the statement is not correct but didn't give me any reason and I couldn't find any proper justification online. I was confused as I just transformed the sentence "I have my mobile phone inside" into an interrogative one. Is it grammatically wrong?
_Note that what follows is my answer but I have duplicated some of what was said in the comments._
* * *
You sentences are _grammatically_ correct but they don't have a sensible meaning.
If you _have_ your phone then you don't need to ask where it is because "have" implies that it is with you.
"I have my mobile phone inside." - If you have a phone inside then either you have it inside you (you have swallowed it) or you have it inside something you are carrying with you (inside a container).
* * *
A possible question is, "Is my mobile phone inside the restroom?" | stackexchange-english | {
"answer_score": 1,
"question_score": -1,
"tags": "grammar, grammaticality, verbs, sentence, questions"
} |
Menu item navigating to localhost rather than the home page
I have a navigation bar on my website with a menu item the home page. When I click on it, it takes me to the localhost main page but not the home page of the website.
<div class="top-navigation-bar">
<ul>
<li><a href="/">HOME</a></li>
<li><a href="#">POPULAR</a></li>
<li><a href="#">FEATURED</a></li>
<li><a href="#">CONTACT US</a></li>
<li><a href="/submit">SUBMIT</a></li>
</ul>
</div>
For the home page, I am using the default route:
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
(I'm using the CakePHP framework.)
I am using MAMP and I believe it has something to do with MAMP but not CakePHP or my code. | Just change your link (`<a href="/">HOME</a>`) to `<?php echo $this->Html->link('Home', '/'); ?>`.
A link that points to `'/'` will always link to the root of the web server. Using Cake's HtmlHelper's `link()` method, `'/'` will resolve to the root of the app instead of the root of the web server and output the `<a>` tag you need. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "php, cakephp"
} |
Proper sentence structure and word usage when using the word, "imbue."
I wrote, "Imbuing a love of reading in youth is a high calling," to a friend and then questioned my usage of the word, "imbue." Does anyone think the way I used it was incorrect in terms of structure? Would,"Imbuing youth with a love reading is a high calling," a better choice? | You are fine. "Imbue" is a transitive verb and it works somewhat like "give". You can "imbue (the) youth with a love for reading" or you can "imbue a love of reading in (the) youth", just as you can "give me a book" or "give a book to me".
However, I would generally prefer "imbue (the) youth with a love for reading" and "give a book to me". | stackexchange-english | {
"answer_score": 0,
"question_score": 0,
"tags": "word usage"
} |
What are initials?
I am filling a form for living in the campus on a university in Australia. The due date for sending this application is near, and I have asked the very same question to them in e-mail and haven't got an answer. I fear that I will not get the answer before the due date, so hopefully I have come to the right place to ask this question.
Bottom of the contract it says "Resident initials here", now what's initials? I searched a bit and found out that it's the first letter of my name followed by first letter in my last name and surname.
If my name is Muazam Al Ace, are my initial "MAA"? So do I write "MAA"?
So my question is, are they asking for my signature or initials which does not make sense to me.
One more question: "Resident’s Representative for Notices" - is it here I fill in my parents? | An initial is the first letter of a word.
So yes, you're the resident, and your initials are _MAA_ , so write those on the form. | stackexchange-english | {
"answer_score": 21,
"question_score": 21,
"tags": "meaning, meaning in context, nouns"
} |
Ant: Converting a path into separate properties
I have a folder containing several jar files which should all go to a classpath:
<path id="my.classpath">
<fileset dir="/tmp/mylibs" includes="*.jar" />
</path>
Now I would like to be able to reference all these jar files as a seperate property, e.g. if I have two jar files foo.jar and bar.jar then I would like to be able to reference them like
${foo.jar} (== /tmp/mylibs/foo.jar)
${bar.jar} (== /tmp/mylibs/bar.jar)
Is that somehow possible in Ant?
Thanks, Peter | With help of ant-contrib you can try this:
<target name="test">
<ac:for param="file">
<fileset dir="/tmp/mylibs" includes="*.jar"/>
<sequential>
<antcall target="setImpl">
<param name="file" value="@{file}"/>
</antcall>
<echo>param: @{file}</echo>
</sequential>
</ac:for>
</target>
<target name="setImpl">
<property name="filename" value="${file}" />
<echo>property: ${filename}</echo>
</target>
For overriding property value (if you need) purpose you can also use ant-contrib | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "ant, properties, jar, classpath"
} |
How to determine contrast of an image according to formula in matlab
I want to determine contrast of an image in matlab . Here is the formula of contrast of a image :

result=1/prod(size(I))* sum(I(:))
The above code is taken from this question
But how can I determine contrast according to the above formula ? Please help me . | I have got the answer . Beaker helps me a lot for this answer. . Here is the code :
I=imread('autumn.tif');
B=1/prod(size(I))* sum(I(:))
contrast = sqrt(1/prod(size(I))*sum(power((I(:)-B),2)))
Hope this may help someone . | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "matlab, sum"
} |
How can I find the angle of the surface/3D Plane.
I have a plane with equation 3x + 2y + 5z - 19 = 0. With the help of Python/MatPlotlib, I could draw this plane also. Please find the image below.
$, from that we can find the angles we are interested in using dot product.
For example the angle for the normal with $x-y$ plane, with normal $e_3=(0,0,1)$ is given by
$$\cos \theta=\frac{n\cdot e_3}{|n||e_3|}=\frac{5}{\sqrt{28}}$$ | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "geometry, 3d, angle"
} |
Efficient way to get bit in binary expansion of [0,1] real in Mathematica?
As is well known, any real in [0,1] can be written as a binary expansion in base 1/2:
x = b1 * 1/2^1 + b2 * 1/2^2 + ...
I would like an efficient way to get **bi** for a given **x** and index **i** , and I don't think there's any built-in way to do that in Mathematica. IntegerDigits and RealDigits don't seem to be able to help, and none of the related functions are pertinent.
The obvious solution is to do the manual conversion, but I was hoping to avoid that. Am I missing something?
**EDIT** : for future reference, what I was looking for can be done this way,
BinaryExpansionBit[p, j] := RealDigits[p, 2, 1, -j][[1]][[1]]
where
BinaryExpansionBit[x, i]
gives the **bi** I was talking about. | It depends on what you mean by "efficient". Mathematica can easily convert to binary, as this Wolfram Alpha example shows.
Otherwise what you are looking for is the parity of the integer part of `x * 2^i`. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "binary, wolfram mathematica, expansion"
} |
Why Does XGBoost Keep One Feature at High Importance?
I am training an XGboost model for binary classification on around 60 sparse numeric features. After training, the feature importance distribution has one feature with importance > 0.6, and all the rest with importance <0.05.
I remove the most important feature, and retrain. The same distribution forms; the most important feature has importance > 0.6, and the rest have < 0.05. I continued to remove the most important feature and retrain, remove and retrain, remove and retrain, etc. My f1-score started to drop, but every time there was one feature more important than the rest.
Also worth noting, when I removed the most important feature and retrained, the new most important feature was not the second most important feature from the previous training.
I cannot explain this behaviour intuitively. Does anyone know why this pattern arises? | According to the docs "gain" is the default, which is calculated by this formula, where I don't think intuition would help. General consensus is, that feature importance is a tricky concept, as long as your model performs fine, you shouldn't worry about it. Especially with the linked formula for gain you can see that the first split may be the most important by far, depending on gamma, so that every other feature importance is low by default.
If, on the other hand you chose "weight", that would be just be the number of times the feature is chosen to split. That may mean that one feature contains a lot of unique values and can be chosen a lot of times and still improve accuracy.
All of this depends heavily on the data and parameters you are using. There isn't any general answer to this pattern. | stackexchange-datascience | {
"answer_score": 3,
"question_score": 5,
"tags": "python, classification, xgboost"
} |
How to draw the graph of $y=(2x^2+13x+9)/(6x+3)$
We haven't learnt how to design the graphic when the denominator has x, and it cannot be simplified. Can you just tell me the steps or lead me to a web address? | Let $f(x)=\frac{2x^2+13x+9}{6x+3}$ and try to find the values of $f$ for different values of $x$, find these pairs on and x-y axis and you will have a picture of this function:
!enter image description here
and more and more points:
!enter image description here
of course comments above are very helpful. | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "graphing functions"
} |
Why the determinant of even-sized magic matrices are zero? Anything special?
The determinant of even-magic square matrix is 0.
For example, this 4x4 magic square matrix:
{{16, 2, 3, 13},
{5, 11, 10, 8},
{9, 7, 6, 12},
{4, 14, 15, 1}}
And this 6x6 matrix:
{{35, 1, 6, 26, 19, 24},
{30, 5, 7, 21, 23, 25},
{31, 9, 2, 22, 27, 20},
{8, 28, 33, 17, 10, 15},
{3, 32, 34, 12, 14, 16},
{4, 36, 29, 13, 18, 11}}
So is true for 8x8,10x10...
Is there anything special here? Is it possible to recognize this kind of matrix and conclude that its determinant is zero?
Reference for magic square matrix: < | It is known that there are essentially $880$ different $4\times 4$ magic squares, of which $240$ are nonsingular. See
> Dave Pountney, _On Powers of Magic Square Matrices_.
Some magic squares created with special methods are also known to be singular. For instance, your $4\times4$ example has the property that the sum of any pair of entries that are symmetric about the center of the matrix is equal to the magic constant (i.e. $a_{i,j}+a_{n+1-i,n+1-j}=n^2+1$ for each $(i,j)$). It's easy to explain why this is singular. See, for instance,
> R. Bruce Mattingly (2000), _Even Order **Regular** Magic Squares Are Singular_, The American Mathematical Monthly, 107(9): 777-782. | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "matrices"
} |
Complex Green's Theorem
I want to integrate $\int_{\partial R} |e^{zt}|dz$ where $R\subseteq \mathbb{C}$ is a rectangle whose sides are parallel to the coordinate axes. I want to use a complex version of green's theorem, but I keep getting an imaginary solution, which doesn't seem right.
The formula I have is $\oint_C f(z)dz=i\int \frac{\partial f}{\partial x}+i\frac{\partial f}{\partial y}dA$.
Say the rectangle $R=\\{x+iy:a\leq x\leq b, c\leq y\leq d\\}$
$\int_{\partial R} |e^{zt}|dz=\int_{\partial R} e^{xt}dz=i\int_R te^{xt} \ dA=it\int_a^b\int_c^de^{xt}dydx\in \\{Re(z)=0\\}$
Am I doing something wrong, or is my intuition off? | The intuition is off. Since $t$ is real, the integrand takes identical values on the two sides of the rectangle parallel to the real axis, and since the two sides are traversed in opposite direction, these integrals cancel. We are left with the integrals over the sides parallel to the imaginary axis, where the integrand $\lvert e^{zt}\rvert$ is real (of course), and the differential $dz$ is purely imaginary, $dz = \pm i\,dy$ there, since the real part is constant. So the integral must be purely imaginary. | stackexchange-math | {
"answer_score": 1,
"question_score": 2,
"tags": "complex analysis, definite integrals"
} |
angular-ui shift button keypress
I've managed to get enter keypress to work. But I can't seem to get the "shift" button keypress to work. Here is my code for enter:
<button
class="btn btn-primary order-input-add"
ui-keypress="{13:'add_plu(order.orderwindow.add_field)'}"
ng-click="add_plu(order.orderwindow.add_field)">Add
</button> | Since it seems that you can't capture a shift key press by itself using ui.keydown (if so, probably because it's most often used as a modifier key), you can instead create your own directive that decorates an element to listen for shift on the keydown event:
angular.module('myApp', [])
.directive('captureShift', function(){
return {
restrict: 'A',
link: function(scope, elem, attrs) {
elem[0].onkeydown = function(){
console.log('shift pressed');
}
}
}
});
Shift doesn't seem to fire on keypress but does on keydown, so `onkeydown` is used.
Plunker Demo | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "javascript, angularjs, angularjs directive, angular ui"
} |
Dell TPM what is it and can it be attached to Dell R210 server?
I read about Dell producing TPMs for their products. What is TPM physically ? Is it module to plug inside the machine or is it like usb hash code generator or is it something else? And do they supply TPMs for their server line (I have Dell R210 with w2008R2) ? What are the costs? | Apparently all Dell R210 servers (or most of them excluding countries like China, Russia, Brazil if I am not mistaken) got TPM chip. That what would be a sensitive answer on my question. | stackexchange-serverfault | {
"answer_score": -3,
"question_score": -4,
"tags": "windows server 2008, security"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.