INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Raw signature of public key vs full certificate
I'm working on an device that will have its own keypair to sign data that it acquires. The public key will be signed with a provisioning key to ensure authenticity of the device. I want to put the public key in a QR code printed on the device, as well as the signature by the provisioning key. If I use a regular X509 certificate structure the barcode gets really huge. Are there any pitfalls or really good reasons not to just put the public key and signature - base64 encoded - instead?
|
X509 certificates contain a lot of additional (management) data that is required to manage the PKI. If you do not require interoperability, you do not need this extensive structure. However, you might want to go through the basic fields of an X509 certificate and think over if you really do not need each of these fields. E.g., you might want the ID of the device signed together with the public key. You also might want a validity period assigned to a key pair and so on. You could also have a look at WAP or CVC certificates. These are more compact than X509 certs.
|
stackexchange-crypto
|
{
"answer_score": 1,
"question_score": 1,
"tags": "signature, certificates"
}
|
Dont understand State in react js
But i trying. I need get json from api. I get error:
> TypeError: Cannot read property 'setState' of undefined(…)
const Main = React.createClass({
getInitialState : function() {
return {
data: null
};
},
componentDidMount: function() {
axios.get('
.then(function (response) {
this.setState({data: response.data})
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
console.log('mount ' + this.state.data );
},
render() {
return (
<h1>{JSON.stringify(this.state.data)}</h1>
)
}
})
export default Main;
Why i cant use setState from **componentDidMount** ?
|
componentDidMount: function() {
var self = this;
axios.get('
.then(function (response) {
self.setState({data: response.data})
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
console.log('mount ' + self.state.data );
},
when `this` is being called its referring to the axios request not the component, so need to set a variable to the `this` that refers to your component instance that way when you do `this.setState` its coming from the right `this`
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "javascript, reactjs"
}
|
Get H.264 frame from UDP stream using jCodec
I am wondering how to get and decode a H.264 frame from a UDP live stream using jCodec. I see examples of how to get it from a file, but I need to get it from a live stream. I have the application receiving the live stream packets, but I need to know how to decode the packets and display the live stream.
Also, if there us a better way to do this than using jCodec please let me know. I looked for a while and that was the best I could find that is still actively maintained.
|
I ended up using vlcj instead of jCodec. More information about vlcj can be found here:
<
And a tutorial to get started can be found here:
<
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "java, udp, h.264, jcodec"
}
|
new array formation from current array in php
I have an array like this in php
Array
(
[0] => 1
[1] => 3
[2] => 5
[3] => 10
[4] => 14
[5] => 15
)
Now I want it to look like
Array
(
[0] => Array
(
[0] => 1
[1] => 3
)
[1] => => Array
(
[0] => 5
[1] => 10
)
[2] => => Array
(
[0] => 14
[1] => 15
)
)
Please suggest how to get the desired output using for loop.
|
for($i = 0, $count = count($array1); $i < $count; $i = $i + 2) {
$array2[] = array($array1[$i], $array1[$i+1]);
}
print_r($array2);
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "php, loops"
}
|
How can I change catalog in mdx query? Like "Use" in T-SQL
Good day!
Can anybody tell me if there is an analog of "use" in mdx query? Or how can I change catalog context?
My task is to get data from olap using mdx query in OpenQuery. I can determine initial catalog on linked server, but there are several catalogs on OLAP server and I want to use one linked server to get access to all catalogs.
|
This is not possible with OpenQuery. You need to have separate linked servers for each catalog as `OpenQuery` executes the MDX only against the default catalog of the linked server.
If this is not feasible try using `OpenRowset` where you can specify string parameters to pass correct catalog information.
See information on `OpenRowSet` here <
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "sql server, mdx, olap, openquery"
}
|
how to format inputs on python 3.2
while True:
letter,Text,numRails= input("").split('\"')
if numRails ==(""):
numRails=(2)
plainText= Text.strip()
numRails=int(numRails)
if letter.strip() == "E" or "e":
x =Encrypt(numRails,Text)
elif letter.strip()=="D" or "d":
x =scramble2Decrypt(numRails,Text)
else: print("invalid encryption command")
E "WEAREDISCOVEREDGO" 2 I need to be able to input all 3 variables on the same line. however I want to have some conditional statements. but I don't know how to do that. like do I just do it as you would normally do if it was just one variable or there's a specific way you have to do this ?
|
Note if conditions are wrong! it always evaluates to True:
letter.strip() == "E" or "e":
# ^^^^ always True
should be:
letter.strip() in ["E", "e"]:
Similar mistake is present in second if code.
Note: a Boolean equivalent of a non-empty string is always True e.g.
>>> bool("") # bool of empty string
False
>>> bool(" ") # bool of non-empty string
True
>>> bool("e")
True
So for this reason your if condition e.g. `letter.strip() == "E" or "e":` == `letter.strip() == "E" or True:` == `Ture`
As @roippi is suggesting in comment, you can further simplify if conditional expressions just as follows:
letter.strip().lower() == 'e':
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "python, input, split"
}
|
Can I place and access a static library (.a) in the Documents or Library directory for an iOS app?
I would like to make my iOS app easy to update a library without updating the app to the App Store. So I think I may place and access a static library (.a) in the Documents or Library directory of the app.
Would this be possible? If so, how this can be done.
So far, I can put a static library (a.) in the Documents or Library directory of the app but cannot link this library from Xcode project.
Please give me any suggestions. Thank you.
|
No. This won't work. Static libraries must be linked into the final executable. And Apple doesn't allow for dynamic libraries.
You will have to submit an app update anytime you need to update any code.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "ios, static libraries, nsdocumentdirectory, nslibrarydirectory"
}
|
Is it ok to replace std::thread objects?
From what I could gather in C++ online documentation, assigning to a joined _std::thread_ object should call its destructor and represents a legitimate operation. Is this the case?
Here some example to show what I mean:
#include <thread>
#include <vector>
using namespace std;
int main()
{
vector<thread> tvec;
for(int = 0; i < 3; ++i)
{
tvec.push_back(thread(foo));
}
for(size_t i = 0; i < 3; ++i)
{
tvec[i].join();
tvec[i] = thread(foo); // is this ok?
}
for(auto& t : tvec)
{
t.join();
}
}
|
> assigning to a joined `std::thread` object should call its destructor
No it shouldn't! Destructors are only called when objects are destroyed, hence the name.
> and represents a legitimate operation
It's fine as long as the thread is not joinable (as is the case in your example). Otherwise, `terminate` will be called.
If you were to read the standard, rather than dubious online "documentation", you'd find in [thread.thread.assign]
> _Effects:_ If `joinable()`, calls `terminate()`. Otherwise, assigns the state of `x` to `*this` and sets `x` to a default constructed state.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 0,
"tags": "c++, variable assignment, stdthread"
}
|
Multiple timers at once
EDIT: i now get a runtimeerror: 'main thread is not in mainloop' when the second timer reaches 0 and calls the Note() function
from datetime import datetime
from threading import Timer
from tkinter import messagebox
import json
def Note():
z = messagebox.showinfo("Note", note)
class Timers:
def __init__(self,a,b,c,d,e):
self.a = month
self.b = day
self.c = hour
self.d = minute
self.e = note
x = datetime.today()
y = x.replace(month=month, day=day, hour=hour, minute=minute, second=0, microsecond=0)
delta_t = y - x
secs = delta_t.seconds
T = Timer(secs, Note)
T.start()
|
you would want to use json to store a list of data objects
def save_some_object(a,b,c):
with open("some_file.txt","wb") as f:
json.dump({'a':a,'b':b},f)
in your case the object you want to save is a **LIST** of datetime metadata
alarms_list = [{'hour':5,'minute':5,'second':0,'day':1,'month':1,'year':2019}, {'hour':6,'minute':5,'second':0,'day':1,'month':1,'year':2021}]
and then you can save them to your file
with open("some_file.txt","wb") as f:
json.dump(alarms_list,f)
you can load your list of alarms also with json
with open("some_file.txt","rb") as f:
my_alarm_data_list = json.load(f)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, python 3.x, variables, import, timer"
}
|
Vanilla Javascript use of bind() with REST parameter
Why bind() passes even the type of event with rest parameters. How to avoid passing the event 'click'?
function say(...numbers) {
for (const number of numbers) {
console.log(number);
}
}
window.addEventListener('DOMContentLoaded', () => {
const el = document.getElementById('input_10_5');
el.addEventListener('click', say.bind(null, 1, 2, 3));
});
Console.log result:
1
2
3
click { target: input#input_10_5.medium, buttons: 0, clientX: 1062, clientY: 732, layerX: 96, layerY: 24
}
|
You can't. The event handling system always passes the event.
> The callback function itself has the same parameters and return value as the handleEvent() method; that is, the callback accepts a single parameter: an object based on Event describing the event that has occurred, and it returns nothing.
<
If your goal is to iterate the arguments and treat them all the same then how about: `function say(numbers, event)` `say.bind(null, [1, 2, 3])`
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, bind"
}
|
jQuery. How do I combine a JS variable with a tag literal?
Here I have a modal dialog that hosts two tabs: <
In the JS code:
$('#trackFilterTabSet_GUID a').click(function (e) {
// present tab
alert('present tab');
e.preventDefault();
$(this).tab('show');
})
$('#trackFilterTabSet_GUID a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
// do something awesome
// alert('shown.bs.tab event fired');
e.target // activated tab
e.relatedTarget // previous tab
})
I want to replace `#trackFilterTabSet_GUID` with a JS variable:
var mySelector = "#trackFilterTabSet_" + myStringGeneratingFunction();
How do I combine this JS variable with `a` in the first function and `a[data-toggle="tab"]` in the second function?
|
Exactly as you'd expect:
var mySelector = "#trackFilterTabSet_" + myStringGeneratingFunction();
$(mySelector + ' a').click(function (e) {...
$(mySelector + ' a[data-toggle="tab"]').on(...
A jQuery selector is simply a `string`. String concatenation works perfectly fine with it.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, jquery, twitter bootstrap 3"
}
|
Simple Bayes? Probability of a state at time t in hidden markov model
Suppose we have a HMM with $2$ states -- $A$ and $B$, with $P(A) = 0.4$ and $P(B) = 0.6$. $A$ has a probability of $0.9$ of outputting "hot," and $B$ has a probability of $0.1$ of outputting "hot." Given that at time step $1$, we output hot, what are the probabilities of being in $A$ and $B$?
My reasoning is that $P(A|\text{hot}) = P(A$ and hot$)/P($hot$)$. $P($hot$) = 1$ as it's given, and $P(A $ and hot$) = 0.4\times 0.9$. If we calculate $P(B|$hot$)$ similarly, $P(A|$hot$)+P(B|$hot$)$ doesn't equal $1$, even though we must be in either state $A$ or $B$. What am I missing here?
|
$P(\text{hot})$ isn't one. All you know is that the event "hot" occurred; this doesn't imply that it has probability 1. You need to calculate using Bayes' rule. Using $H$ to denote the event "hot", we see: $$P(A\mid H)={P(H\mid A)P(A)\over P(H)}={P(H\mid A)P(A)\over P(H\mid A)P(A) + P(H|B)P(B)}.$$ Now plug in $P(A)=0.4$, $P(B)=0.6$, $P(H\mid A)=0.9$, $P(H\mid B)=0.1$.
Finally, calculate $P(B\mid H) = 1-P(A\mid H)$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 2,
"tags": "probability, markov chains, bayesian, bayes theorem"
}
|
Ignore dependency with buildout
Here is my `buildout.cfg`:
[buildout]
extends = versions.cfg
eggs = package1
package2
parts = installeggs
[installeggs]
recipe = zc.recipe.egg
eggs = ${buildout:eggs}
And my `versions.cfg`:
[versions]
package1 = 1.0
package2 = 2.0
Unfortunately, `package2`'s version requires another version of `package1`.
Error: The requirement ('package1>=2.0') is not allowed by your [versions] constraint (1.0)
Is there an option I'm not aware of to install this version of `package1` anyway? Something like the `--no-deps` option of pip for instance.
|
I use a workaround consisting in running `pip install --no-deps`, but it forced me to declare another part.
[buildout]
extends = versions.cfg
eggs = package1
# package2
parts = installeggs
forceinstall
[installeggs]
recipe = zc.recipe.egg
eggs = ${buildout:eggs}
[forceinstall]
recipe = collective.recipe.cmd
on_install = true
cmds = ${buildout:directory}/bin/pip install --no-deps package2==2.0
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, dependency management, buildout, egg"
}
|
MDF file in App_Data, is it thread safe?
I have a local database file (`.mdf`) in my `app_data` directory of my C# asp.net mvc program.
If I have many user on my site all reading data from the `.mdf` file is it thread safe? This would be read only, and updated a few times a week.
Thanks
|
Yes, the `.mdf` is being handled by **SQL Server Express** which is installed on your machine (or any other machine that uses your application), and SQL Server **is** thread-safe in that you can throw any number of concurrent requests at it and it won't break under that kind of workload.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "sql, sql server, asp.net mvc, visual studio 2013, mdf"
}
|
ID not aligning center CSS [outlook.com]
I am having trouble centering an ID in the login page of outlook.com. The ID of the login box is #signInTD. I have tried using the 'right' style to center it. However, I have managed to make it look like it is in the center but I want to make sure that it is in the center when looking at it from bigger screen or browser. What should I use to achieve this?
Here is a jsfiddle link to the login box.
Thanks.
This is what I have tried.
#signInID {right: -195px !important;}
|
Try this :-
Add this class
#signInTD.floatLeft{float:none}
#signInTD{margin:0 auto}
**DEMO**
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "html, css, outlook"
}
|
Understanding "LOG: execute S_1: BEGIN " in PostgreSQL
I turned on the Postgres logging with 'all' and logs show `LOG: execute S_1: BEGIN`.
What does `S_1` mean?
|
The format of this log entry denotes the use of the extended query protocol.
From the linked doc:
> In the extended protocol, the frontend first sends a Parse message, which contains a textual query string, optionally some information about data types of parameter placeholders, and the **name of a destination prepared-statement object** (an empty string selects the unnamed prepared statement)
The `S_1` from the log corresponds to that name.
If the application uses the `libpq` C library or a layer based on it, libpq functions like `PQprepare`, `PQexecPrepared` or `PQexecParams` are built on the extended protocol. On the other hand, the older `PQExec` uses the simple query protocol only.
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 7,
"tags": "postgresql, logging"
}
|
Как изменить директорию сохранения сайтов в open server?
Скачал open server, все работает, но хотелось бы изменить директорию, откуда сервер запускает сайты. Может кто нибудь знает, где можно это настроить?
|
Тоже интересовался, но нужного ответа в этой теме не увидел. Может кому надо будет, то: в настройках во вкладке "Сервер" меняем корневую папку доменов на нужную.:
print('user clicked summary')
|
Try -
# On html file
<form method='get' action='#'>
<input type="submit" value="Next" name="Next"/>
</form>
# In django views
if request.GET.get('Next') == 'Next':
print('user clicked summary')
Because the name of the button is `'Next'` not `'Name'`
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 2,
"tags": "python, html, django, if statement, button"
}
|
Analysis of the Residuals vs Fitted
I have a model for which I gathered 10 observations from each person, a total of 25 people, then 250 observations.
Well, this is part of my summary of the model,
> summary(m)
Call:
lm(formula = fmla, data = mydata)
Residuals:
Min 1Q Median 3Q Max
-9.3311 -3.8480 -0.3134 3.3273 13.4413
Residual standard error: 5.246 on 216 degrees of freedom
Multiple R-squared: 0.7702, Adjusted R-squared: 0.7351
F-statistic: 21.94 on 33 and 216 DF, p-value: < 2.2e-16
Looking at this results may seem that the model is pretty significant, but when I plot the Residuals vs Fitted I get this plot,
!enter image description here
Which suggests me that there is a pattern in the plot. I figure this is about the 10 observations for each person. Can anyone help me analyse this plot?
|
Note that within each diagonal band, the residual decreases by one unit for every one unit the fitted value increases. This looks to me like the response for a given subject remains relatively constant and the predictors change a little bit between observations. Thus when the change in predictors predict a unit increase in mean response (fitted value) and the observed response remains the same, the residual for that observation decreases by one unit.
Because you have multiple observations from each subject, your data exhibits clustering, and you should use a method that handles clustered data if you wish to keep all of your observations as-is. However, if your predictors are indeed less stable or more prone to measurement error than your response, you might think about regressing the mean response on the mean predictor values per subject, or some similar procedure.
|
stackexchange-stats
|
{
"answer_score": 7,
"question_score": 5,
"tags": "r, regression, linear model, residuals"
}
|
nav with display: inline-block not centering in css?
I am trying to center my nav with display:inline-block in css?
nav {
position: fixed;
width: 100%;
}
nav ul {
width: 100%;
margin: auto;
}
nav ul li {
display: inline-block;
margin: 5px 20px 5px 20px;
text-align: center;
}
|
Simply add `text-align:center;` to the parent element of the `inline-block` element.
nav {
position: fixed;
width: 100%;
}
nav ul {
width: 100%;
margin: auto;
text-align:center;
}
nav ul li {
display: inline-block;
margin: 5px 20px 5px 20px;
text-align: center;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "css, block, center, inline"
}
|
sending the request to physical process in Castalia?
when sensor manager sends the request to physical process using gate index for sensor device :
send(requestMsg, "toNodeContainerModule", corrPhyProcess[sensorIndex]);
will the physical process receive the request message regardless of the distance with node? or whether the physical process receives the msg or not will depend on the distance?
The physical process has a fixed value and it never changes.
|
The physical process will always get the message from any node.
Figure 1 of the Castalia manual shows that a physical process module is connected to all the nodes. So when a node sends an OMNeT message to that module, it will be received.
Of course, what will the physical process do with the message and what value it will return, it depends on the specific physical process you implement.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "omnet++"
}
|
How to add a semi-transparent shade over elements in WPF?
I would like to add a semi-transparent colour over the contents of a WPF window (to indicate the state of the window). Currently I am using a UserControl that fills the Window, and I change the Background colour and Visibility as required.
The problem with this method is when the UserControl is visible, I cannot click any controls (Buttons, CheckBoxes) in the Window behind the UserControl. I guess I need to make the UserControl transparent to clicks somehow. Is this possible, or is there a better way to add the colour over the Window?
|
You could set `IsHitTestVisible` to `False` on your masking element.
<Grid>
<Button>Background Button</Button>
<Rectangle Fill="Blue" Opacity="0.25" IsHitTestVisible="False"/>
</Grid>
Try that XAML out in something like Kaxaml. You will still be able to click the button, yet the blue rectangle will be presented over the top. It is semi-transparent due to the low opacity setting.
|
stackexchange-stackoverflow
|
{
"answer_score": 18,
"question_score": 9,
"tags": "c#, .net, wpf, user interface"
}
|
goto-file in Emacs
Is there a substitute in emacs for the vi `gf` command? I mean to open the file which is under the cursor right now, if a real file name is in fact there.
|
You want the `find-file-at-point` function (which is also aliased to `ffap`). It's not bound to a key by default, but you can use
M-x ffap
Or, you can put in your `.emacs` file:
(ffap-bindings)
This will replace many of the normal `find-file` key bindings (like `C-x C-f`) with `ffap`-based versions. See the commentary in `ffap.el` for details.
|
stackexchange-stackoverflow
|
{
"answer_score": 76,
"question_score": 54,
"tags": "emacs"
}
|
Query for an exact match for a string in to a column having text fields(more then one strings)
In my data base table i have a field "description" which is a text field. it contains values like it :
This bracelet is composed of round diamond surrounded by milgrain detailing. Its secure setting prevents it from twisting and ensures it will sit impeccably on her wrist.
This stylish design is the perfect accessory for the day or evening. Akoya cultured pearls are lined up by a string of bezel-set round diamond.
I want to query for the columns which contains exact word "diamond"
when i query as `select description from tproduct where description like '%diamond%'` it give me the result but it runs as wild card query
where i want to exact match for "diamond"
I did as select `description from tproduct where description ='diamond'` But it is not giving any result
Please tell me how to query for this.
Thanks Romi
|
One simple way is to put spaces around the word in your query:
SELECT ... WHERE description LIKE '% diamond %';
That doesn't work so well if your sentence ends with "diamond.", however.
For something much more complex, you really need to use some sort of full-text indexing, which I have no experience with in MySQL.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "mysql, sql, squirrel sql"
}
|
Find occurrences of characters in a Java String
I would like to count the occurrences of a character in a string, suppose I have the string "aaaab", how would i count the amount of a's in it?
|
The code looks way easier to read if you don't use regular expressions.
int count = 0;
for(int i =0; i < string.length(); i++)
if(string.charAt(i) == 'a')
count++;
`count` now contains the number of 'a's in your string. And, this performs in optimal time.
Regular expressions are nice for pattern matching. But just a regular loop will get the job done here.
|
stackexchange-stackoverflow
|
{
"answer_score": 14,
"question_score": 20,
"tags": "java, regex"
}
|
Prevent browser from closing in asp.net
I am using asp.net 2.0 with c#.
i want a pop up to be displayed when user tries to close the browser and if user click on "no" [i.e. he don't want browser to be closed] then it prevent browser to get closed. Please help. Thanks
|
the code they use is
window.onbeforeunload=function() {
if (somereasonorother) return "You did not save your stuff"
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "javascript, asp.net"
}
|
make mistakes to push large file to git
I have a question: I made a mistake to push a large file to git, and then I git rm it, however, the git repository has contained this large file, if someone else want to git pull or git clone it, he has to download this large but useless file. How to solve this problem? Thank you very much.
|
You must have force push permission to _really_ undo your last commit:
This kills last commit:
git reset --hard HEAD~
And this pushes it to server:
git push origin master --force
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -1,
"tags": "git, push"
}
|
keypress on datagridview only character "abcde" and convert to uppercase
How to limit `keypress` on `datagridview` only character **abcde** and convert to uppercase at vb.net?
Private Sub DataGridView1_EditingControlShowing(sender As Object, e As DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
If DataGridView1.CurrentCell.ColumnIndex = 3 Then
AddHandler CType(e.Control, TextBox).KeyPress, AddressOf TextBoxabcde_keyPress
End If
End Sub
Private Sub TextBoxabcde_keyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
If Not Char.IsControl(e.KeyChar) And Not Char.IsLetter(e.KeyChar) And e.KeyChar <> "." Then
e.Handled = True
End If
End Sub
|
**Updated:**
Private Sub DataGridView1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles DataGridView1.KeyPress
Dim allLetters As String = "abcde"
If Not allLetters.Contains(e.KeyChar.ToString.ToLower) Then
e.KeyChar = ChrW(0)
e.Handled = True
End If
End Sub
Private Sub dataGridView1_CellFormatting(sender As Object, e As
DataGridViewCellFormattingEventArgs)
If e.Value IsNot Nothing Then
e.Value = e.Value.ToString().ToUpper()
e.FormattingApplied = True
End If
End Sub
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "vb.net, datagridview"
}
|
Optimizing UV Map Sheet Based On Surface Area?
I am trying to get my UV Map Sheets Optimized Based On Surface Area , I need Them optimized cause my scene area is huge and i want to use them in UDK so i am trying to get maximum possible optimization and i am running out of time
Here is What i Try TO Achieve :
**Default 3DS Max** :
!Default Max Output
**Optimized By HAND** _THIS IS WHAT I WANT Or Even Better If There Is Automated Intelligence Tool_
!Optimized By Hand
Also I know this Tools **Flatiron** , **UVPacker** But They Are No Use
|
UVLayout is a professional tool which is specialized in optimizing UV layouts and general UV editing.
Here are some of the features (I highlighted the ones that are probably interesting for your use-case) (source):
> * OBJ import and export
> * Edge-loop Detection for quicker UV seam selection
> * Symmetry Editing for faster flattening of symmetrical meshes
> * Edge Straightening on shell boundaries and interiors
> * Flattening Brushes for local tweaks of the automatically generated UVs
> * **Auto Packing of UV shells to minimize wasted texture space**
> * **Auto Stacking of similar shells for shared texture space usage**
> * Subdivision Surface calculations based on limit surface shape
> * Unlimited Undo of all editing functions
> * Plugin Interface for integration into other applications
>
|
stackexchange-gamedev
|
{
"answer_score": 1,
"question_score": 1,
"tags": "udk, optimization, uv mapping"
}
|
how to get rows created with DataTable.NewRow() in C# / ADO.NET 2.0?
Now I use Select and use a criteria which select only new rows. But is there any kind of GetInsertedRows-method. If I remember correctly there is status for each row so naturally one can loop through them all but that's not elegant.
-Cheers -Matti
|
I like TypeT's answer but it may help to know that you always bind through a DataView to a DataTable and you can set it to filter on the rows state:
myDataSet.myTable.DefaultView.RowStateFilter = DataViewRowState.Added;
You can also create an additional DataView to look at the new or deleted rows, and then those Views won't byte each other:
var addedView = new DataView(myDataSet.myTable);
addedView.RowStateFilter = DataViewRowState.Added;
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "c#, ado.net, datatable"
}
|
Is it possible to know what string replaces a wildcard in a regex comparison?
Suppose I check whether a string match a regex with wildcard. How can I programatically get extract which substring replaces the wildcard?
Simple example: the regex is `"[foo|bar].*\.txt"` and say, a matching string that is found is "foo123.txt". In this case the answer I want is "123", since it is the substring that replaces the wildcard. If a matching string is bar0123456789.txt, then the answer is 0123456789.
I use c#, but I wouldn't mind answers in other languages that I can also implement in c#
|
Don't use square brackets, if you want a group. Square brackets create a character class.
What you want is a non capturing group for that:
(?:foo|bar).*\.txt
To get the result from the `.*` (`.` is a special character that matches any character, but Newline characters (by default) and `*` is a quantifier that repeats the previous character 0 or more times), you need to put it into a capturing group.
(?:foo|bar)(.*)\.txt
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "regex, language agnostic"
}
|
Android MediaPlayer fails (status 0x80000000) when calling prepare (local mp3 file)
I've finished developing a game, but it's very annoying that sometimes (yes, only sometimes!) when I open it, it fails, and I can see in logcat this error: java.io.IOException: Prepare failed.: status=0x80000000.
It's very weird because it's a local file (2MB mp3 file), and I don't know why it shows a IOException. And only sometimes, not always...
EDIT: It seems that is related with proguard, because it only happens with release version...
|
I finally solved it.
It happened because my MediaPlayer variables were static, so when I restart the app I was creating more MediaPlayers without releasing previous ones, and there is a limit of 8 (at least in Android 2.3.6, where I tested it). Calling mediaPlayer.release() (if mediaPlayer != null, of course) it's solved.
Hope it helps someone.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 1,
"tags": "android, android mediaplayer"
}
|
Lipschitz continuous dynamical system
I stumbled upon the notion of a Lipschitz continuous dynamical system, and was wondering what this exactly meant. I guess it means that all solutions to (in my case the dynamical system is a set of ODE's) are Lipschitz continuous, but I wanted to be sure.
Thanks
|
It means that the right side in $\dot y=f(t,y)$ is Lipschitz-continuous in $y$. Then the uniqueness theorem applies (Picard-Lindelöf) and also numerical simulation will give meaningful results.
The solutions will be continuously differentiable, if the function $f$ is Lipschitz in all variables, then the solutions have (locally) Lipschitz continuous derivatives.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "dynamical systems, lipschitz functions"
}
|
Optimal Way To Generate A Balanced Binary Search Tree From A Stream Of Sorted Numbers
I have an input stream of integers coming in an ascending order, my task is to create a balance binary search tree out of that stream, on the fly. I have gone through the link:BBST from a stream of integers and understood that we can make use of Red-Black trees. The thing is, I am looking for more optimal solutions that use 'sorted information' from the input data.
|
If you use a red-black tree but always start your insertion at the last node inserted, rather than the root, and use a bottom up insertion algorithm, insertion is O(1) amortized. This means constructing the tree will cost O(n), not Ω(n log n).
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "algorithm, data structures, binary search tree, data stream"
}
|
How to find String.indexOf("\")?
I need to get the substring that appears before a bunch of \r\n\r\n junk. So I want to geto the first /that appears. indexOf("\") is not accepted. String.indexOf("\") does not match the first . ????? Thanks
|
If you're looking for the first occurrence of `\n` in a string then searching for `\\` won't help. You need to look for `\n`.
String.indexOf("\n")
Note that `\n` is one character, not two. It's an escape sequence that evaluates to the character with ASCII value 10.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "java, string"
}
|
Convergence and divergence at an end point
Is it possible for a series to converge at some given end point $x = A$ and at the same time the differentiated series to diverge at this point?
|
Sure, $x^n$ on $[0,1]$ converges for $x=1$ but $nx^{n-1}$ diverges for $x=1$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 4,
"tags": "real analysis, sequences and series"
}
|
Split list of lines into 2d array
I have set of sequences in a list which looks like this :
[agghd,gjg,tomt]
How to split it so that my output looks like the following :
[[a,g,g,h,d],[g,j,g],[t,o,m,t]]
I have done the following code for now :
agghd
gjh
tomt
list2=[]
list2 = [str(sequences.seq).split() for sequences in family]
|
You can split a string to characters by calling `list()` on it
list1 = ['agghd', 'gjg', 'tomt']
list2 = [list(string) for string in list1]
# output: [['a', 'g', 'g', 'h', 'd'], ['g', 'j', 'g'], ['t', 'o', 'm', 't']]
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "python, arrays, list, split, biopython"
}
|
Proving there exist an infinite number of real numbers satisfying an equality
Prove there exist infinitely many real numbers $x$ such that $2x-x^2 \gt \frac{999999}{1000000}$.
I'm not really sure of the thought process behind this, I know that $(0,1)$ is uncountable but I dont know how to apply that property to this situation.
Any help would be appreciated,
Thanks,
Mrs. Clinton
|
Firstly we are guessing you have one too many $9$ on the top. We proceed with $\frac{999999}{1000000}$
Define $f(x)=2x-x^2$ then $f$ has its maximum at $1$ and its maximum is $1$. Now as $f$ is continuous we can find a neighborhood (which means an open interval) around $x=1$ so that if $y$ is in the neighborhood, then $f(1)-f(y)<\frac{1}{1000000}$.
Thus $f(y)>f(1)-\frac{1}{1000000}=\frac{999999}{1000000}$.
Hence every point in our open interval satisfies the inequality and as open intervals have infinite cardinality we are done.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 2,
"tags": "calculus, real analysis, discrete mathematics"
}
|
Let $x$ be a real number. If $x^3 + 7x^2 − 8 \leq 0$, then $x \leq 1$.
I was just wondering if this is a good way to write out this proof statement. I used proof by contradiction. I am pretty new at using this so I was just wondering if anyone on here could give me advice on the formatting of my proof.
**PROOF:** Suppose the opposite, $x^3+7x^2-8 \leq 0$ and $x>1$. If $P$ and $\neg Q$ for all $x>1$, then it should be true for $x=2$. Thus, $(2)^3 + 7(2)^2 - 8 \leq 0 \implies 8 + 28 - 8 \leq 0 \implies 28$ is not $\leq 0$.
Therefore, $P$ and $\neq Q$ is false. $\square$
|
Note, as a part of the _definition_ of the $<$ sign and positive/negative numbers one has the following property:
> Given $a>0$ and $b>c$ it follows that $ab>ac$
In particular then, supposing $x>1$ one has
$x^2=x\cdot x> x\cdot 1=x$
Applying this once again, we have $x^3>x$ for all $x>1$
* * *
Suppose for the sake of proof by contrapositive that $x>1$
It follows then that $x^3>x>1$ and $7x^2>7x>7$ and therefore we have
$x^3+7x-8>1+7-8=0$
This proves then by contrapositive that $x^3+7x-8\leq 0$ implies $x\leq 1$
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 2,
"tags": "algebra precalculus, inequality, proof verification, proof writing"
}
|
Reading user attributes
So on create/update methods, there's a attributes param, described as "base64 encoded JSON document describing the user attributes".
However, on both the read user and the auth/me endpoints, it doesn't return the attributes. How can we retrieve the data?
|
Add 'full=1' as a query parameter and it should return the User attributes for both endpoints. We missed that param in our docs so we will go ahead and make the addition.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "truevault"
}
|
Calculate a function using the fact that is multilinear and alternant
I'm currently working in the following excercise:
> Be $f$ defined in $\mathbb{R}^4 \times \mathbb{R}^4 \times \mathbb{R}^4 \times \mathbb{R}^4$ a function, calculate it in
>
> $$ \begin{pmatrix} 1\\\ 2\\\ 0\\\ 1 \end{pmatrix}, \begin{pmatrix} 3\\\ 2\\\ 4\\\ 0 \end{pmatrix}, \begin{pmatrix} 0\\\ 1\\\ 7\\\ 2 \end{pmatrix}, \begin{pmatrix} 1\\\ 6\\\ 3\\\ 1 \end{pmatrix} $$
>
> Using the fact that $f$ is multilinear and alternant
How could I calculate a function without knowing it? Also I've tried to play with the information provided but is not too clear to me how the fact that $f$ is multilinear and alternant helps. Thanks in advance for any hint or help and for taking the time to read my question.
|
Show that $f=\lambda\det$ for some $\lambda\in \mathbb{R}$. Then compute the determinant.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "abstract algebra, functions, discrete mathematics"
}
|
Android JobScheduler - setRequiredNetworkType not working
I tried to make the JobScheduler with 1 simply constraint condition: **setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)**
JobScheduler jobScheduler = (JobScheduler) mContext.getSystemService(Context.JOB_SCHEDULER_SERVICE);
ComponentName componentName = new ComponentName(mContext.getPackageName(), JobOneService.class.getName());
JobInfo jobInfo = new JobInfo.Builder(1, componentName)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.setPersisted(true)
.build();
jobScheduler.schedule(jobInfo);
The JobOneService is extended the JobService class. I tried to simulate the condition by the way: turn off then turn on the wifi network. But the onStartJob() method not always called (intermittent called).
Anyone can help me explain why does onStartJob() not always called once I turn on the wifi connection? Thanks
|
In the documentation, they mentioned that setRequiredNetworkType use for
> Calling this method defines network as a strict requirement for your job. If the network requested is not available your job will never run.
So it checks for network connectivity. If the network is connected then your job will run else your job will not run. If you want that when network connected again your job should run then you have to write your logic for that. It's better to use WorkManager because WorkManager handles it properly.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "android, job scheduling, android jobscheduler"
}
|
Which is a better gem for indextank?
I am using indextank with heroku. Which is a better gem to use, indextank or thinkingtank? I looked at the documentation, and tutorials for both,and it seems like thinkingtank is easier to use. A related/follow up question: what are the advantages/disadvantages of each?
|
It depends on what you're doing. If you are writing a simple app that's not based on ActiveRecord, the indextank client lets you add and search content without storing anything within your app. An example: if you are fetching tweets, you could index them directly without having a data model on your side. It's more "low level", so to speak.
If you are using ActiveRecord or another ORM, you should take a look at Tanker, it's more actively developed than ThinkingTank:
<
Hope this answers your question, if not please come chat with us at < (chat widget on the main page) and we'll be happy to help!
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 4,
"tags": "ruby on rails, heroku, indextank"
}
|
Inserting One Row Each Time in a Sequence from Matrix into Another Matrix After Every nth Row in Matlab
I have matrix A and matrix B. Matrix A is 100*3. Matrix B is 10*3. I need to insert one row from matrix B each time in a sequence into matrix A after every 10th row. The result would be Matrix A with 110*3. How can I do this in Matlab?
|
Here's another indexing-based approach:
n = 10;
C = [A; B];
[~, ind] = sort([1:size(A,1) n*(1:size(B,1))+.5]);
C = C(ind,:);
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 3,
"tags": "arrays, matlab, matrix"
}
|
get element from inside webview javascript chrome app
I've been searching on google for a while now and I couldn't really find much regarding this topic so I wanted to know if it's even possible:
> Can I get an html element from a loaded page inside a `<webview>` and store it's attributes for later use outside of my `<webview>`?
|
You can use webview.executeScript along with postMessage to communicate the data back out of the webview
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, webview, google chrome app"
}
|
Can I power an outdoor security light from a non-EV garage receptacle?
I'm planning to install an outdoor floodlight above my rolling garage door, and there is a continuously powered receptacle in the rafters above the garage door that's just a few feet from the other side of the wall where I want to install the light. Running some new Romex from that receptacle through a hole and into an outdoor junction box for the floodlight seems like an easy installation.
However, I've read that new code requires that no garage receptacles power outdoor security lights. Is this an issue even for ones that are not intended for EV car charging, like my garage door opener receptacle?
Here's a photo of the receptacle powering the garage door opener, and the wall above the garage door where I'd be drilling a hole:
 (1). For attached and detached garages with electric power, the branch circuit supplying the garage receptacle(s) will not supply any outlets outside the garage. And at least one receptacle outlet shall be installed for each car space.
An "outlet" is defined as "A point on the wiring system at which current is taken to supply utilization equipment."
So, your outdoor floodlight power should come from elsewhere.
Sorry
|
stackexchange-diy
|
{
"answer_score": 1,
"question_score": 1,
"tags": "electrical, lighting"
}
|
Non Uniform Date columns in Pandas dataframe
my dataframe looks like:
a = DataFrame({'clicks': {0: 4020, 1: 3718, 2: 2700, 3: 3867, 4: 4018, 5:
4760, 6: 4029},'date': {0: '23-02-2016', 1: '24-02-2016', 2: '11/2/2016',
3: '12/2/2016', 4: '13-02-2016', 5: '14-02-2016', 6: '15-02-2016'}})
Rows have 2 different formattings.
The format I need is:
a = DataFrame({'clicks': {0: 4020, 1: 3718, 2: 2700, 3: 3867, 4: 4018,
5: 4760, 6: 4029}, 'date': {0: '2/23/2016',1: '2/24/2016', 2: '2/11/2016',
3: '2/12/2016', 4: '2/13/2016', 5: '2/14/2016', 6: '2/15/2016'}})
So far I managed to open the csv in Excel as text data, UTF-8 format and then choose a MDY formatting for the date column. Moreover I apply:
a['date'] = a['date'].apply(lambda x: datetime.strptime(x,'%m/%d/%Y'))
How can I efficiently do that in Pandas?
|
You can convert to `datetime` using `to_datetime` and then call `dt.strftime` to get it in the format you want:
In [21]:
a['date'] = pd.to_datetime(a['date']).dt.strftime('%m/%d/%Y')
a
Out[21]:
clicks date
0 4020 02/23/2016
1 3718 02/24/2016
2 2700 02/11/2016
3 3867 02/12/2016
4 4018 02/13/2016
5 4760 02/14/2016
6 4029 02/15/2016
if the column is already `datetime` dtype then you can skip the `to_datetime` step
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "python, datetime, pandas"
}
|
How add Pie chart ShowEffect and HideEffect in flex?
Im trying to add showEffect and HideEffect for pie chart.Did not find good example.Guys do you have any idea about this ?
|
I recommend you work on the Chart PieSeries and play with interpolated and shadows, plus some effects of rotation. The leave some links that may be useful
Link 1
Link 2
Link 3
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "actionscript 3, apache flex, flex4, flex3, flex4.5"
}
|
Proof that x in domain of a function F is an element of $ (F^{-1} \circ F) (x)$
Let A and B be two non-empty and finite sets. Let $a\in A$ and $b \in B$.
Let $F:$ $A$ $\rightarrow$ $B$ and $G: B$ $\rightarrow$ $P(A)$ defined by $G(b):= F^{-1}(b) $.
Prove that for all $a$, $a\in (G\circ F)(a)$.
My proof:
By the definition of a function, for every $a\in A$, there is an unique $b=F(a)\in ImF \subseteq B$.
For every $b \in ImF$, $G(b)$ returns a non-empty set containing all $a_i$ such that $F(a_i) = b$.
Therefore, for $a\in A$, $a \in G(b) = G(F(a)) = (G\circ F)(a)$.
|
Your proof is correct but, in my opinion, can be written better. Notice that the above claim does not really require $A$ and $B$ to be nonempty.
Let $A$ and $B$ be nonempty sets and $f\colon A\to B.$ We claim that, for all $a\in A, $ we have $$a \in (g\circ f)(a)$$ where $g\colon B\to P(A)$ is defined by $g(b) = f^{-1}(b)$ for all $b\in B.$
Let $a\in A$ be arbitrary. Then, as $f\colon A\to B, f(a) \in B.$ Now, by definition of $g\circ f, $ we have $$(g\circ f)(a) = \\{ a'\in A \mid f(a') = f(a) \\}.$$ As $a\in A$ and $f(a) = f(a), $ it follows that $a \in (g\circ f)(a).$
* * *
Please see if this proof feels better written to you.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "functions, discrete mathematics, elementary set theory, solution verification"
}
|
Fragments and animations android
I have a question. This is possible to animate fragment. This is what I mean: I click on the button and from right side showing fragment.Something like you go to next page when you are reading pdf. If yes how?
|
You might want to read these questions:
* Fragment standard transition not animating
* Android Fragments and animation
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "android, android layout"
}
|
Map<String, Map<String, String>> - Select key of value using Stream
I have this Map:
Map<String, Map<String, String>> listMap = new HashMap<>();
I want to select all distinct `Keys` from `Map` which is value in main `Map`: `listMap.value.key`
List<String> distinct = listMap.entrySet().stream()
.map(e -> e.getValue()) //Map<String, String>
//Select key of value
.distinct().collect(Collectors.toList());
I don't know how to select `key` of `value` of `listMap`.
|
You need `flatMap` in order to map all the keys of all the inner `Map`s into a single `Stream`:
List<String> distinct =
listMap.values() // Collection<Map<String,String>>
.stream() // Stream<Map<String,String>>
.flatMap(map -> map.keySet().stream()) // Stream<String>
.distinct() // Stream<String>
.collect(Collectors.toList()); // List<String>
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 1,
"tags": "java, lambda, java stream"
}
|
find limit (lim n->infinity an) sequence an = (5n-1)!/(5n+1)!
Determine whether the sequence converges or diverges. If it converges, find the limit. If it diverges write NONE.
$a_n = \frac {(5n-1)!}{(5n+1)!}$
$\displaystyle\lim_{n \to \infty} a_n=?$
* * *
the answer is $0$, but I have no idea how to get the value.
|
We have
$$a_n=\frac{(5n-1)!}{(5n+1)!}$$
$$a_n=\frac{1.2.3...(5n-1)}{1.2.3...(5n-1)5n(5n+1)}$$
$$=\frac{1}{5n(5n+1)}$$
So,
$$\lim_{n\to+\infty}a_n=0.$$
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 0,
"tags": "sequences and series, limits"
}
|
How to stop functions from running until they are called upon javascript
I have an array with functions: `var ranArray = [funct1(), funct2()]` and the functions themselves:
function funct1() {
document.write("hello");
};
function funct2() {
document.write("hi");
};
I am trying to make it so that whenever a button is pressed, either funct1 or funct2 is executed. However, without me even pressing the button, on the page I see my button and "hellohi". Here is the function for the randomization:
function getFunctions() {
return ranArray[Math.floor(Math.random * ranArray.length)];
};
and here is the HTML:
<button type="button" name="ranButton" id="ranButton" onclick="getFunctions();">Random Button</button>
|
Your array declaration is actually calling `funct1` and `funct2` and trying to store the return values in the array. What you want is an array of functions. Remove the parentheses so the functions themselves are stored in the array rather than the return values. It should look like this:
var ranArray = [funct1, funct2];
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript"
}
|
How can I create a view which includes all parent terms of a taxonomy term?
I am creating a view which takes a tid as an argument. I then want to generate the full list of tids which includes the one directly referenced plus all those above it in its taxonomy.
How could I do this?
|
I guess you can't do it directly in views. You can use "Contextual filter: Taxonomy term: Term ID" and write small php code by selecting "Provide default value".
;
$parent_terms_array = taxonomy_get_parents_all($current_tid);
foreach($parent_terms_array as $term){
if($current_tid != $term->tid){
$parent_terms_tid_array[] = $term->tid;
}
}
$parent_terms_string = implode('+', $parent_terms_tid_array);
return $parent_terms_string;
|
stackexchange-drupal
|
{
"answer_score": 2,
"question_score": 2,
"tags": "7, views, taxonomy terms"
}
|
Wp8 cant find csv file in project
I'm using the MVVM structure and I wish to read a csv file, which I've added in the same folder as the viewmodel. I've tried to use the second answer in this question, but my variable var is null, so it doesn't seem to find the file. Beneath is an image of the folders and what I've done so far.
!enter image description here
Can anyone help me get the destination of the file so I can use it as a stream?
|
You need to provide a path relative to your package, thus it should work if done like this:
var dest = App.GetResourceStream(new Uri(@"StartUpViewModels/" + destination, UriKind.Relative));
Here is also reference to answer to similar question.
Remember also to check if your resource file added to package has _Build Action_ set to _Content_ , otherwise if it's set to _None_ , your file won't be added.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c#, windows phone 8, path, stream, directory"
}
|
locate command does not work on mac terminal
I'm working on Mac (Catalina, 10.15.7) and want to use the `locate <...>`-command. After typing `locate ...` it suggested me the following, which I did.
WARNING: The locate database (/var/db/locate.database) does not exist.
To create the database, run the following command:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.
After creating the database, I wanted to perform the `locate`-command. This didn't work as expected. Instead this came up:
locate: locate database header corrupt, bigram char outside 0, 32-127: -1
What can I do to fix this? Thank you so much for your help.
|
You can try to delete (or move) the locatedb file, e.g. `mv /var/db/locate.database /var/db/locate.database.backup` and then regenerate the database from scratch using `/usr/libexec/locate.updatedb`. You will need to use `sudo` for these commands:
`sudo mv /var/db/locate.database /var/db/locate.database.backup`
`sudo /usr/libexec/locate.updatedb`
|
stackexchange-superuser
|
{
"answer_score": 3,
"question_score": 1,
"tags": "database, terminal.app, locate"
}
|
How is pronunciation discussed in Chinese?
Here's an English example:
> Learner: Wait, how is _c-o-w_ pronounced?
> Native: COW, like a K sound followed by _ow._
But in Chinese there are no phonetic letters. So how are children taught how to pronounce something, other than to hear the difference by someone who already knows it? Unless they're taught pinyin (which didn't even used to exist), how on earth could you specify the difference between, for example, _j_ and _q_ , if the learner were uncertain which sound was being used in the pronunciation of a given word or character?
|
Nowadays schoolchildren are taught Pinyin pretty thoroughly first, so they know how to correctly pronounce Pinyin. Then when learning new words, all they have to do is learn the Pinyin. A lot of primary/elementary textbooks will have annotations like this:
.css('height',470)` and `$(element).css('height','470px')` but neither of these worked.
|
After the function which adds the element has run, use the following:
`$(element).height(247)`
This works a treat for me
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "jquery, css, height"
}
|
Select row with max value saving distinct column
I have values
- id|type|Status|Comment
- 1 | P | 1 | AAA
- 2 | P | 2 | BBB
- 3 | P | 3 | CCC
- 4 | S | 1 | DDD
- 5 | S | 2 | EEE
I wan to get values for each type with max status and with comment from the row with max status:
- id|type|Status|Comment
- 3 | P | 3 | CCC
- 5 | S | 2 | EEE
All the existing questions on SO do not care about the right correspondence of Max type and value.
|
This gives you one row per type, which have max status
select * from (
select your_table.*, row_number() over(partition by type order by Status desc) as rn from your_table
) tt
where rn = 1
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "sql, oracle"
}
|
hyperref generates PDF bookmarks for Koma-script document with bookmark option turned off
I would like to stop hyperref from creating bookmarks for a KOMA-Script document. The option bookmarks=false does not work with KOMA classes, it works flawlessly with default classes such as report. Is there any way to disable PDF bookmarks in KOMA-Script documents with the hyperref package.
MWE:
\documentclass{scrreprt}
\usepackage[bookmarks=false]{hyperref}
\begin{document}
\tableofcontents
\chapter{Chapter}
\section{Section}
\end{document}
|
KOMA Script loads the `bookmark` package by default, which overrides `hyperref`'s option. You can disable this with the (apparently undocumented) document class option `bookmarkpackage=false`.
|
stackexchange-tex
|
{
"answer_score": 1,
"question_score": 1,
"tags": "hyperref, koma script"
}
|
Proving a simple property of Floor function
I have to prove the following property of Floor function:
> For any real number $x$, $x$ not being an integer, $\lfloor x \rfloor + \lfloor -x \rfloor = -1$.
Now, we know from the definition of floor that $\lfloor x \rfloor$ is the unique integer $n$ such that $n \leq x < n+1$. The trouble is writing $\lfloor -x \rfloor$. If I imagine a negative real number on the number line, it is _obvious_ that $-n-1 \leq -x < -n$. Then, simply adding the two yields -1.
My problem is that I can't seem to arrive at $\lfloor -x \rfloor$ from the definition. For instance, if $x$ is a postive real number, then the floor is given by
$$n \leq x < n+1$$
Multiplying by -1 throughout,
$$-n \geq -x > -n-1$$
$$\Rightarrow -n-1 < x \leq -n$$
Feels like I'm almost there, but this _**does not**_ match the definition (the $\leq$ has appeared on the upper bound). What am I doing wrong?
|
Put $$\lfloor x\rfloor=:n,\qquad \lfloor-x\rfloor=: n'\ .$$ Then the definition of $\lfloor\cdot\rfloor$ implies together with $x\notin{\mathbb Z}$ that we have $$n<x<n+1\qquad\wedge\qquad n'<-x<n'+1\ .$$ Adding the left parts of these two squeezes gives $n+n'<0$, and adding the right parts leads to $n+n'>-2$. All in all only $n+n'=-1$ remains possible.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 1,
"tags": "discrete mathematics"
}
|
Python: How to ignore an exception while still handling others
I was messing with some code and was faced with a particular problem:
def find_available_slug(object, instance, slug)
try:
sender_node = object.objects.get(slug=slug)
except object.DoesNotExist:
instance.slug = slug
else:
slug = '%s_' % slug
find_available_slug(object, instance, slug)
return
The issue I am having is that sometimes `objects.get(slug=slug)` throws a `MultipleObjectsReturned` exception because that field is not unique within my database. I wonder how I can cleanly catch `MultipleObjectsReturned` while the "else" statement will still get executed.
|
Alternatively, don't use the `else` clause at all:
def find_available_slug(object, instance, slug)
try:
sender_node = object.objects.get(slug=slug)
except object.DoesNotExist:
instance.slug = slug
return
except object.MultipleObjectsReturned:
pass
slug = '%s_' % slug
find_available_slug(object, instance, slug)
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "python, django, exception"
}
|
How to use IF statement before FROM Clause
I have three tables:

feeds_id title name
2 This title added twice by user User-1
3 This title added by company Company-2
1 This title added by user User-3
Demo on dbfiddle
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "mysql"
}
|
Can I get the ProductCode from an InstallShield executable?
I can programmatically query an MSI and retrieve such properties as the ProductCode. Is there a way to query an Installshield executable to get the properties of the MSI that it contains?
|
I guess installshield executable is kind of a self extracting executable. It first extracts files to a temp folder and then runs the setup. If the exe supports commandline switch to extract all the files then you can make it extract through your program and then query the MSI for product code.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "c#, installshield"
}
|
How can I disable automatic epstopdf conversion of .eps figures?
As far as I understand my TexLive 2014 distribution performs automatic eps to pdf conversion for `\includegraphics` where it find only an .eps file. However I would like to disable this automatic conversion because it messes with my own Makefile and latexmk custom dependencies conversion scheme.
Is there a way to disable this automatic conversion in TexLive?
|
Add `\newcommand{\DoNotLoadEpstopdf}{}` before loading `graphicx`; the start of the file, before `\documentclass` is a good place.
From `pdftex.def`:
% In other words, by default .eps files will be automatically
% converted to .pdf files when outputting pdf. This can be wrong!
% If the .pdf is the source, rather than the .eps, you should put
% \newcommand{\DoNotLoadEpstopdf}{}
% before even the \documentclass line of your document.
|
stackexchange-tex
|
{
"answer_score": 3,
"question_score": 1,
"tags": "texlive, epstopdf"
}
|
Filtering a file
I have a file that contains many lines :
at 12:00 the schedule is :
first_task:eating:fruit
second_task:rest:onehour
third_task:watching:horrorfilm
at 18:00 the schedule is :
first_task:eating:vegetals
second_task:rest:threehours
third_task:watching:manga
at 22:00 the schedule is :
first_task:eating:nothing
second_task:rest:sevenhours
third_task:watching:nothing
I tried to search before Asking . but I didn't find a way to filter the file the way I liked .
I would like to get a filtered file like this : for example If I would like to know what I am going to eat today .
at 12:00 eating:fruit
at 18:00 eating:vegetals
at 22:00 eating:nothing
Is there any way to do this using awk or bash ?
|
Using `awk`, you can do it as:
awk -F '[\ :]' '/the schedule is/{h=$2;m=$3} /eating/{print "at "h":"m" eating:"$3}' filename
Output:
at 12:00 eating:fruit
at 18:00 eating:vegetals
at 22:00 eating:nothing
This will give correct answer, even if you have `eating` as second or third task.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "bash, file, unix, awk, filefilter"
}
|
The bound for the conditional expectation related to a sub-gaussian random vector
Let $X,Y$ be two mean-zero, independent subgaussian random vectors and assume their sub-gaussian norms are both bounded by a positive number $K$.
Recall that for a mean-zero real-valued sub-gaussian random variable $Z$, we have the bound
$$\mathbb E\exp(\lambda Z)\le \exp(C\lambda^2\|Z\|^2_{\phi_2}), \forall \lambda\in \mathbb R.$$
I want to prove the following inequality
$$\mathbb E[\exp(\lambda X^TY)\mid Y]\le \exp(C'\lambda^2 K^2 \|Y\|^2_2), \forall \lambda\in \mathbb R.$$
One of the major difficulties for this generalization is that the conditional expectation of two independent random variables may not be uncorrelated and thus the multiplicity rule of the $\exp$ may not work.
|
Note that $$\mathbb{E}[\exp(\lambda X^{T}Y) \mid Y] = \mathbb{E}\left[\exp\left(\lambda\|Y\|_2 X^{T}\frac{Y}{\|Y\|_2}\right) \mid Y\right].$$
Because we condition on $Y$ and $X$ is independent of $Y$, we can simply take the terms involving $Y$ within the expectation to be constant (you can make this rigorous, e.g., by invoking the law of the unconscious statistician). Using the definition of a sub-Gaussian random vector in these notes (see Definition 1.2 therein and the discussion after it), we then have
$$\mathbb{E}\left[\exp\left(\lambda\|Y\|_2 X^{T}\frac{Y}{\|Y\|_2}\right) \mid Y\right] \leq \exp(C\lambda^2 \|Y\|^2_2 \|X\|^2_{\phi_2}).$$
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 1,
"tags": "probability theory"
}
|
killing process in linux
I need to kill all the process on the remote host with owner as "user1"
I am using command:
ps -efww | grep "user1"| awk '{print $2}' | xargs kill
But the problem is that I have used same user "user1" to ssh to the remote machine. and executing this command also kills the sshd process.
Can any one help me with this command, so that all the other process except the one for ssh is killed.
|
You can exclude the sshd process by piping `| grep -v "sshd"`.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "linux, shell, unix"
}
|
$4q=a^2+27b^2$ elementary proof of uniqueness
I’m trying to prove that if $q$ is prime then the representation $$4q=a^2+27b^2$$ is unique (up to sign). Any help would be appreciated.
**Edit** : By elementary I mean only using divisibility rules, modular arithmetic, etc.
|
Suppose that $4q=a^2+27b^2=c^2+27d^2$ and $a,b,c,d> 0$ (equals 0 is not possible).
We have $a^2d^2-b^2c^2\equiv 0 $ mod $q$.
Then $(ad-bc)(ad+bc)\equiv 0$ mod $q$.
If $ad+bc\equiv 0$ mod $q$, then by $16q^2=(a^2+27b^2)(c^2+27d^2)=(ac-27bd)^2+27(ad+bc)^2$, we must have $ad+bc=0$. This is impossible, so we have $ad-bc \equiv 0 $ mod $q$.
By $16q^2=(a^2+27b^2)(c^2+27d^2)=(ac+27bd)^2+27(ad-bc)^2$,
we have $ad-bc=0$. Thus, $a/c=b/d=t$ gives $a^2+27b^2=t^2(c^2+27d^2)=c^2+27d^2$. Hence, $t^2=1$ and $t=\pm 1$. Since $a,b,c,d> 0$, we must have $a=c$ and $b=d$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 4,
"tags": "elementary number theory, prime numbers, modular arithmetic, divisibility, integers"
}
|
Terraform AWS ALB Module: disable HTTP/2
Following the instruction for alb module of Terraform <
I can't understand how to disable HTTP/2 can you help me?
|
Judging by the module requirements, the `enable_http2` variable is optional [1] and by default set to `true`. You can change that by adding this variable when calling the module and setting it to `false`:
enable_http2 = false
* * *
[1] <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "amazon web services, terraform, aws application load balancer"
}
|
Add tab in text sent from Matlab to Word
I would like to write a string containing a tab in Word from Matlab. Here is what I have done:
word = actxserver('Word.Application');
selection=word.Selection;
selection.TypeText('This document presents the results of ^t my study.')
This will not work, it simply displays ^t. I have also tried to use vbtab instead of ^t, same thing: only displays text. How can I send a string containing a tab to Word from Matlab?
|
If `'\t'` does not work, try using `char(9)`:
selection.TypeText(['This document presents the results of ',char(9),' my study.'])
9 is the ASCII code for the tab character.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "vba, matlab, ms word"
}
|
For Loop Swift: Cast from to unrelated type always fails
I have an error that says `Cast from '[String : AnyObject]' to unrelated type '[[String : AnyObject]]' always fails`
for dict in json as! [[String: AnyObject]] {
let VideoCategory = videoCategory()
VideoCategory.setValuesForKeys(dict)
videoCategories.append(VideoCategory)
}
I tried wrapping it in an if statement, still it shows an error
What am I doing wrong?
here's the JSON feed
{
"action":"videos",
"result": {
"count":2,"videos":
[
{
"id":"427","asset_id":"279804413","asset_title":"title_1"
}
{
"id":"428","asset_id":"279804413","asset_title":"title_2"
}
]
}
|
I think I got it right. I declared it as a string object first. Is this a good approach?
let videos = json["result"] as! [String:AnyObject]
for dict in videos["videos"] as! [[String: AnyObject]] {
let VideoCategory = videoCategory()
VideoCategory.setValuesForKeys(dict)
videoCategories.append(VideoCategory)
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "swift, xcode, swift4"
}
|
Java count realm results
I have a method to do this but I am very aware that there is probably a better way to solve the problem I am having.
See below for my current code, please tell me there is something like `.length()` that I can use.
Realm realm = Realm.getDefaultInstance();
deviceImages = realm.where(UploadImage.class).equalTo("imageableId", device.id).equalTo("title", "Before").findAll();
int count = 1;
for(UploadImage image : deviceImages){
count++;
}
Log.d("Count:", String.valueOf(count));
|
As suggested by EpicPandaForce if you only need the count:
Change:
deviceImages = realm.where(UploadImage.class).equalTo("imageableId", device.id).equalTo("title", "Before").findAll();
To:
int count = realm.where(UploadImage.class).equalTo("imageableId", device.id).equalTo("title", "Before").count();
Or as suggested by Ben if you want to maintain the results variable, use:
int count = deviceImages.size();
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "java, android, realm"
}
|
kml to layer error
I tried to use the "KML to Layer" tool in ArcMap 10.2.2 but it always end up in an error showed up the the following image. I hide the directory of the kml file in the image since it does contain my name in it. Please bear with me.
I have been wasting my time for the past 2 hours trying to figure this out.
!kml error
|
I hope this useful to you please try once
<
|
stackexchange-gis
|
{
"answer_score": 0,
"question_score": 1,
"tags": "arcgis desktop, arcgis 10.2, convert, kml"
}
|
Get the list of layers in a store from geoserver
Is there a way to get the all the layers present in a store in geoserver?
My JS file contains code for each layer present in a store. So when I publish a new layer in geoserver I have to manually include the code of the new layer in JS. But what I want is to put a for loop in JS with the layer names present in a store, like
for(i<=all layers present in store)
{
var wmslayer2 = new OpenLayers.Layer.WMS("Layer2","
{'layers': '**cite:layer[i]**', 'format':'image/png', 'transparent':'true'},
{'opacity': 1.0, 'isBaseLayer': false, 'visibility': true});
}
|
The restconfig api allows you to do this:
<
You can request data be sent back in JSON as well which is handy from javascript code. The WMS caps has the same info but it is a huge xml document... so expensive to parse on the client side.
|
stackexchange-gis
|
{
"answer_score": 8,
"question_score": 3,
"tags": "openlayers 2, geoserver"
}
|
How to insert html element at certain point using JS/jQuery
updated question link - Page break at random places in browser print
My requirement is such that I need to insert an HTML element with help of 'height from top and bottom' of that position. I have tried to convey the exact requirement through the image attached. As my HTML page with dynamic height can vary as per situation.
How can this be done using jQuery?
.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -4,
"tags": "javascript, jquery, html"
}
|
Postman - Get only endpoint from a URL
Having this kind of endpoing:
<
I want to get rid of the ` and get only the `/p1/m/p2` part on the _Pre-request Script_. I know I can do it using `request.url.replace(/^.*\/\/[^\/]+/, '')`, getting the desired output `/p1/m/p2`.
Is there any other way to do it without using replace or regex? Something like `request.url.pathname` (which is not working, obviously).
The URL above is just an example, the endpoints and urls will vary.
Bear in mind that I'm using the _Pre-request Script_ on the Postman environment and some things may not work.
Thank you so much.
|
You should be able to use the URL browser API to construct a URL object.
(new URL(request.url)).pathname
If you're using the desktop version, you can use the built-in node.js API.
var URL = require('url');
URL.parse(request.url).pathname
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "javascript, postman"
}
|
How to set Concurrency::event object only if it is not in signaled state now?
In my code some concurrency work task should start to work only if special event is not in signaled state. Code sample:
tasks.run([&](){
if (event.wait(0)!=0)
{
event.set();
// work code ...
}
})
Such task may have many instances and only one should to work. But wait() and set() are different methods and code is not atomic. So, may be situation when two or more instances of task begin to work. How I can test event for signaled state and lock it only if it is non-signaled, and do it in atomic manner ?
|
Looks like you may use mutex::try_lock
the code should look like this:
tasks.run([&](){
if (event.wait(0)!=0 && mutex.try_lock()) {
event.set();
mutex.unlock();
// work code ...
}
})
Don't forget to make sure that event.set() doesn't throw an exception, otherwise extra efforts are needed to make this code exception-safe.
May be you should wrap the entire into while (true) to catch 'false-positive' cases, smth like that:
tasks.run([&](){
while(true) {
if (event.wait(0)!=0 && mutex.try_lock()) {
event.set();
mutex.unlock();
// work code ...
break;
}
}
});
Thus tasks failed to acquire the lock would return to the wait state.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "c++, concurrency"
}
|
Show that the improper integral $\int_1^\infty f(x) \ dx$ exists iff $\sum_1^\infty a_n$ converges.
The assignment:
> Let $(a_n)_{n\in\mathbb{N}}$ be a sequence of real numbers and $f: [1, \infty) \rightarrow \mathbb{R}$ be a function, defined by $f(x) = a_n$, for $x \in [n,n+1).$ Show that: $$\lim_{b\to\infty} \int_1^b f(x) \ dx $$ exists if and only if $$\sum_{n=1}^\infty a_n$$converges. Similarly show that the equivalence also holds for the absolute improper integral and that if we have convergence the equality $\int_1^\infty f(x) \ dx = \sum_1^\infty a_n$ is true.
I think the comparison tests for both series and integrals might be helpful but I don't know which inequality to use to get from the series to the integral and vice versa, since I need either two integrals or two series to use a comparison test.
Any help would be appreciated.
|
**Hint:** Note that $\displaystyle \int _1^\infty f=\sum \limits_{n=1}^\infty \left(\int _{n}^{n+1}f\right)=\sum \limits_{n=1}^\infty \left(a_n\right)$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 2,
"tags": "real analysis, integration, sequences and series, analysis, improper integrals"
}
|
insert row based on rows height
I have a range in excel that i want to insert it in ppt slides.
If the rows had a specific height (depending on cell's text value) then i would have no difficulty in inserting i.e. every six rows a new row with specific title columns (= columns' titles of row 1).
Because the rows from 2 to Nth are filled with various wrapped text, the row height is not constant. So, it might be a row with height that alone it covers a ppt slide or it might be a couple of rows that cover a slide.
I don't know if the criteria of inserting a new titled row could be a max fixed height of one or more rows, and if yes, is it possible to give me some guidance?
thanks
|
I'm skeptical about that you can set a maximum height for rows (lock rows height) as a default value.. You could lock a row height but that implies that the worksheet will be protected (by a password).
What you can do is set a default height value by "Changing Default Row Height". This will not prevent other users to increase/decrease the row height.
Another way to easy change all the row heights is to use this code (which could be triggered every time you open/close a workbook):
Sub RowHeights()
ActiveSheet.Rows("3:34").RowHeight = 15 'Set row 3 to 34 to RowHeight: 15
End Sub
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "excel, vba"
}
|
Sql syntax error about ``
I have never seen this problem. I want to make a MySQL query (insert, update, select) but MySQL gives an error.
My query:
SELECT * FROM option
and error:
> [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'option' at line 1]
but if i put ``
SELECT * FROM `option`
it's working. What can i do?
|
`option` is reserved word for MySQL you need to enclose it with backticks or avoid it by changing table name
SELECT * FROM `option`
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": -1,
"tags": "php, mysql"
}
|
Restart of Apache Tomacat
When we change any code in servlet we need to restart Apache ,but when we change any code in JSP we need not restart Apache. Even though at last JSP is turned to Servlet.I
|
You can also enable servlet reloading:
<Context reloadable="true">
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "java, tomcat"
}
|
formal definition of quadratic subfield
I am looking for the formal definition of a quadratic subfield of a field $E$. Are they subfields $K$ of $E$ such that $[E:K]=$2?
Here is the context:
I have the polynomial $f(x)= x^4-2x^2+2$. Let $E$ be its splitting field over $\mathbb{Q}$. I was able to determine that $G=\text{Gal}(E/\mathbb{Q}) \cong D_8$. I now need to find all the quadratic subfields of $E$. Let $H$ be a subgroup of $G$. By the fundamental theorem of Galois thery $[E:K]=[E:E^{H}]=|H|.$
So am I looking for the subgroups of $G=D_8$ of order $2$? And then I would apply $E^H$ to the subgroups $H$ in order to find my quadratic subfields?
I am very confused. Thanks
|
A quadratic subfield of $E$ is a subfield $K$ of $E$ that is quadratic, which means that $[K:\Bbb{Q}]=2$. Because $[E:\Bbb{Q}]=|D_8|=8$ it follows that then $[E:K]=4$, so if $K=E^H$ then $|H|=4$.
So you are looking for subgroups of $D_8$ of order $4$.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "galois theory"
}
|
changing branch to head using tortoise svn
I have a weird requirement where I need to change the current trunk into a branch and one of branches into trunk. I was trying to figure out how this can be done with tortoise svn client. I don't want to merge, but I just need to exchange the head and a branch.Any clues on this can be done?
|
It's basically a good old swap, so you need a temporary name and three operations:
svn rename
svn rename
svn rename
Same with TortoiseSVN, just use the repository browser.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "tortoisesvn"
}
|
standard garden tap size (US)
I am building a garden irrigation system which is directly connected to a tap. In Europe the garden taps are usually BSP 3/4" (< It would be great to have it compatible to the US, therefore I am wondering if you use the same system or what is a standard garden tap thread over there?
Any clues or just stating what you have in your garden would be great!
|
In the U.S. the standard is simply called Garden Hose Thread or GHT,. It's a 3/4" straight thread with a coarse thread pitch and is not compatible with the BSP which is a finer thread pitch.!enter image description here
|
stackexchange-diy
|
{
"answer_score": 0,
"question_score": 0,
"tags": "pipe, taps"
}
|
netword authentication method
If I was running a server that allowed certain user's on my LAN to access the WAN.
How can I reliably **authenticate** these users?
I could allow by checking MAC/IP adresses, but those details can be spoofed, right..
Ideally, I would like the user to:
1\. connect to the LAN via DHCP
2\. be re-directed to the server's login page when the user tries to browse
3\. have to user enter username - password
4\. if authenticated, user must be allowed to browse freely.
|
What you describe is proxy server,
e.g. Kerio control: _User-specific access management Each user in the network can be required to log in to Kerio Control before connecting to the Internet. That allows for restrictive security and access policies to be applied based on the specific user, rather than the IP address._
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "authentication"
}
|
Readonly folders in Apache installation on Windows 7
I installed Apache 2.2 on Windows 7 to folder: "C:\Program Files\Apache Software Foundation\Apache2.2". Unfortunately, all folders in "Program Files" are for "read only". When I removes this flag from properties of some folder, it come back again.
But my real problem is, that I can not to edit files in folder htdocs. When I editing them in Notepad++, I get following error: "Pleas check whether if this file is oppened in another program". So generaly, I succeed to delete files from htdocs folder, but after that I accept to get administrative control. I think, that if I will succeed to remove the "read only" flag complitely, the problem will solve.
Normally I'm loggin in with non Administrator user (but in Administrators group). With Administrator I succeed to edit the files, but also failed to remove "read only" flag.
I hope, that you will give me solution other that to work always with Administrator.
Thank you for ahead.
|
So, the solution I founded, was to install the server to "C:\Apache2.2\" instead of "Program Files" folder.
Despite that, that attribute "read only" still exists, I do succeed to change the files with non Administrator user.
|
stackexchange-serverfault
|
{
"answer_score": 0,
"question_score": 0,
"tags": "windows 7, apache 2.2"
}
|
(Antenna impedance matching) How to find the load impedance
I'm working on a project that requires impedance matching and I'm going to match a 50 Ω antenna to a RF amplifier SST12LP22. However, I'm not sure how can I get the impedance of the amplifier from the datasheet in order for me to design the matching circuit, or I will need to measure it?
Datasheet: <
|
In the figures at the end of the datasheet there are some matching networks. Use those. To get the impedances, look at the S-parameters, and you can convert those to impedances.
Based on the s-parameters in the datasheet the device is already pretty close to 50 ohm on both input and output between 2 - 3 GHz.
|
stackexchange-electronics
|
{
"answer_score": 0,
"question_score": 0,
"tags": "amplifier, rf, antenna, impedance matching"
}
|
Select distinct from Muiltiple columns into one column
I have this:
ColumnA ColumnB ColumnC
Dog Soda Book
CatIce Juice Notebook
Bird Water Pencil
Dog Water Notebook
By using this select:
select ColumnA, ColumnB, ColumnC from table
I wanna a list like this:
ColumnD
Bird
Book
Cat
Dog
Ice
Juice
Notebook
Pencil
Soda
Water
How can I do this? Thanks!
|
Use a UNION
SELECT ColumnA
FROM table
UNION
SELECT ColumnB
FROM table
UNION
SELECT columnC
FROM table
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "sql, select"
}
|
how to use python2.7 pip instead of default pip
I just installed python 2.7 and also pip to the 2.7 site package.
When I get the version with:
pip -V
It shows:
pip 1.3.1 from /usr/lib/python2.6/site-packages (python 2.6)
How do I use the 2.7 version of pip located at:
/usr/local/lib/python2.7/site-packages
|
There should be a binary called "pip2.7" installed at some location included within your $PATH variable.
You can find that out by typing
which pip2.7
This should print something like '/usr/local/bin/pip2.7' to your stdout. If it does not print anything like this, it is not installed. In that case, install it by running
$ wget
$ sudo python2.7 get-pip.py
Now, you should be all set, and
which pip2.7
should return the correct output.
|
stackexchange-stackoverflow
|
{
"answer_score": 167,
"question_score": 89,
"tags": "python, linux, django, centos, pip"
}
|
Google Chrome DNS Cache refers to the old site
I changed one of my domain DNS records recently, but when I open the URL in Firefox, it works and it is on the new server.
Also I ping the domain using CMD and it shows the new IP address too.
But in Google Chrome, it still refers to the old IP address. How can I clear and disable dns cache in Chrome?
I used `chrome://net-internals/#dns` and cleared cache, but it still refers to the old site
|
* Create a link to Chrome on your Desktop
* Right click - then Properties
* In Shortcut Tab - append --disable-async-dns to Target
* "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" \--disable-async-dns
* Start Chrome from that link
* go to chrome://net-internals/#dns
* Async DNS should be disabled
* Clear Host resolver cache
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "google chrome, google chrome extension, browser"
}
|
How to left-justify lines of code to the left edge of the window in eclipse
I have alot of code that has white space to the left of the lines of code in my eclipse project. I would like to select pieces of this code and remove the extra white spacing so each line lines up with the left edge of the window.
|
You can select the code you wish, and press SHIFT+TAB until the code lines up to the edge of the screen. You could also go to:
Window->Preferences->general->Editors->Text Editors
and when you're there, specify the tab width under:
Displayed Tab Width.
You can also customize Eclipses' formatter:
Go to:
Window->Preferences->Java->Code Style->Formatter
Select the formatter and press Edit. Edit it to your desire.
Then select the text you wish to format and press Ctrl+Shift+F
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "eclipse, format, lines of code"
}
|
How to filter rows between two dates from CSV file using python and redirect to another file?
I am newbie to Python. I have a CSV file with below data as an example. I wanted to skip rows between specific date range(2018-08-01 to 2018-08-28) and redirect output to a separate CSV file. Please note, a blank space in the header "LAST USE".
NUMBER,MAIL,COMMENT,COUNT,LAST USE,PERCENTAGE,TEXTN
343,[email protected],"My comment","21577",2018-08-06,80.436%,
222,[email protected],"My comment","31181",2018-07-20,11.858%,
103,[email protected],"My comment",540,2018-06-14,2.013%,
341,[email protected],"My comment",0,N/A,0.000%,
Any idea would be greatly appreciated.
|
With Pandas, this is straightforward:
import pandas as pd
# read file
df = pd.read_csv('file.csv')
# convert to datetime
df['LAST USE'] = pd.to_datetime(df['LAST USE'])
# calculate mask
mask = df['LAST USE'].between('2018-08-01', '2018-08-28')
# output masked dataframes
df[~mask].to_csv('out1.csv', index=False)
df[mask].to_csv('out2.csv', index=False)
You can also combine Boolean arrays to construct `mask`. For example:
m1 = df['LAST USE'] >= (pd.to_datetime('now') - pd.DateOffset(days=30))
m2 = df['LAST USE'] <= pd.to_datetime('now')
mask = m1 & m2
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "python, python 3.x, pandas, csv, datetime"
}
|
Proverb for when one person sees something, but someone else takes it
Is there a proverb that fits the following situation:
**John and Anderson (while walking):**
> **John:** [sees a $100 bill lying in the road, and shouts] Yahoo! $100!
>
> **Anderson** : [takes the money and puts it into his pocket]
**Reflection:** John exclaimed when he saw the money in the road, but he didn't try to take it. Anderson was smarter, as, when he saw John exclaiming, he took the money and put it into his pocket. **Consequently** , John now repents his foolish excitement.
My question is, is there a proverb for such situations?
* * *
**EDIT:** When I asked my friend, he suggested the following saying:
> "Some feel the rain others just get wet."
|
you snooze, you lose
> informal
> if you do not pay attention and do something quickly, someone else will do it instead of you:
> Cambridge Dictionary
>
> If you wait too long to do something, that opportunity might become unavailable.
> Farlex Dictionary of Idioms
>
**John:** Yahoo! $100!
_(Anderson takes the money)_
**John:** Hey, I saw it first!
**Anderson:** You snooze, you lose.
|
stackexchange-english
|
{
"answer_score": 101,
"question_score": 28,
"tags": "proverb requests"
}
|
Interpreting rsync command
as I am very new to rsync, I came across this code somewhere in the server and decided to try it out. It was a dry-run but there are a few parts within this line that I do not understand.
Do correct me if my interpretation below are wrong :x
find -name "*.jpg" | xargs -I icon sudo rsync -azuvhE -n icon tango:/jobs/prime/Item/icon
Firstly, I understand the first part of `find -name "*.jpg"` and it is looking for any .jpg files within the directory stated.
But I do not understand the meaning of `|` and `xargs -I icon`.. For the latter part, I presume it is like defining `icon` as a variable?
Then as for the last part, as I am crossing referencing between 2 servers (alphis which I am currently on) and tango, I presume it is referencing against the tango/jobs/prime/Item/icon?
|
find -name "*.jpg" | \ # find jpeg files (assume no white space)
xargs -I icon \ # get file names from find, call them icon
sudo rsync -azuvhE -n icon # copy each file to ....
tango:/jobs/prime/Item/icon # this folder on tango
This should be an equivalent command:
sudo find -name "*.jpg" -exec rsync -azuvhE -n {} tango:/jobs/prime/Item/ \;
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "linux, terminal, rsync"
}
|
Extract line of interest from a wmic.exe call
On powershell i'm executing the following command:
$objWMI = wmic product where "name like 'app' " get PackageCache
echo $objWMI
Output:
PackageCache
C:\Windows\Installer\file.msi
I need to convert this output only to show this dir.
|
The variable in your example is converted to an array once the command is successfully run, with the path always being displayed on the 3rd line, so you can simply call $objWMI[2] to give you the directory only (we use the number 2 because if we wanted the first line we would use [0]).
All together it could be something simple like below.
$objWMI = wmic product where "name like 'app' " get PackageCache
$directory=$objWMI[2]
echo $directory
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "windows, powershell, wmi, wmic"
}
|
Change string in a date format to another format
I have a string like this (YYYYMMDD):
> 20120225
And I want to have a string like this (MM/DD/YYYY):
> 02/25/2012
What's a good way of doing this in Ruby? I have thought about converting the first string to a Date, and then change the format. Or just treating the string and getting the parts I want and build the new string.
|
Parsing it then formatting it is the best solution:
Date.parse("20120225").strftime("%m/%d/%Y") #=> "02/25/2012"
|
stackexchange-stackoverflow
|
{
"answer_score": 19,
"question_score": 5,
"tags": "ruby, date"
}
|
Redis search for matching keys that equal a value
OK, in REDIS if i simply want to set up keys = a channel name and value = either paid or free...
so eventually ill have a list 100s, 1000s, etc etc of keys and values where the key's value will either be paid or free.
channelName, paid or free
so,then i want to come and search and ask the db give me all the channels whose value = free
whats the best way/efficent way to set this up?
i basically want to query and return a list of all the keys that equal a certain value in a list or dict...
|
You can use sorted sets, and the member value to be 0 (free) or 1 (paid).
In a single key, you can store the members of the sorted set, and each member is given a decimal value. Abstracting the `free` and `paid` to be `0` and `1` values, you can add members (i.e. in your case, channels) to the set, and later query those.
127.0.0.1:6379> ZADD mychannels 0 1stchannel 1 2ndchannel 1 3rdchannel 0 4thchannel
(integer) 4
127.0.0.1:6379> ZRANGEBYSCORE mychannels 0 0 /* Querying free channels */
1) "1stchannel"
2) "4thchannel"
127.0.0.1:6379> ZRANGEBYSCORE mychannels 1 1 /* Querying paid channels */
1) "2ndchannel"
2) "3rdchannel"
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "caching, redis, key value"
}
|
how to see the optimized code in c
I can examine the optimization using profiler, size of the executable file and time to take for the execution.
I can get the result of the optimization. But I have these questions,
* How to get the optimized C code.
* Which algorithm or method used by C to optimize a code.
Thanks in advance.
|
you can get an idea of optimization using the option `-fdump-tree-optimized` with gcc . and you'll get an optimised file. you cannot run the code but using that you can get an idea of optimization . dont forget to include `-O2` or `-O3` or some other level.
|
stackexchange-stackoverflow
|
{
"answer_score": 14,
"question_score": 10,
"tags": "c, optimization"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.