INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Is there a word for "be popular for a time"?
Something had been popular for a period of time. How do I describe it?
|
There's several ways to say this.
> It's all the rage right now.
That implies it extremely popular right now.
> It's the current fad.
That's what's popular right now.
If you're speaking about the past I'd say
> It was the trend at the time to wear fur boots.
|
stackexchange-ell
|
{
"answer_score": 0,
"question_score": 1,
"tags": "word request"
}
|
How to send a single request to a particular person in Facebook? (in FBML)
Instead of popup the multiple friend selector, how to do it only for one friend?
|
You can use the request-form-submit fbml tag to do this: <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "facebook, fbml"
}
|
Joomla: Listing recently modified pages
It's easy enough to show recently modified articles, but I need to list page URLs on a Joomla site that have been most recently modified. Is this straightforward? Is there a module for this?
Many Thanks
|
From the menu manager you can list all the articles in a category.
Check the options `Article Order` -> `Most recent first`
`Date for Ordering` -> `Modification date`
Otherwise you need to search harder for an extension that does that test your programming skills building a module or a new view in com_content which display what you need.
Let me know if this helps.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "joomla"
}
|
Test case for testing a textbox in c# with NUnit
I want to test a textbox to determine if is empty or not (at a press of button for example), within a graphic Interface in C# with NUnit.
I do not really know how to write this kind of test case in the test method in my test class and searching the internet did not quite help me (or I did not know where to look).
I only found tescases like sum of 2 numbers and the expected result, but none with the interface.
So, I thought of throwing an exception in my class and in the testClass I wrote something like this:
[Test]
[ExpectedException(typeof exception))]
public void TestTextbox()
{
Produs target=new Produs();
target.textbox1.text="";
Assertion.AssertEquals("*",label.text); //label.text should be: 'complete all fields'
}
It is clearly not entirely correct.
Can you please tell me what is the right way to write a test case for a textbox.
|
NUnit is for unit testing. What you wanted is probably an Automated/ Coded UI Testing.
If your'e using Visual Studio Ultimate/ Premium, take a look here for Verifying Code by Using UI Automation: <
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "c#, nunit"
}
|
Integrating FastPdfKit with a PhoneGap application
I'd like to integrate a FastPdfKit Reader into my PhoneGap application. That is, the PDF reader should be opened within the PhoneGap app, so that the application-related navigation is still visible.
Where do I best start? Do you know about any publicly available code that gives an example on how to achieve this?
|
It sounds like what you are looking for is creating a PhoneGap plugin.
<
Here are some tutorials on making plugins for PhoneGap:
<
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 3,
"tags": "ios, ipad, pdf, cordova, phonegap plugins"
}
|
How to manipulate current task's Activity back stack?
Currently I have 3 `Activity` classes A, B and C.
Activity A is a `singleTask` while other has the default launch mode. Consider a case: the user is first in A, then starts B, and then starts C.
The back stack now is ABC.
Next, the user starts A again.
The back stack now is A, but what I would like to be achieved is ABCA.
I know not setting `Activity` A to be `singleTask` can have a back stack : ABCA. But I really need the Activity A to be the same instance.
Anyone know how to do this?
|
You have stipulated two conditions:
> what I would like to be achieved is ABCA.
and
> I really need the Activity A to be the same instance.
These two conditions are mutually contradictory. Absolutely.
What you want is impossible.
That is all.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "android, android activity, back stack, android task"
}
|
How to generate Java keystore from X.509 Certificate
I am trying to generate Java keystore from X.509 Certificate file, and don't know how. On other word, I want to convert X.509 (application/pkix-cert) to java Keystore (application/x-java-keystore). Do you have any idea how to do it ? Thanks
|
For add the certificate to your keystore is this:
keytool -importcert -keystore [keystore location, varies, but can be e.g.
/etc/pki/java/cacerts] -storepass changeit -file /tmp/lb.cert -alias
newSelfSignedKey -noprompt
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "java, x509certificate, keystore, truststore"
}
|
¿Consume ancho de banda realizar consultas a la base de datos desde otro sitio web?
¿Consume ancho de banda en el sitio web original el obtener datos desde otro sitio?
Estoy obteniendo con Ajax datos del 'sitio web original' desde otro sitio web, hago simplemente eso, me interesa saber si esto gasta recursos del servidor de ese sitio o no, ya que quiero contratar un hosting solo para base de datos pero de pronto se consuma el ancho de banda y no pueda obtener nada después.
Este es el script que estoy utilizando desde el sitio web que obtiene los datos del sitio web donante.
$.ajax({
data:parameters,
url: 'get.php',
type: 'POST',
success: function(mensaje) {
alert(mensaje);
}});
|
Tu mismo te estas autocontestando en el momento que mencionas "Estoy _**obteniendo**_ con Ajax _**datos**_ del 'sitio web original'"
Cuando realizas un request mediante AJAX, en cierta manera es como si visitases esa web, así que en mayor o menor medida vas a utilizar ancho de banda y recursos del servidor al que estás haciendo el request.
|
stackexchange-es_stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, mysql, ajax"
}
|
Is there a way to fire ResourceTaskStart block programmatically without a Downtime block?
Leading into a preparedUnits port of a Seize block, I'd like a cart to arrive at a dropoff location before the delivery truck arrives at the same spot. I thought there would be a function similar to a `source.inject(1);` for this block, but I'm not finding anything quite like that. Does something similar exist?
|
This is not how the block is supposed to work.
If you want to design an upfront flow manually, you need to manage it yourself: You either put an "Enter" block and use `enter.take(myAgent)` to start a custom flow. Or you use a source block to create a new agent for your custom flow.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "function, anylogic"
}
|
Proof that any $\,a \ge 20\,$ can be written as $\,a = 5b + 6c\,$ where $\,a,\, b\,$ and $\,c \,$ are Natural Numbers
I'm currently working on a problem for an assignment, so forgive me if my question is a little clumsy or vague. I'm trying to get myself headed in the right direction and offer a meaningful question here without just being handed the answer.
I'm trying to prove that $\,\forall\,a\in\mathbb{N}: \left[a \geq 20 \wedge\exists b,c \in\mathbb{N}: a = 5b + 6c\right] \rightarrow\exists\; b,\,c \in\mathbb{N}: a + 1 = 5b + 6c$
I really haven't a clue where to begin. I would appreciate any hint or suggestion as to an approach.
|
Hint: If you can prove that $20,21,22,23,24$ can each be written in such a way, then you can add one extra five to each of those and thereby represent $25, 26,27,28,29$.
|
stackexchange-math
|
{
"answer_score": 5,
"question_score": 2,
"tags": "induction, proof explanation"
}
|
Rails generates wrong asset url in production (with localhost instead of server ip)
Rails 6 in production generates wrong asset path url with <
When I replace < with server IP assets load fine, so it's just url generation error by rails.
System is run on digital ocean with Passanger on Nginx.
|
Try to add `config.action_controller.asset_host = "assets.example.com"` to `/config/environments/production.rb`
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "ruby on rails, ruby on rails 6"
}
|
SQL - MYSQL One query recieving set limit on different column values
Lets say i have a table with a set of different columns (offcourse),
Example :
Table
id
col1 INTEGER(1), // 0 || 1
col2 // --||--
col3 // --||--
col4 // --||--
Is it possible, in 1 query to select 4 rows where col1=1 and then select 4 rows where col2=1 and then select 4 rows where col3=1 etc etc. I think you understand what i mean.
What i have done so far is to make 4 different queries OR make one query and just do a (col1 = 1 OR col2=1 OR... etc).
This works but if i limit that result to lets say 16, then i might get 15 rows with col1=1 and maybe 1 row with col2=1 and then col3,col4 - no result.
So dear fellas; is there a way to do this in 1 query (i think not)
|
Select * from table where col1=1 limit 4
Union
Select * from table where col2=1 limit 4
Union
Select * from table where col3=1 limit 4
Union
Select * from table where col4=1 limit 4
This will get you one result with 16records max. If there are less then 4rows for a certin criteria, you'll get less rows. Duplicates will be removed, resulting in less then 16 rows. Not different rows.
If for a single row `col1=1 and col2=1`, then it might be returned twice if you use `union all`, but just `union` is slower with large datasets
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "mysql, sql"
}
|
Permutations - counting
Four girls bought each a swimsuit , and they decided to share them . How many days are needed so that each girl will wear each swimsuit once ?
|
If order matters, there are 20 ways to choose 1st place, 19 ways to choose 2nd place, ..., 16 ways to choose 5th place: ${}_{20}P_5 = 20(19)\cdots(16) = 1\,860\,480.$ [Computation in R.]
prod(20:16)
[1] 1860480
If order does not matter: ${}_{20}C_5={20\choose 5} = \frac{20!}{5!\cdot15!} = 15\,504.$
choose(20, 5)
[1] 15504
|
stackexchange-stats
|
{
"answer_score": 0,
"question_score": -2,
"tags": "permutation"
}
|
Balance docker service in docker node groups instead of nodes
I have the following problem:
I have a docker service with 2 replicas and 4 workers splitted in 2 different datacenters.
I know when swarm spawns new replicas will do it in a different host each time. Is it possible to configure it to spawn it in different groups of nodes if I label them somehow?
|
Yes you can.
You can attach labels to nodes, as follows:
docker node update --label-add region=east worker-1
docker node update --label-add region=east worker-2
docker node update --label-add region=west worker-3
docker node update --label-add region=west worker-4
You can then start your service with contraints or placement-prefs:
# This will force your service to only run on nodes in your 'east' region
docker service create \
--name myservice-east \
--replicas 2 \
--constraint node.labels.region==east \
yourimage
# This will spread the replicas across the regions:
docker service create \
--replicas 2 \
--name spread-service \
--placement-pref 'spread=node.labels.region' \
myotherimage
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "docker, docker compose, docker swarm"
}
|
what is the use of mysql_pconnect
mysql_pconnect as I read does not close when the mysql_query ceases.. in that case why do we use this command?? does that create any security issue??
|
First of all, it's worth noting that persistent connections are not MySQL-specific.
What's their purpose? They allow to reuse a database connection in different script calls. Otherwise, scripts must open new connections every time they're executed. This is particularly useful when opening a new connection is an expensive operation.
In my personal experience, they should be avoided when coding with PHP and MySQL for these reasons:
1. PHP does a very poor handling of the connection pool and you're likely to have a hundred idle connections that are not being reused.
2. MySQL allows to open new connections pretty quickly compared to other DBMS.
I'm not sure about what security issues you have in mind. In order to reuse an idle connection, your PHP script needs to provide the same credentials that were used to open it. If script A opens a connection as root, script B cannot use it with other user.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "mysql"
}
|
Visual Studio error?
About a half dozen times now, I’ve been doing a regular chore in Visual Studio – either running a unit test or simply compiling, updating something from SVN or whatever, and visual studio just disappears… it shuts down and goes away instantly… it is fine when I restart it, and I don’t see the problem again for a while… it keeps happening, and for random reasons… has anyone else experienced this?
One thought is that i'm using AnkhSVN, but if you've had this problem and don't experience this, please let me know.
|
All of the devs on my team see this problem quite often. It isn't AnkhSVN because we don't use it. I believe it is C++ intellisense, but that is just a feeling. Sometimes it happens when we are not doing anything. We will go for coffee, come back and it is just gone.
It never happens to me on smaller projects, but happens frequently on our large (several million lines, dozens of projects) solution with a mix of unmanaged C++, managed C++ and C#.
We have seen it less frequently since upgrading to SP1.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "visual studio 2008"
}
|
RJ45 Crimping - Do I have bad plugs?
I have a basic crimping tool that so far worked most of the times. I am a hobbyist when it comes to computers and networking.
Recently I bought a few new plugs and now crimping simply does not work. I do not hear a 'click' and after pressing it hard, eventually the plug remains in the tool and wires comes off if pulled.
I suspect the wires are not reaching the end of the plug where metallic contacts are present. The question is if wires do not extend full up to the end of the inside of the plug, will crimping happen or does it require presence of wires over the metallic contacts?
After failed crimping the plug looks the same just like rest of the other unused plugs.
|
Yes, you must strip the outside shielding enough to fully insert the wires into the RJ-45 clip. When you crimp the clip, you are actually pushing the wire tines into the cat-5/6 wires. So, if they are not fully seated, they will not form an electrical connection and not function correctly.
|
stackexchange-superuser
|
{
"answer_score": 2,
"question_score": 0,
"tags": "networking, rj 45"
}
|
Sliding window minimum algorithm
This is a homework problem. Let A[] is an array of integers and integer K -- window size. Generate array M of minimums seen in a window as it slides over A. I found an article with a solution for this problem but did not understand **why** it has O(n) complexity. Can anybody explain it to me?
|
This tends to catch people out. You would think it would take `O(N^2)` time since you reason adding takes `O(N)` time and you have `O(N)` elements. However, realise each element can only be added once and removed once. So in total it takes `O(N)` to slide over the whole array `A`.
This yields an amortised efficiency of `O(1)` every time you move the sliding window on by one element. In other words, the average time it takes to move the sliding window by one element is `O(1)`.
|
stackexchange-stackoverflow
|
{
"answer_score": 9,
"question_score": 5,
"tags": "algorithm, sliding window"
}
|
Why simple XML parser doesn't fill struct
Trying to implement a simple XML parsing, the code below doesn't work as expected.
It just returns a `{[]}` empty `Results`, while it should fill it.
Why ?...
package main
import "fmt"
import "encoding/xml"
import "bytes"
type Name struct {
Name string `xml:"NAME"`
}
type Results struct {
Names []Name `xml:"RESULTS"`
}
func main() {
data := []byte(`
<?xml version="1.0" encoding="UTF-8"?>
<RESULTS>
<NAME>Apple</NAME>
<NAME>Banana</NAME>
</RESULTS>
`)
var r Results
decoder := xml.NewDecoder(bytes.NewBuffer(data))
unError := decoder.Decode(&r)
if unError != nil {
fmt.Println("XML Unmarshaling error:", unError )
}else{
fmt.Printf("%v", r)
}
}
Tryed in the Playground, and locally (go1.17.2).
|
I would suggest you to use a online struct generator like xmltogo, so use this as:
type RESULTS struct {
XMLName xml.Name `xml:"RESULTS"`
Text string `xml:",chardata"`
NAME []string `xml:"NAME"`
}
Try on playground
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "go, xml parsing"
}
|
Post form data to a new page and show that page with the posted data
I have: form.php preview.php
form.php has a form in it with many dynamically created form objects. I use jquery.validation plugin to validate the form before submitting. submit handler:
submitHandler: function() {
var formData = $("#myForm").serialize();
$.post("preview.php", {data: formData },function() {
window.location.href = 'preview.php';
});
Question: \- How to change the current page to preview.php and show the data? my submitHandler doesnt work? Any tips?
preview.php:
$results = $_POST['data'];
$perfs = explode("&", $results);
foreach($perfs as $perf) {
$perf_key_values = explode("=", $perf);
$key = urldecode($perf_key_values[0]);
$values = urldecode($perf_key_values[1]);
}
echo $key, $values;
enter code here
|
I managed to solve my problem. without sessions.
add to form:
<form action="preview.php" onsubmit="return submitForPreview()">
<input type="hidden" name="serial" id="serial" value="test">
js:
function submitForPreview()
{
if($("#form").valid()){
$('#serial').val($("#newAdForm").serialize());
return true;
}else{
return false;
}
}
preview.php
echo $_POST['serial'];
//Which shows the serialized string. YEEEEYYY :D
Thanks for help folk :D
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php, jquery"
}
|
Move file XSLT - Create new XSLT
When I'm doing a convertion with XSLT, I need to put in the output directory, another XSLT file. This XSLT file always have the same code.
I don't know if I can copy and paste a file with XSLT. I tried to create a new document with `<xsl:result-document>` but it's seems not appropriate
Thanks
|
If you use
<xsl:result-document href="outputdir/sheet.xsl">
<xsl:copy-of select="document('sheet.xsl')"/>
</xsl:result-document>
then a copy of `sheet.xsl` will be created in `outputdir`.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "xml, xslt, xslt 1.0, xslt 2.0"
}
|
How to check Docker RAM and cores configuration from terminal? (MacOS)
I would like to find out what are the max RAM and cores available to a new docker container. Using Docker GUI, I can click on the Docker icon, then going to Preferences --> Advanced. Two sliders show up, and the values selected on the sliders, are the values I am interested in. However, I can not use the GUI and want to find out via terminal. Is this possible?
(Note - I am not interested in _modifying_ these values, only discovering what they are, via terminal.)
|
Ok I came across this:
find $HOME/Library/Containers/com.docker.docker -type f -name '*.json' | xargs jq -r .arguments
(jq is just a utility which will let you manipulate/parse about the json. < . . That file itself is not very readable.)
You will see entries in the json:
"-c",
"5",
"-m",
"4096M",
This corresponds to the current values you'd see on the sliders.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "macos, docker, terminal"
}
|
what is the shorcut for Mean uncrease
With the face or edges selected. In edit mode when press `Shift`+`E` i can make Mean Crease to make the edge sharper. But after making the crease if i want to remove the crease i have to go in N panel in Edges Data to give a value 0. Like the `Shift`+`E` shortcut is there any Mean uncrease or say i want remove crease. Any suggestion or help. Thanks.
+W = x+W$. In a sense, you can ignore that y and just use x and vice versa. In a special case, if $y=0$, then $x-y \in W$ means $x\in W$ and for every $x \in W$, $x+W = 0+W =W$. So, you "kill" those x by seeing them as $0$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 2,
"tags": "linear algebra"
}
|
Swift, how to implement Hashable protocol based on object reference?
I've started to learn swift after Java. In Java I can use any object as a key for HashSet, cause it has default `hashCode` and `equals` based on object identifier. How to achieve the same behaviour in Swift?
|
If you are working with classes and not structs, you can use the `ObjectIdentifier` struct. Note that you also have to define `==` for your class in order to conform to `Equatable` (`Hashable` requires it). It would look something like this:
class MyClass: Hashable { }
func ==(lhs: MyClass, rhs: MyClass) -> Bool {
return ObjectIdentifier(lhs) == ObjectIdentifier(rhs)
}
class MyClass: Hashable {
var hashValue: Int {
return ObjectIdentifier(self).hashValue
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 54,
"question_score": 39,
"tags": "swift, hashtable"
}
|
Find data for specific date in mongodb
I wanted to find data for 2014-08-01 from MongoDB collection. Date in MongoDB is in ISO format.I wrote below query, but it gives me very huge number which i suspect is not the data for 1 day. Can some one let me know what is wrong with query. sd is the key
db.history.count({sd:{$gte: new Date("2014-08-01")},sd:{$lt:new Date("2014-08-01")}})
|
Ranges can be specified using **`$gte`** and **`$lt`** in the same document portion:
db.history.count({ "sd": {
"$gte": new Date("2014-08-01"), "$lt": new Date("2014-08-02")
}})
Otherwise the argument are considered to be separate and a logical "and" condition. But really since you are using the same "key" in your "sd" field, this is not allowed in a JSON/BSON document and violates the "unique" keys rule for hash structures in general. So one condition overwrites the other and only one is applied.
That is why your result is wrong. Use as shown above instead.
|
stackexchange-stackoverflow
|
{
"answer_score": 10,
"question_score": 4,
"tags": "mongodb, mongodb query"
}
|
SFMC busines rule to auto update all subscribers email address
I have a few subscribers who has changed their email addresses in our system which has been reflected in synchronized data extensions in Marketing Cloud. On email send SFMC is sending email to their old email addresses. Upon investigation, I found that All Subscribers data has not been updated with the new email address for the subscribers who changed their email addresses in Salesforce Cloud (CRM).
Please find below the details for one of the records.
Subscriber Key: 000000000000BBBAA1
New Email address (changed on 13/12/2016): [email protected]
Old Email address: [email protected]
I have raised a case with SFMC and they came up with a solution to enable the business rule in our account to update the records in All subscribers data as soon as the record is updated in CRM.
Can someone help me to understand the impact of this business rule going forward?
|
The email address Salesforce Marketing Cloud uses on send depends on your **Data Sources** in **Contact Builder**. You can configure these setting to have Salesforce use an email address in a Data Extension in place of the one in All Subscribers.
Alternatively, you can force an update on the affected subscribers in All Subscribers by conducting a **Data Extract** activity, followed by a **File Transfer** and then **Import** activity - choosing to Import the data into the All Subscribers list.
These steps can also be put into Automation Studio and scheduled to run daily.
|
stackexchange-salesforce
|
{
"answer_score": 2,
"question_score": 1,
"tags": "marketing cloud"
}
|
How to cook a pork sirloin roast?
I picked up a pork sirloin roast yesterday, it's a little over three pounds. I've never cooked one of these before and I am not sure what to do. My seasoning plan is salt, pepper, thyme, and rosemary, and I might poke a couple holes for cloves of garlic as well. My cooking plan is 8+ hours in the crock pot on low, with about an inch of water in there. Will this turn out OK? I'd like a tender and moist result, obviously. Any tips would be greatly appreciated.
|
I don't think a pork sirloin roast will stand up to that kind of cooking very well. That is a very lean piece of meat, which does not lend itself to long cooking times at low temperatures. That type of cooking is best reserved for cuts of meat with lots of fat and/or connective tissue. If you put a pork sirloin roast in your cooker for 8 hours on low, you're going to have one tough, dry piece of meat when you are through.
You would be better served by cooking it in the oven at higher heat, for a relatively short period of time, like 400F for an hour or so. Bear in mind, you're not going to get to a fall-apart tender state with a sirloin roast. This isn't a pork butt with which you're dealing, which you'd take up to an internal temperature of 195F or more. Rather, you're going to want to target the safe temperature, and no higher. You want the meat to be juicy. Cut into thinner slices to achieve maximum tenderness.
|
stackexchange-cooking
|
{
"answer_score": 15,
"question_score": 9,
"tags": "pork, roast"
}
|
Definiteness of fractions
I was tutoring a French student the other day. We were doing some math homework on fractions, and one question read:
> Les trois huitièmes de la solution sont de ... Le quart est de ... Quelle partie reste de ... ?
Naturally, the English equivalent would be:
> Three eighths of the solution consist of ... A quarter consists of ... What is the remaining fraction that consists of ... ?
Does anyone have a good answer for why this would be definite in French? (After all, there's more than set of "three eighths"!) Or is it just one of those arbitrary quirks?
|
It's a linguistic quirk, not a mathematical one. French prefers to use an article with a noun much more often than English. In English we say "last summer" but in French it's "l'été passé" or "the last summer." The profusion of articles helps identify genders and clarifies some other relationships, but mostly it's just the way it is.
|
stackexchange-french
|
{
"answer_score": 2,
"question_score": 6,
"tags": "nombres, mathématiques"
}
|
Vue, filter property on Observable
I'm pretty new to Vue, what I'm doing now is the following.
I receive an _Item_ prop in my component, I spread this _Item_ prop out over a _Form_ data object that's defined in my component (as to have reactivity)
data() {
return {
form: {}
}
mounted () {
this.form = {
...this.item,
translations: { ...this.item.translations }
}
},
Now my local form data holds the information, including reactive translations, right?
Next thing I try to do is filter this data, but then it's failing me. If I console.log(this.form). It is an _Observable_ (see screenshot)
 requests[position][1];
OutputStream os = s.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(o);
thanks.
|
To get rid of the ArrayStoreException I would create a Request-class which holds the information and then store the Request in the array. This way you don't need to do a lot of unnecessary casting and don't need to use Object as the type of the array. I can also recommend you to have a look at `java.nio` where you use channels and selectors to choose desired sockets, which I think is what you are trying to do.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "java, sockets, serialization"
}
|
prove that $(a-b)x^n+(a^2-b^2)x^{n-1}+(a^3-b^3)x^{n-2}+ \dotsm +(a^n-b^n)x+a^{n+1}-b^{n+1}=0$ has at most one real root.
> prove that $$ \left( \text{a}-\text{b} \right) \text{x}^{\text{n}}+\left( \text{a}^2-\text{b}^2 \right) \text{x}^{\text{n}-1}+...+\left( \text{a}^{\text{n}}-\text{b}^{\text{n}} \right) \text{x}+\text{a}^{\text{n}+1}-\text{b}^{\text{n}+1}=0 $$has at most one real root.
I tried to find a nice expression of it, and tried differentiation but failed. How to simplify (It seems like this question can be simplified) it, or directly solve it?
|
$x$ is a root of this polynomial iff $$\sum_{r=0}^{n+1}x^ra^{n+1-r}=\sum_{r=0}^{n+1}x^rb^{n+1-r}$$ Multiply $(x-a)(x-b)$ on both sides and get $$(x-b)(x^{n+2}-a^{n+2})=(x-a)(x^{n+2}-b^{n+2})$$ $$\Longrightarrow (b-a)x^{n+2}-(b^{n+2}-a^{n+2})x+ab(b^{n+1}-a^{n+1})=0$$ Let $P(x)$ be this polynomial, then $P'(x)$ has atmost two roots (if $n$ is odd) and hence $P(x)$ has atmost three distinct roots. But roots $a$ and $b$ are roots of $P(x)$ which were added later when we multiplied by $(x-a)(x-b)$. Hence, original polynomial has atmost one real root.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 3,
"tags": "linear algebra, polynomials"
}
|
Suppose $f$differentiable with $f (0) = 0$ and $f (1) = 1$. Show that $f '(X_0)$ = $2X_0$ for some $X_o \in [0,1]$
I tried to solve this problem using the Mean Value Theorem but didn't get very far. This question appeared in my calculus exam and I still can't solve it. Any thoughts?
Thank you.
|
Let $g(x)=f(x)-x^2$ then $g$ is differentiable with $$g(0)=f(0)-0^2=0$$ and $$g(1)=f(1)-1^2=0$$ thus according to the **Mean Value Theorem** there exists $0<\color{red}{c}<1$ such that $g'(\color{red}{c})=0$ but $g'(x)=f'(x)-2x$ and then $f'(\color{red}{c})-2\color{red}{c}=0$ , finally $f'(\color{red}{c})=2\color{red}{c}$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "calculus"
}
|
Does it mean he has no doubt about it?
> "I **would not dare** to say that there is a direct link between mathematics and madness, but there is no doubt that great mathematicians suffer from maniacal characteristics, delirium and symptoms of schizophrenia." _John F Nash_
What is the meaning of _would not dare to say_ here?
|
Nash is comparing two statements: (a) there is a direct link between mathematics and madness; and (b) great mathematicians suffer from maniacal characteristics, delirium and symptoms of schizophrenia.
There is no doubt about (b). But there is some doubt about (a). Therefore he would need to be daring (brave) to assert (a); the assertion would expose him to the risk error. He is not sure enough of (a) to assert it; he is not daring enough to assert (a) given his level of certainty.
So he would not dare to say it, i.e. take the risky step of saying it.
|
stackexchange-ell
|
{
"answer_score": -1,
"question_score": 0,
"tags": "meaning in context"
}
|
Create sequential counting in data frame column
Let's say I have a data frame looking like this:
Value1 Value2
1 543
1 845
3 435
5 724
5 234
8 204
Now, I would like the first column to count up sequentially, instead of jumping several steps every time the value changes, like so:
Value1 Value2
1 543
1 845
2 435
3 724
3 234
4 204
If there was some way of simply replacing an element in a data frame with something else, this could be easily done. However, I don't know if there is such a command. Also, I guess some kind of macro command for doing something like this would do, but I guess there isn't such a command.
|
Make use of the fact that `factor` levels will be increasing integers:
> x <- c(1, 1, 3, 5, 5, 8)
> as.numeric(factor(x))
[1] 1 1 2 3 3 4
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "r"
}
|
Run non-markup Angular Code
I am writing some Angular code which polls a server and shows a notification if the server says to.
I would like this to be a stand-alone js file which can be included into any site (assuming the site already loads Angular). The issue I am having it getting the code to run without any markup in the HTML.
If I make it the init function of a controller and use that controller in the page it works well. But that requires I add markup to the HTML.
How can I have the code run without markup in the HTML? (And as close as possible to the _Angular_ way).
|
Provide a service, and tell the developer to call it from a `run()` function:
myModule.run(function(pollingService) {
pollingService.startPolling();
}).
Or, if you don't even want to force the developer to add this function, and always start polling when the app starts up, just add the `run()` on your own module, and tell the developer to depend on your module.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "angularjs"
}
|
Difference between Omniture h23 and h26 code
I am upgrading my Web Analytics Omniture reporting from h23 to h26 code base.
I have two questions: 1) What is the difference between Omniture h23 and h26? 2) I see that a new variable "fid" is firing when I upgraded to h26? What is that variable and what is it's purpose?
Please guide.
|
The Release Notes are the place to go for this information <
C.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "adobe analytics"
}
|
Use filter to remove list items in AngularJS controller
In an AngularJS template I can _sort_ the elements in a `select` list using filter `|` notation:
<select ng-model="myListModel"
ng-options="c.id as c.name for c in myList | orderBy:'name' }">
Equivalently it seems I can perform the sorting in the controller using `$filter`:
$scope.myList = $filter('orderBy')($scope.myList,'name');
Now, I can _remove_ elements from a list in the template using:
<select ng-model="myListModel"
ng-options="c.id as c.name for c in myList | filter: { id : '!' + $scope.someId }">
But how can I (analogously with the sorting example) perform the same removal in the controller using `$filter` (thereby avoiding lots of JavaScript code to perform the removal)?
|
Use this code. It makes use of the `filter` filter and note that not equals is implemented using `!` and a string representation of your ID to remove.
$scope.filteredListToUseInTemplate =
$filter("filter")($scope.myList, { id: "!" + $scope.someId });
Then use `filteredListToUseInTemplate` in your template instead of `myList`.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "angularjs, angularjs filter"
}
|
Blur image with a 1/2" lens on a 1/3" sensor
When I put my 1/2" lens on my 1/2" sensor, the image is perfect, but when I put the same lens on my 1/3" sensor, everything is very blur, even when I focus at maximum, so I need to put an extension tube, but the image seems of lower quality (the extension tube disturbs the image ?). I don't understand why it's blur without extension tube, in Lens for 1/2" sensors, installed on a 1/3" sensor the picture f/w = a/b does not explains it. The image is supposed to be formed at the same distance, this shouldn't depend on the sensor size right ?
|
If the only difference is the sensor size, and the flange focal distance is the same, you're right — this shouldn't be happening. From the details you've given, the possibilities are:
* the systems don't actually put the lenses at the same distance, or
* it's broken
|
stackexchange-photo
|
{
"answer_score": 0,
"question_score": 0,
"tags": "lens, image quality, blur, extension tubes"
}
|
C++ Pass by reference a single element array - It's factible?
Quick question about passing vars by reference: What's more appropiate:
1) Using the classic pointers syntax:
void change(int *a) { a = 0; }
...
int number = 1;
change(&number);
2) Or making it a single element array and passing it by reference as default:
void change(int a[]) { a[0] = 0; }
...
int number[1] = {1};
change(number);
Something I thought off. Wanted to know how's the difference in resource use if using an array of one element instead of a simple variable.
|
There is no point in making it a one element array. Just pass it in as a reference using the `&` operator. By making it a one element array you are making your code more complex, obfuscating the real purpose of the variable, and making the next developer's life much more annoying.
As for your resource use concerns, there is no resource different whatsoever. Under the hood both of them are basically just a pointer.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 3,
"tags": "c++, arrays, pointers"
}
|
Use of final when referencing an Object type
private final List<KeyListener> keyListeners= new CopyOnWriteArrayList<KeyListener>();
public void addKeyListener(KeyListener keyListener){
keyListeners.add(keyListener);
}
In the above code I declare keyListeners to be final and also it is thread-safe . I assume by final I mean that the state of the listener can not change after construction . But am I not doing the same in the addKeyListener() method ? Why does the compiler doesn't give me an warning ? What am I missing here ?
|
Final keyword is used to tell that the variable may only be assigned to once. But you can call method on it even if it "change" object properties.
From the JLS :
> Once a final variable has been assigned, it always contains the same value. If a final variable holds a reference to an object, then the state of the object may be changed by operations on the object, but the variable will always refer to the same object.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "java, final"
}
|
is there a Java ECB provider?
Anyone know of a Rijndael-128bit ECB provider in Java???
Also, what's the difference between AES-128bit and ECB? or are they the same? (couldn't find answer any where else online)
|
ECB is a way of using a block cipher (not a cipher itself). It is not very good. Here is a related question How to choose an AES encryption mode (CBC ECB CTR OCB CFB)?.
I suspect if you find an implementation of AES (which is the same as Rijndael, by the way), it will be configurable to use ECB.
Try the following to start you off
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding", "SunJCE");
Key skeySpec = KeyGenerator.getInstance("AES").generateKey();
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
System.out.println(Arrays.toString(cipher.doFinal(new byte[] { 0, 1, 2, 3 })));
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "java, aes, aescryptoserviceprovider"
}
|
How to use Apple Header doc for auto-generated documentation for iOS development?
I have used Doxygen tool for document generation. But later on I have come to know that Apple itself provides "Documentation Set Guide".
Here is the reference link: <
Is there anyone aware about this - how to use this and all? Whether it would be useful for autogenerated document creation?
Thanks in advance,
Mrunal
|
'docsets' are merely a way to package documentation and show it in XCode. Doxygen has support for docsets, see < and < and <
If you want a tool that mimics Apples output (and care less about the features provided by doxygen) you could have a look at appledoc <
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "ios, xcode, documentation, doxygen, autodoc"
}
|
How to add another string in the next line to a specific string on MacOS sed?
I'm trying to add a string `'rest_framework',` after `'django.contrib.staticfiles',` in a file, however when I do try something like
sed '/'django.contrib.staticfiles',/a 'rest_framework',' file
I get an error saying
> sed: 1: "/'django.contrib.static ...": command a expects \ followed by text
I have tried the same command with `\` around the symbols as well.
Answer: Installed gsed as base MacOS sed does not work well when creating lines under specified strings.
|
Using single quotes inside one another gets real messy. Use double-quote to preserve the literal value of the search string. As long as you don't have search/replace string containing `$` strings, using double-quotes should be fine
sed "/'django.contrib.staticfiles',/a 'rest_framework'," file
Apparently the FreeBSD version of the `sed` on MacOS was still throwing errors for the above syntax and using GNU `sed` by installing `brew install gnu-sed` and running the command with `gsed` worked fine.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 3,
"tags": "macos, sed"
}
|
What field Django used in FOO_set?
I am little bit comfused. Lets say I have such models.
**models.py** :
class Company(models.Model):
name = models.CharField(blank=False, null=False)
class Game(models.Model):
developer = models.ForeignKey(Company, on_delete=models.CASCADE)
publishers = models.ManyToManyField(Company)
If I use next code:
current_company = Company.object.get(pk=1)
current_company.game_set.all()
as I understand it return all games of `current_company`, but what field (developer or publishers) Django used?
|
But this code wouldn't be valid, for precisely this reason. If you tried to run it, Django would tell you that there was a conflict in the reverse relation.
If you have two relationships pointing to the same model, you need to explicitly set `related_name` on one of them to avoid this conflict.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "python, django, django models"
}
|
.net Core appsettings - Multiple Environments on same IIS
On a single server (in IIS), how can I use a different configuration (appsettings.x.json files) per site/application?
This is so I can use the same CI build artifacts for both deployments.
I understand how the appsettings.environment is picked up by the Server System Environment variable (ASPNETCORE_ENVIRONMENT), and that works for a couple of our environments. However we have **one server with more than one environment** hosted on it. ie. CI _and_ UAT on the same server + IIS.
|
I ran into a similar problem and ended up specifying the environment variable inside of the web.config.
<aspNetCore /* omitting other aspNetCore arguments for brevity */>
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Staging" />
</environmentVariables>
</aspNetCore>
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "iis, asp.net core, asp.net core mvc"
}
|
Constructors in case of multi-inheritance
this may be a stupid question but I'm dealingthe first time with multi-inheritance.
Single-inheritance is defined and works like this:
class Canvas3D : public CanvasBase
{
...
Here Canvas3D inherits from CanvasBase and therefore the base-constructor has to be called this way on construction:
Canvas3D::Canvas3D(window* parent)
:CanvasBase(parent)
{
...
Now Canvas3D needs to inherit from two base classes:
class Canvas3D : public CanvasBase, public GLCanvas
{
...
How do I call the base-constructor of GLCanvas when it does not provide a default constructor? These variants do not work:
Canvas3D::Canvas3D(window* parent)
:CanvasBase(parent)
,GlCanvas(parent)
{
...
Canvas3D::Canvas3D(window* parent)
:CanvasBase(parent)
:GlCanvas(parent)
{
...
|
The `Canvas3D` constructor needs to take in the parameters to construct the `GLCanvas` part and pass them to the `GLCanvas` constructor.
Canvas3D::Canvas3D(window* parent, GLCanvas_Parameters) :
CanvasBase(parent), GlCanvas(GLCanvas_Parameters)
{
//...
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -2,
"tags": "c++, inheritance, constructor"
}
|
Modifying my nicad battery pack charger to charge nimh batts
I've got a battery pack for one of my peripherals that recently died, so i took it apart to find half the (nicad) cells were dead (I tested each cell's voltage both with and without a load - the dead ones dropped off to zero with load).
So what i wish to do is replace them with nimh's. Apparently the easiest way to charge nimh's is at 10% of C (C being 2500mAh) for 15 hours at 1.5V per cell (i will have 10 cells in series).
Now the question: I have a 15v power adaptor (correct voltage) but it is 400mA. I want to 'throttle' it to 250mA somehow. Is there some way i can do this with a diode or resistor or transistor or something?
Cheers
|
There are IC chips like the LM317 that vary the voltage to keep the current constant. But you can't do it with out building at least a small circuit. An alternative would be to put a potentiometer is series with the battery, but you would have to periodically adjust it to keep the current constant.
|
stackexchange-superuser
|
{
"answer_score": 2,
"question_score": 2,
"tags": "repair"
}
|
Specifying rules in the Linkextractors in scrapy
Is there a format to specify the rules in the `LinkExtractor` in scrapy? I have read the documentation but it was not very clear to me. In my case the url links values keep increasing after the first page (something like &pg=2 and so on). For example see below:
start_urls = ['
rules= [Rule (LinkExtractor(allow=['www.examples.com/sports/companies?searchTerm=news+sports&pg=2']), 'parse_torrent')]
Let me know if there is a right way to specify the url in rules so that I can scrape page 1, page 2...page 100.
|
If you want to extract links from your starting page. (for your case is <
You should create a spider inheriting from `CrawlSpider`, and use following regular expression.
rules = (
Rule(LinkExtractor(allow=[r'www.examples.com/sports/companies?searchTerm=news+sports&pg=\d+'], callback='parse_torrent'),
)
But seems like you already know your url rules, I would suggest you to generate url by yourself.
from scrapy.http.request import Request
def start_requests(self):
for i in xrange(1, 100):
url = 'www.examples.com/sports/companies?searchTerm=news+sports&pg=' + i
yield Request(url=url, callback=parse_torrent)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, python 2.7, web scraping, scrapy"
}
|
Calling a function within one class that calls a function within a separate class python
I am having trouble trying to call a function with one class that calls a separate function that exists within another class.
class PrintNum():
def get_square(self):
Numbers.square_Num(self)
def Print_Num(self):
Numbers.square_Num(self)
class Numbers():
def __init__(self, num1,num2):
self.num1=num1
self.num2=num2
def show_num(self):
return self.num1,self.mum2,
def square_Num(self):
self.num1,self.mum2, = self.num1**2,self.num2**2
p2= PrintNum(3,6)
p2.get_square()
print(p2.Print_Num)
|
To Get Such Behaviour from your classes, You need to use either inheritance or Embed the class. I used embedding to solve the problem above although I feel inheritance might be better suited here.
class PrintNum():
def __init__(self,a1,a2):
self.numbers = Numbers(a1,a2)
def get_square(self):
self.numbers.square_Num(self)
def Print_Num(self):
print(self.numbers)
class Numbers():
def __init__(self, num1,num2):
self.num1=num1
self.num2=num2
def __repr__(self):
print(self.num1)
return self.num2
def square_Num(self,*args,**kwargs):
self.num1,self.num2 = self.num1**2,self.num2**2
p2= PrintNum(3,6)
p2.get_square()
p2.Print_Num()
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, oop, methods"
}
|
Extra data in point object isn't available for tooltip
In Highcharts, I've got my data set up like so:
var data = [{
x: Date.UTC(2011, 10, 1),
y: 1.9,
variance: 2.6
}, {
x: Date.UTC(2011, 11, 1),
y: 2.0,
variance: 2.6
}...];
I want to use the variance value in my tooltip. But the variance value doesn't show in the point object available to the tooltip formatter. What am I missing?
JSFiddle : <
|
Fix your formatter string to the following:
`var tooltipString = "Highcharts.dateFormat('%b-%y', this.x) + ' survey<br>Average inflation expectations: ' + this.y + '<br>Variance ' + point.point.variance";`
And then you should add this to your `detailChart` data.
Change `detailData.push(point.y);` to `detailData.push(point.options);`
**Demo**
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "highcharts"
}
|
Custom DTOs for Web services
I currently have an MVC website and am about to create an API to expose limited functionality to a mobile client. My site has a logic layer where I have DTOs that I use to display information on the site.
When creating an API, should I expose these same DTOs to the client or should I create DTOs specific for use in the API? I will be creating new controllers and action methods, so might make sense to also create API-specific DTOs.
I feel that creating an API forces you into a contract with the mobile client so that changes are harder to make. Having separate DTOs allows you to freely make changes to DTOs that are only used on the site.
However, the down side is that I am basically duplicating my code, since the DTOs will basically be the same.
Thoughts?
|
IMO, Decision on this would mainly be guided by what all data do I need to pass to the view, if its the same in both cases, I would go with the same DTOs. If this is not the case, then I would create a base class for a DTO which has the common stuff across APIs for a particular view, and inherit from that base DTO and add more properties in the derived class specific to the API needs.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "web services, asp.net mvc 3"
}
|
SEO: Single URL rewrite from one app to another
I have two web applications running on two different servers. I want one, example.com/hello, to redirect to the second, hello.com. But I want both to contribute to each other's SEO ranking. What is the best way to accomplish this primarily for google search and for other search engines?
I currently do a rewrite with permanent from example.com/hello to hello.com using nginx.
|
Rather than use redirects to cross-promote your sites, you should just be linking the pages on on app to the other. If users of `hello.com` would find `example.com` useful, put a blurb about `example.com` on `hello.com` along with a link so that users can get from one to another. Search engines will see this link as well.
|
stackexchange-webmasters
|
{
"answer_score": 0,
"question_score": 0,
"tags": "seo, nginx"
}
|
test for process return status returns unexpected results on ubuntu
Here's a piece of shell script code that I am executing on an ubuntu machine:
myProcess
ret="$?"
if [ "${ret}" == "0" ]
then
echo good
else
echo bad "${ret}"
fi
So the logic is pretty simple: if `myProcess` returns a non-zero exit status, it's bad, otherwise good. I tested this piece of code by isolating it into a separate script and running it from command line. When `myProcess` returned 0, I got `good` as expected.
However, when I run it in production, I get `bad 0`. So even though the return code seems to be 0, the `if` test seems to return `false`. What's going on here?
|
It appears that the problem was in the use of too many quotes possibly in combination with `==`. The following modified code seems to be working fine:
myProcess
ret=$?
if [ ${ret} -eq 0 ]
then
echo good
else
echo bad "${ret}"
fi
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "shell, ubuntu, return"
}
|
How to compare and find the min between a constant and each element of a matrix?
For example, I have a 3x3 matrix called "A" with numbers between 1 to 10, and a constant= 5. I would like to create another matrix 3x3 called "B" where each element is the minimum between A elements and the constant. I know i could do this easily with for loops, but is there any function or shorter way to do this?
**example**
A[1,1] = 2 -> B[1,1]=min(A[1,1],constant) ->B[1,1]=2
A[1,2]=10 -> B[1,2]=min(A[1,2],constant) ->B[1,2]=5
|
You can use `pmin` :
set.seed(123)
A <- matrix(sample(1:10, 9), nrow = 3)
constant <- 5
pmin(A, constant)
# [,1] [,2] [,3]
#[1,] 3 5 1
#[2,] 5 5 5
#[3,] 2 5 5
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "r"
}
|
What does a circular number icon on an item mean?
Some items in my backpack have a circular number icon near their description. These number icons aren't listed in the search filters and don't appear if I check the same items in storage or a shop. What do these circular number icons mean?

.
Think of an RFID tag more as the secondary side of an air-core transformer, where information is transmitted by the tag changing the amount of power it draws from the primary side of the transformer, or by charging a energy storage (capacitor), and then exchanging the role of secondary and primary side of the transformer.
Because we're not talking about a wave propagating away from antenna, but about a coil coupling into a magnetic field, the decay in power is even worse than the distance² for free space loss, and after a couple of cm, practically no effect of the tag on the reader can be made.
|
stackexchange-electronics
|
{
"answer_score": 32,
"question_score": 21,
"tags": "rfid"
}
|
Python Regex to Extract Word From Multiline String
How would I extract the serial number from the following python string:
blah: asdf
blah: asdf
Serial Number: 1234ABCD
blah asdf
blah asdf
I have tried the following, but it doesn't appear to be working:
serial_num = re.search("^Serial Number:\s*(\w*)$", serial_num, re.MULTILINE)
|
You may perhaps use the following _regex_ ...
Serial\sNumber.*?(?=\w)(\w+)
see **regex demo**
**python** ( demo )
import re
s = """
blah: asdf
blah: asdf
Serial Number: 1234ABCD
blah asdf
blah asdf
"""
r = r"Serial\sNumber.*?(?=\w)(\w+)"
m = re.findall(r, s)
print(m)[0]
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "python, regex, match, extract, multiline"
}
|
Put shapes in a grid in WPF
I'm trying to dynamicaly add a shape to a grid, I'm creating and setting it this way :
Rectangle theRect = new Rectangle();
currentRect = theRect;
theRect.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
theRect.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left;
theRect.Margin = new Thickness(oldPos.X,oldPos.Y,0,0);
theRect.StrokeThickness = brushWidht;
theRect.Stroke = new SolidColorBrush(brushColor);
theRect.Height = newPoint.Y - oldPos.Y;
theRect.Width = newPoint.X - oldPos.X;
theBoard.Children.Add(theRect);
But it sticks to the corner of "theBoard" which is the grid where I put it. Does anybody can help me with this ? Thanks.
|
Since you've decided to have a `Grid` for the parent, I suppose you're trying to put your shape in different "cells", i.e. in different rows and columns. You can do that with the following code:
Grid.SetRow(theRect, 1);
Grid.SetColumn(theRect, 1);
If you want to set the absolute position of the shape in the parent then a `Canvas` would be a better choice. In this case you could set the offset of the shape inside the parent using the following code:
Canvas.SetLeft(theRect, oldPos.X);
Canvas.SetTop(theRect, oldPos.Y);
I hope this answers your question.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "c#, windows runtime"
}
|
How to draw a simple Gantt chart in latex?
I wanted to draw a simple Gantt chart like the following picture, but I saw that many instructions about Gantt charts on the Internet are much more complicated than I expected. :
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
node distance = 0pt,
G/.style = {draw, fill=gray!30, text width=2*#1mm, align=center,
inner xsep=0pt, outer sep=0pt,
anchor=south west},
tck/.style = {font=\scriptsize, below}
]
\foreach \n/\i [remember=\i as \j (initialy 0),
evaluate=\i as \k using \i-\j] in {P_4/3, P_1/9, P_3/16, P_2/24}
{
\node[G=\k] at (\j/5,0) {$\n$};
\node[tck] at (\i/5,0) {\i};
\ifnum\j=0
\node[tck] at (0,0) {\j};
\fi
}
\end{tikzpicture}
\end{document}
 for it to work.
In Visual Studio 2015: .setAttribute('size', ${count}) | lol
But I don't know why do you need a screenshot to prove something while you can just check it by standart selenium IDE command:
assertText | id=LANGUAGE | - Select from list - (en_US) Canada Canadian French United States English
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "automation, automated tests, selenium ide"
}
|
Github API: Unable to get list of members of an organization from code ... Although the same works from Postman
I am trying to fetch the list of members of any given organization on Github.com ... When I try it with Postman using the below Url and a Personal Access Token ... It works
"
But when I try it using my C# code with the same Url and Personal Access Token ... I get an empty Array instead ... What could I be missing? There are no errors since the HTTP Status Code is success ... But the Body of the response is an empty array like below: "[]"
|
After @Martin Costello comment above I used fiddler to analyze the two requests ... One sent using Postman and the other from my code ... It turns out that the way I was setting the Authorization header was incorrect ... This is how I was sending it earlier
_baseClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Authorization", authInfo);
Vs.
_baseClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authInfo);
The second approach works ... Feel kind of silly ... But thanks to @Martin Costello for the hint to analyze the requests using a Network traffic analyzer
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "c#, .net core, github api"
}
|
Is this laser printer ruined?
I was having a minor streaking problem with my Brother printer, using non-Brother toner (!). Following instructions I removed the cartridge to reposition it when a whole bunch of toner came out, all over the guts of the printer. I began delicately to vacuum it but it's all over the insides as you can see in the photo. Even after removing all 4 cartridges you can see a ton of the magenta.
### Addded question
Also, I was right to assume that one can handle a toner cartridge without it leaking toner, or was it my stupidity?
### Can this printer be saved?
.
Another thing to try maybe just to print out a number of blank pages and see what comes out - you might find that most of the toner simply adheres to the first few sheets and it's fine after that.
|
stackexchange-superuser
|
{
"answer_score": 3,
"question_score": 1,
"tags": "printer, toner"
}
|
Can I find cocoa modem in the repositories?
I just have a basic question. I am trying to set up a digital ham radio station. I have a piece of equipment called a SignalLink, a radio and a computer. What I am trying to do is make it so that the sound card in my computer recognizes the hardware. I saw this youtube video, and it looks like it may work. This is the link-< The only thing is he says that you have to have a Mac for cocoa modem. Is there a repository for it? Thank you very much in advance, you have all been very helpful over the years.
|
As per the CocoaModem page, you cannot use it on anything other than OS X, no. It is only available on OS X, and the _Cocoa_ in the name is a reference to the core toolkit framework of OS X.
|
stackexchange-askubuntu
|
{
"answer_score": 1,
"question_score": 0,
"tags": "14.04, repository, external soundcard, ham radio"
}
|
do i need a license to apply the RUP?
I am probably being desperately naive here, but i wanted to clear something up. RUP appears to be a proprietary process owned by IBM. What implications does that have for any project wanting to implement it?
Logically, i struggle to see how any 'process' can be made proprietary - you are simply following a series of tasks in a prescribed order. Further to this, there appears to be similar methodologies like AUP and OpenUP that work in a very similar manner but are open source.
The only conclusion i can come to, is that the proprietary aspect refers to the tools and diagrams made available to assist in implementing these.
As i said, i am probably being desperately naive but i wanted to clear up the confusion.
|
I think you can apply the RUP.
I believe UML is an OMG standard, not a proprietary IBM technology.
The licenses apply to the tools that IBM sells to support it. IBM bought Rational Software, which was founded by the Three Amigoes who were responsible for unifying their competing object notations into a single standard, since taken up by OMG.
If you're really worried, best to consult a lawyer. But I believe you're safe from legal hassles if you use UML and RUP.
I'd challenge what value you'll get from both, but that's another question.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "open source, licensing, rational unified process"
}
|
Query on backslash character
Below is the line that builds the path of a directory in java.
Here, `File.separator` is "\" on windows and "/" on Unix.
String path = System.getProperty("user.home") + File.separator + "workspace" +
File.separator + "JavaCode";
If i hardcode the path, it should look as shown below:
File path = new File("C:\\users\\david\\workspace\\JavaCode");
My question:
Why do we mention `\\` in second case?
|
Because, with a string, `\` is an _escape_ character: it says to interpret the following character in a special way (which is why `\n` isn't an `n`). In your case, you want `\` itself to be interpretted specailly by _not_ treating it special, so you need 2 of them: the first says "treat the next character special", the next gets treated specially _for a`\`_.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "java, escaping"
}
|
Export NetLogo output in .tiff or .jpg
I have a 300x300 world and I would like to save the generated result in .jpg or tiff format. Could someone tell me if it is possible to do this? I have so far only been able to export in .txt or .csv. Sorry for the beginner's question. If anyone can provide me with some direction, I would appreciate it.
|
You can use `export-view view.png` or `export-interface interface.png` in the code. Afterwards you can convert the .png to .jpg, if that's neccesairy. If you want to do it manually, you can right click on the view and choose "Export View..." or in the upper left "File" -> "Export" -> "Export View ..."
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "netlogo"
}
|
why does rewriteBatchedStatements default to false for mysql connector/j?
The mysql jdbc driver has a property called rewriteBatchedStatements that, when set to true can improve batch inserts significantly, but has to be explicitly turned on.
I've had to do this for multiple projects now, and couldnt find any good reason why I must manually turn this on.
Why is this not the default?
|
The connection property rewriteBatchedStatements provides a non-JDBC compliant feature. Not all statements can be re-written and it may held unexpected results. Particularly with regard to handling errors and returning update counts.
Also note that rewriteBatchedStatements can modify the original SQL string beyond a simple concatenation of queries which, in many cases, is not expected or desirable.
For those reasons, and many others, this property is false by default.
|
stackexchange-stackoverflow
|
{
"answer_score": 10,
"question_score": 5,
"tags": "java, mysql, jdbc, mysql connector"
}
|
how is this program working [python 3.x]?
I am learning python 3.x and got stuck on this program. Can someone please explain me whats happening in this program?
input:-
pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]
pairs.sort(key=lambda pair: pair[1])
output:-
[(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]
|
`key=lambda pair: pair[1]` is used to compare elements in the list during sorting. Since the lambda indexes a pair to its second value, it will compare the strings 'one', 'two', etc during sorting.
Strings are compared by their lexicographical order which is similar to alphabetical order, but also defines orderings for non alphabet characters too (like punctuation and digits). Sorting by the strings results in the pair with 'four' being first since it starts with 'f' and 'one' being second since it starts with 'o' and `'f' < 'o'` etc.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "python 3.x"
}
|
What is the difference between JOIN through ON and Using in MYSQL
I am trying to write a query to display the last name, department number, and department name for all the employees.
And this my working code:
SELECT
last_name,
department_id,
department_name
FROM
employees
JOIN departments USING(DEPARTMENT_ID);
When I was trying to make the query using JOIN ON ,I faced an error saying that
>
> Column 'department_id' in field list is ambiguous through this code
>
query using JOIN ON:
SELECT
last_name,
department_id,
department_name
FROM
employees
JOIN departments ON(
employees.DEPARTMENT_ID = departments.DEPARTMENT_ID
)
I want to know why it is not working .
|
The ambiguity should be resolved in select clause
SELECT
last_name,
employees.department_id,
department_name
FROM employees
JOIN departments USING(DEPARTMENT_ID);
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "mysql, join"
}
|
Not able to upload file. Laravel
Here's my code:
html:
<form class="m-t" role="form" method="POST" action="/badmin/register" enctype="multipart/formdata" files="true">
<input type="file" name="image">
<button type="submit" class="btn btn-primary block full-width m-b">Register</button>
</form>
backend:
public function register(Request $request){
$request['image']; /// getting file name here when i return it.
return $file = Input::file('image'); ///getting nothing.
}
But when I am trying to hit it using postman, I am getting a correct response.
|
The `enctype` of your form is missing a dash.
<form class="m-t" role="form" method="POST" action="/badmin/register" enctype="multipart/form-data">
That's why only the name if the file is sent to the server and not the file.
Also to test the value of a variable in Laravel it's better to use `dd()`, this will return the type and the value of any variable at any location. Like so:
dd($request->file('image'));
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "php, html, laravel"
}
|
How can I change the lock screen background image in Lion 10.7.4?
With Lion, I know that, in order to change the **lock screen** background image, I have to change
/System/Library/Frameworks/AppKit.framework/Versions/C/Resources/NSTexturedFullScreenBackgroundColor.png
In particular, I used an image with the same size as the resolution of my MacBook screen (1440x900).
So far so good, but after the update to Lion 10.7.4, the lock screen background switched back to the gray texture. I thought that the upgrade overwrote my custom image, but it didn't. I tried overwriting my image, but again, nothing changed.
Now I'm stuck with that dull texture. Can someone help me please?
**Note:** Please note that I'm not trying to change the _login screen_ background, there are plenty of answers related to that problem.
|
/System/Library/PrivateFrameworks/LoginUIKit.framework/Versions/A/Frameworks/Log inUICore.framework/Versions/A/Resources/appleLinen.png
This is the new location to change the login screen wallpaper but im still figuring out how to put it to the fullscreen.
|
stackexchange-apple
|
{
"answer_score": 1,
"question_score": 8,
"tags": "macos, settings, screen lock"
}
|
Default nodata value in QGIS 3
I want to set the nodata value in the layer transparency properties to 0, meaning that every new added layer will have this value as a default as opposed to the situation today where this value is blank by default: .
 statements to test static methods.
I was wondering if there is a simple way to test same things in Python. Please disregard what the code is actually doing (i have changed many names in it) I have the following code:
def create_models(pr_dict):
facility = FacilityCreator.doit(pr_dict)
p = PCreator.doit(facility, pr_dict)
pr = PRCreator.doit(p, p.recent, pr_dict)
models_affected = {'f': f,
'pr': pr,}
return models_affected
I have looked at unittest and unittest.mock but it doesn't seem to be eloquent solution if I have many static methods in my method. In other words, I would be doing a @patch within a @patch, etc. etc.
|
You may want to take a look at the python unittest module. It has mocking and patching modules
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, django, unit testing"
}
|
is there a way to use mstest in my application
is there a way to run mstests inside my application ?
these how it should work i should put the project in a folder point my appliaton to it and run the tests
thx for your time
|
I know the Galio project have it on their roadmap to create a testrunner for MSTest and that there is already source in the project for an MSTest extension. Don't know the state of this though but it could be useful to have a look into it.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": ".net, mstest"
}
|
Extra class for writing data to some backend?
What is the common practice to write classes which take some data class and store it to some backend? In my case I have table classes (columns, headers, etc.) which are written to Excel. So I have a class Table with the data and a class ExcelDocument with access operations and basic writing (cells, ...).
Where would I put the code which knows how to deal with Table data and knows how to write that the ExcelDocument? Both might be subject to refactoring at some point.
Do I use `Table.write_to_excel(excel)` or `ExcelDocument.write_table(table)` or even some need intermediate class? With the concept "a class should serve just one purpose" I'd most likely write an intermediate class?
|
I would consider modeling your output format as a separate class. In other words, go with your `ExcelDocument` idea. This lends itself well to the something like the Strategy pattern if you need to support multiple back end formats, now or in the future.
You would have an interface that defines the operations that you perform on the data store, such as reading and writing. You then implement that interface in a number of subclasses, each designed to handle a specific type of backend, such as CSV files, Excel XLS files, insert-flavor-here SQL database. If you only have one output now, you don't necessarily need the interface, but if you know for sure that you'll be adding more formats in the future, take care of the class hierarchy now.
Of course, it does depend on how complex these actions are. You might favor decomposing into both "reader" and "writer" classes instead of putting everything in one. This might also be more in line with the Single Responsibility Principle.
|
stackexchange-softwareengineering
|
{
"answer_score": 2,
"question_score": 1,
"tags": "design patterns, object oriented"
}
|
What 12 hex digits color codes in xfce terminal configuration means?
Recently I set up my XFCE terminal to use the perfect palette of Solarized using this prepared config.
All works fine (although midnight commander colors make me cry now) but one thing is really curious to me:
Why do color codes in xfce terminal settings contain 12 hex digits rather than 6? Like these one:
ColorPalette8=#d3d3d7d7cfcf
What does it mean? And how is it related to color codes specified on official page
|
GTK uses 16 bits per colour channel, i.e. 4 hex digits. A colour value for GTK can be encoded as `#rgb`, `#rrggbb` or `#rrrrggggbbbb`.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 4,
"tags": "colors, terminal, terminal emulator, xfce"
}
|
How to write infinite series in expression
I have a series: $$1+ (1*2)/(1*3) +(1*2*3)/(1*3*5) +...$$ The question is: how to write this sam as expression of form $\sum_{i=1}^\infty a_n$?
Of course, the numerator is of the form n!. But how can we express the denominator? It seems like a factorial over one term.
|
You can use the double factorial to write $$a_n = \frac{n!}{(2n-1)!!} = \frac{n!}{\frac{(2n)!}{2^nn!}}=\frac{2^n (n!)^2}{(2n)!}$$
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "sequences and series"
}
|
Show that it is a solution for all values of $t$
Show that $(1-t, 2+3t, 3-2t)$ is a solution for all values of $t$ to following linear system:
$a + b + c = 6$
$a - b - 2c = -7$
$5a + b - c = 4$
I have found that these rows are linearly dependent but I do not know how to continue. Can you help me? Here is after Gaussian Elimination:
$$\begin{bmatrix}1 & 0 & -\dfrac{1}{2} & -\dfrac{1}{2} \\\0 & 1 & \dfrac{3}{2} & \dfrac{13}{2} \\\ 0 & 0 & 0 & 0 \end{bmatrix} $$
|
Hint: One approach is to use Gaussian Elimination, you end up with:
$$\begin{bmatrix}1 & 0 & -\dfrac{1}{2} & -\dfrac{1}{2} \\\0 & 1 & \dfrac{3}{2} & \dfrac{13}{2} \\\ 0 & 0 & 0 & 0 \end{bmatrix} $$
Can you take it from here?
**Update**
We have:
* $a = -\dfrac{1}{2} +\dfrac{1}{2}c$
* $b = \dfrac{13}{2} -\dfrac{3}{2}c$
So, $c$ is a free variable and from the problem statement, they chose $c = 3-2t$.
Now, what are $a$ and $b$? Also, can you write this in another form?
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "linear algebra"
}
|
if __name__==function_name()
Why does python calls the function which is checked as **name** == function_name()
When i run this program In this program
def game():
print("1")
return("2")
def main():
print("game over")
if __name__==game():
print("3")
else:
print("4")
the output is: 1 # here the method game() is called and why is it so? 4 Can anyone explain the reason behind this Thank you in advance
|
`game()` returns the string `"2"` that is not equal to the value of `__name__`, the variable which refers to the name of in scope module.
Your code is not easy to read: I suggest you to add blank lines to make clear the distinction among different function. Here is a modified version that should clarify what happens when you execute it.
def game():
print("I'm: " + __name__ + " executing game()")
print("1")
print("I'm going to return 2")
return("2")
def main():
print("I'm: " + __name__ + " executing main()")
print("game over")
print("I'm: " + __name__)
if __name__==game(): # game() is returning the string "2"
print("3")
else:
print("4")
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python 3.x"
}
|
Advantages of NOT versioning .dproj
I read in a blog about Version Insight (< that (among others) JCL doesn't have its .dproj files under version control and i was wondering what the advantages of that would be.
Especially since me and my collegue developer often "bug" each other with checking in project files with our own favorite debug settings (he likes optimization on, I want it off). And because of the regular hick ups of Delphi 2007 that screw up the dproj file with all kinds of faulty dependencies. Does not versioning help in anyway with these things?
We are using Starteam as our VCS at the moment.
|
I store, in my .dproj files, settings that are used by `msbuild` for my build process. For example, conditional defines, compiler settings, etc. If you do the same then you need to version them.
If you are using a version of Delphi where the IDE breaks the .dproj file on a regular basis, then surely revision control will help you fight back.
I can't see any advantage in not versioning them.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 10,
"tags": "delphi, version control, delphi 2007, starteam"
}
|
Spring Boot "schema.sql" When Using JPA
When utilizing 'Spring Data JPA' the schema is created automatically if you have '@Repository' and '@Entity' annotated classes. **Is there any reason why I may want to have the addition of a 'schema.sql' file in the resources folder?** There does not seem to have any conflict if you happen to have it present. If so, which takes precedence in creating the structure of the database (tables, columns, etc)? JPA or the 'schema.sql' file when present?
|
I found an answer according to the link below:
Database Initialization on Spring Boot
" **In a JPA-based app, you can choose to let Hibernate create the schema or use schema.sql, but you cannot do both. Make sure to disable spring.jpa.hibernate.ddl-auto if you use schema.sql.** "
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "spring, spring data jpa"
}
|
How to use awk to find and replace with calculation?
I have several CSS files under a folder contains `0.2rem` or `0.5rem 0.6rem`, now I want them to be all divided by 2, become `0.1rem` and `0.25rem, 0.3rem`. How can I use `awk` or `sed` or `gawk` to accomplish this?
I tried the following command but have no success:
find . -name "*.css" | xargs gawk -i inplace '{gsub(/([0-9\.]+)rem/, "(\\1 * 0.5)rem"); print $0}'
|
**`find`** \+ GNU **`awk`** solution:
find . -type f -name "*.css" -exec gawk -i inplace \
'{ for (i=1; i<=NF; i++)
if ($i ~ /^[0-9]+\.[0-9]+rem/) { v=$i/2; sub(/^[0-9]+\.[0-9]+/, "", $i); $i=v $i }
}1' {} \;
|
stackexchange-unix
|
{
"answer_score": 5,
"question_score": 6,
"tags": "awk"
}
|
Как сделать редирект на сокет сервере?
Я делаю что-то типа своего apatche и я завис на теме, как сделать редирект, что бы пользователя перебросило на указываемый url?
Заголовок Location не работатет, либо что-то нужно изменить, что-бы браузеры понимали, что нужно сделать переадресацию
 or 201 (created) status response.
Нужно статус ответа делать 3xx (например, `307 (Temporary Redirect)`) или 201, а **у вас статус 200**
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java"
}
|
Magento 2 Add product to category (code)
I want to create products by their code, and I want to add products to categories.
How to add products to categories by code?
I tried to add category to product `\Magento\Catalog\Model\Product`, but there no method setCategory or something like that.
Then I tried to add products to category `Magento\Catalog\Model\Category`, and there no method addProduct or something like that. I saw function
CategoryLinkManagementInterface -> assignProductToCategories(
$product->getSku(),
$product->getCategoryIds() //but there is not categories yet
)
|
/**
* @var \Magento\Catalog\Api\CategoryLinkManagementInterface
*/
protected $_categoryLinkManagement;
$this->_categoryLinkManagement->assignProductToCategories($sku, $categoryIds);
//where $sku is sku of product, and $categoryIds is array of real categories ids
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "categories, magento2"
}
|
Getting file name and changing a button to that name
Im just getting into C# forms and im wondering how to change a button text to the name of a file you are opening i have it somewhat working but when i open the file the buttons text changes to the path of that file i just want the files name
OpenFileDialog op = new OpenFileDialog();
op.Title = "open";
op.Filter = "Text Document(*.txt)|*.txt|All Files(*.*)|*.*";
if (op.ShowDialog() == DialogResult.OK)
{
richTextBox1.LoadFile(op.FileName, RichTextBoxStreamType.PlainText);
button1.Text = op.FileName;
this.Text = op.FileName;
}
|
You'll want to check out the Path class. Remember to reference `System.IO`
OpenFileDialog op = new OpenFileDialog();
op.Title = "open";
op.Filter = "Text Document(*.txt)|*.txt|All Files(*.*)|*.*";
if (op.ShowDialog() == DialogResult.OK)
{
richTextBox1.LoadFile(op.FileName, RichTextBoxStreamType.PlainText);
button1.Text = Path.GetFileNameWithoutExtension(op.FileName);
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c#, forms, filenames"
}
|
How to Fetch data related to current date from data base with date Time
My database date column format is (16/06/2019 8:33 AM). How can I fetch data based on current date only.
SELECT * FROM `table` WHERE date_column = CURDATE()
|
SELECT *
FROM `table`
WHERE DATE(date_column) = CURDATE()
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "mysql"
}
|
Java Convert double to string
Hello I am trying to convert these two double variables into a String so it can be displayed into the JLabel `AnswerLabel`
double GasType;
double CostOfGas;
Answer = GasType * CostOfGas;
this.AnswerLabel.setText(Answer);
|
This will work:
this.AnswerLabel.setText("" + Answer);
but this is better:
this.AnswerLabel.setText(String.valueOf(Answer));
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "string, awt, double, jlabel"
}
|
sum multiple count expressions in ssrs
I have a column that contain a count expression :
=IIF(isnothing(Fields!SuiteNameFR.Value) and Count(Fields!ModuleNameFr.Value) <> 0 , Count(Fields!ModuleNameFr.Value),"")
and an other column that contain a count expression also :
=IIF(IsNothing(Fields!SuiteNameFR.Value) ,"" , CountDistinct(Fields!PackageID.Value))
I want to sum this tow columns, any help please?
Thanks
|
You can reference objects in the report with expressions using the ReportItems collection. So you can add the two text boxes together like this:
=CInt(ReportItems!TextBox1.Value) + CInt(ReportItems!TextBox2.Value)
You can find the name of the report objects by selecting them in the designer and looking at the properties pane.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "reporting services, sum"
}
|
Call function on textchange in span
I want to call a function in My big commerce project when the `<span> </span>` text has changed i want to call that particular function.For ex., If the tag contains `<span>Hi</span>`,when the text `Hi` changed to `<span>Hello</span>` means i want to call the function `test()`.
function test(){
alert("Hi you are authorised for this page")
}
|
You can try like this:
HTML:
<span id="mytext">Hi</span>
JQuery:
$('#mytext').on('DOMSubtreeModified',function(e){
if($(this).text() == 'Hello')
alert("Hi you are authorised for this page");
});
**Fiddle Example**
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "javascript, jquery"
}
|
Python regex matching on strings I don't want
This is my first attempt at trying to use regex with Python or at all, and it is not working as expected. I want a regex to match any alphabetic character or underscore as the first character, then any number of alphanumeric characters or underscores after. The regex I am using is '^[a-z_,A-Z][a-z_A-Z0-9]*', which seems to produce what I want at pythex.org, but in my code it is matching strings that I do not want.
My code is as follows:
isMatch = re.match('^[a-z_A-Z][a-z_A-Z0-9]*', someString)
return True if isMatch else False
Two examples of strings that are matching that I don't want are: "qq-q" and "va[r". What am I doing wrong?
|
I think that you just forgot the `$` at the end of your regex to specify the end of the string.
isMatch = re.match('^[a-z_A-Z][a-z_A-Z0-9]*$', someString)
Without that, it will match the beginning of the string and not the entire string, which explains why it worked on `"qq-q"` (`"qq"` is a match) and `"va[r"` (`"va"` is a match).
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, regex"
}
|
PHP: How do I convert a regular expression to an example match?
I have a regular expression for matching URIs. For example,
preg_match("/^my\/uri\//i", "my/uri/whatever");
Which I use for routing, for exmample "< will match the above (with the protocol/host removed of course).
Is there any way to evaluate the regular expression into the most general URI that will match? For example,
"my/uri/"
|
I didn't understand what you actually want.
This code might be what you need:
$general_uri = 'my/uri/';
$regex = '/^' . preg_quote($general_uri) . '/i';
If you want reverse of the above code:
$regex = '/^my\/uri\//i';
$general_uri = str_replace('\\', '', preg_replace('/^\/\^(.*)\/i?$/', '$1', $regex));
However above code will not work on complicated regexes.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "php, regex"
}
|
How to implement 32-bit adder logic using two 16-bit adders?
I've been trying to implement a 32-bit adder by instantiating two 16-bit adders. The code is compiling but failing some test cases. I don't know what is going wrong in this.
# verilog code
module top_module(
input [0:31] a,
input [0:31] b,
output [0:31] sum);
add16 adder2 (.sum(sum[16:31]), .a(a[16:31]), .b(b[16:31]));
add16 adder1 (.sum(sum[0:15]), .a(a[0:15]), .b(b[0:15]));
endmodule
This is the top level figure of the circuit:
. Now I want to alternate the row colors. How would I do that?
So basicially I want to do something like this:
if ($listCount == 1, 2, 3 OR 7, 8, 9 OR 13, 14, 15) {
$alternateRow = "rowOdd";
}
else {
$alternateRow = "rowEven";
}
(I know this is a syntax error, just trying to explain)
I think it's possible with modulus but to be honest I don't really understand how it works.
|
Indeed, modulo. You can test for `($listCount - 1) % 6 < 3`.
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 1,
"tags": "php, background color, alternate"
}
|
overflow:hidden; strange behavior at Internet Explorer on mouse over
On mouse over, the size of the menu increases on **Internet Explorer 9.0.8**. I found out that the reason was that the element `divider` was using the property `overflow:hidden`.
Why does it influence the element when the mouse is over?
Here's the fiddle with the code. I have pointed in the first CSS style where is the problem. <
This is the problematic style:
.floatingMenu li.divider{
height: 1px;
margin: 9px 1px;
overflow:hidden; /*PROBLEM INTERNET EXPLORER*/
background-color: #E5E5E5;
border-bottom: 1px solid #FFF;
}
If we get rid of the `overflow:hidden;` everything works well.
|
It's happening it would seem based off an alternate interpretation on IE's part of the 100% width and what div is defining that size.
100% width in a div or ul that has no set or max width could be interpretted as being the width of the largest div it is nested in, which is what appears to be happening. If you remove the 100% width or apply a set or max-width to the ul, it will confine it to that hierarchical width.
This may in part also be a factor of the absolute positioning applied to the ul, since it may ignore relatively positioned divs' width higher than itself.
I believe this explains what is happening further.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "internet explorer, css"
}
|
Is variable $u$ viewed as a constant in the chain rule?
If one has to use the chain rule repeatedly, such as in the problem $y=\cos(2u)$ and $u=3x+1$, would $u$ be viewed as a constant? There's an easier way to solve this function by simply making $u=6x+2$ but this is just for an example.
I know that the derivative $\frac{du}{dx}$ is $3$.
I know that the derivative of $\cos(2u)$ would be equal to $-2\sin(2u)$ since $2u=j$ and $f'(\cos(j))\times f'(2u)=-2\sin(2u)$. However, in solving $\cos(2u)$, its actual value of $3x+1$ was removed, since the actual derivative of $2u$ with the value of $u$ plugged in would be $6$.
Why would you treat $u$ as completely independent from its actual value when using the chain rule (until you plug it back in)?
|
Nothing is being removed. It’s just another way of reaching the same answer. According to the Chain Rule, we have the following:
$\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}$ when $y = f(u)$ and $u = g(x)$
Here, $u = 3x+1$ and $y = \cos(2u) \implies y = \cos(2(3x+1))$.
$$\frac{dy}{dx} = \frac{d}{du}\cos(2u) \cdot \frac{d}{dx}(2u)$$
$$\frac{dy}{dx} = (2u)’\cdot-\sin(2u)$$
$$u = 3x+1 \implies \frac{dy}{dx} = (6x+2)’\cdot -\sin(6x+2)$$
$$\frac{dy}{dx} = -6\sin(6x+2)$$
In examples like this, of course, solving for $y = \cos(6x+2)$ is pretty quick, getting the same answer, just as you mentioned.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "calculus, trigonometry, chain rule"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.