INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Как исправить TAB-отступ в Pycharm?
При нажатии TAB в PyCharm ставится полу-отступ(2 пробела), а раньше был полный отступ(4 пробела). Подскажите, пожалуйста, как это исправить?
|
Вероятно ваш вопрос уже задали разработчику
> 1. "Settings | Editor | Code Style" \-- try disabling "Detect and use existing file indents for editing"
>
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "pycharm"
}
|
UTF-8 in Java's String.GetBytes(Charset)
I read some documents about String.getBytes(Charset) method in Java.
It is used to convert a String to a byte array (byte type can get value -2^7 to 2^7-1).
As I knew, per character in UTF-8 charset can be used with 1-4 byte(s). What will happen if the code of a character in UTF-8 charset is larger than 2^7-1?
I tried with
> String s="Hélô"
then I got such 'Hélô' with:
> String sr=new String(s.getBytes("UTF-8"),Charset.forName("UTF-8"));
I want it to return orginal value 'Hélô'.
Can anybody describe this? Thanks. (Sorry for my English)
|
As Jon already said, the reason is that you use different encodings. In UTF-8 encoding the characters `é` and `ô` are encoded as two bytes each.
ISO-8859-1: H é l ô
bytes: 48 E9 6C F4
UTF-8 : H é l ô
bytes: 48 C3A9 6C C3B4
Your example fo the wrong string result is in bytes as follow
UTF-8 bytes interpreted as ISO-8859-1
H à © l à ´
48 C3 A9 6C C3 B4
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 4,
"tags": "java, encoding, utf 8, character encoding"
}
|
Is it wise to dissolve priming sugar or gelatin in water the day before adding it to the beer?
One of the biggest time consumers I have on bottling day is cooling down the sugar to room temperature. So I have been thinking about sanitizing a small container the day before bottling, dissolve the sugar there, and seal the container. The solution should cool overnight and be ready to add to the bottling bucket the next day. Is this wise?
And on that note, I was thinking about doing the same for the gelatin I use to clear my beer, so once again, is this wise?
|
No need to cool it down. I don't. Beer turns out good anyway. Yeast doesn't die because it's such a small volume of hot liquid in a much larger volume of beer.
|
stackexchange-homebrew
|
{
"answer_score": 2,
"question_score": 1,
"tags": "bottling, carbonation, priming, priming sugar, gelatin"
}
|
Arithmetic overflow error converting expression to data type datetime (Int64 to datetime)
Trying
`SELECT convert(datetime, 20120825142616 , 120) AS time`
Running into exception
_Arithmetic overflow error converting expression to data type datetime._
The value '20120825142616 ' **is of type 'Int64** ' passed as parameter to a .Net SqlCommand object.
Any help is appreciated
|
If you place your data in single quote then you will not get arithmetic flow error
SELECT convert(datetime, '20120825142616' , 120) AS [time]
but you will got an error:
`Conversion failed when converting date and/or time from character string.`
I thought the format is not right. If I only place date it works. like
SELECT convert(datetime, '20120825' , 120) AS [time]
-- output
2012-08-25 00:00:00.000
and If I place date in this format it works
SELECT convert(datetime, '2012-08-25 14:26:16' , 120) AS [time]
-- output
2012-08-25 14:26:16.000
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "sql server, sql server 2008 r2"
}
|
Linux SVN recover files
A recent update over unversioned directories removed a bunch of files. Is there a way I can manually recover these lost files?
P.S. I cannot recover them from subversion, as the files I am looking for were never committed to SVN control. I have looked in the linux trash folder, which only contains files which have been manually deleted.
edit: Actually, the files were lost through an accidental svn rm operation. Unfortunately I cannot use revert as the files I am trying to recover were newly created and not under version control yet. Any ideas?
|
If files were lost during a `svn update` operation, there's not a lot you can do. I would suggest looking for hidden backup files that your editor may have created (in the directory where the file originally was or in the editor's temporary directory).
If you remember the name of one of the files, you can try using `find` to see if there's a backup copy of it somewhere on the disk.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "linux, svn, data recovery"
}
|
Git repository clean up
So I have this huge bitbucket repository with so many branches, each with tens of commits some of which are really small. Now that the entire thing works perfectly, I want a clean repo with only the final commits and required branches. How do I achieve a 'repository clean-up' where I can remove the unnecessary branches and the commits and have a final clean repo?
Please help me out.
|
From the solution here:
# Make sure remotes are up to date (with stale remotes purged):
git fetch -p
# Initial no-op run --- do the branches to delete look correct?
# Be careful to omit 'master' from the output.
git branch --remote --merged origin/master | grep -v 'master' | cut -b 10- | xargs
# Do the bulk delete!!! (can take a long time...)
git branch --remote --merged origin/master | grep -v 'master' | cut -b 10- | xargs git push --delete origin
This will delete branches that have been merged into a 'master' branch. You can modify to reflect whatever organization your repo is using.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "git, repository, bitbucket"
}
|
Can I deduct mortgage interest in Kansas with a standard deduction?
I'm working on filling out my U.S. income tax forms, and am confused by the mortgage interest credit. It seems more complicated than I remember it being last year (perhaps because it is? Or maybe my memory is just failing).
I see that I can fill out Form 8396 to deduct mortgage interest with a standard deduction, but this requires `a qualified Mortgage Credit Certificate (MCC) [issued] by a state or local governmental unit or agency under a qualified mortgage credit certificate program.`
My state of Kansas appears not to have such a program. Does this mean my only option for deducting mortgage interest is to do an itemized deduction?
|
MCC is not a deduction, its a credit (a kind of "first home owner" credit). If you had it you would have noticed, you need to proactively get this certificate from your state government. If you're talking about the regular mortgage interest (form 1098), then you cannot deduct this if you're not itemizing.
|
stackexchange-money
|
{
"answer_score": 5,
"question_score": 3,
"tags": "united states, income tax, tax deduction"
}
|
How to execute code in `if __name__ == "__main__"` from another python file
In my python file I have a function that takes some parameters and in the same file I have an `if __name__ == "__main__"` clause that runs this function with a particular set of parameters (for a user to showcase what it does). Like so,
def foo(arg1, arg2):
pass
if __name__ == "__main__":
arg1 = 1
arg2 = 2
foo(arg1, arg2)
Furthermore, I also have another file with tests which is used by pytest. I'd like to have one of the test run exactly what is written inside the above mentioned if clause, i.e. execute
arg1 = 1
arg2 = 2
foo(arg1, arg2)
Is this possible without copying the code to the file containing the tests?
|
Well, im no expert at that but how about redicrecting your `if __name__ == "__main__":` to another function and call that function from your other file?
file1:
def main_file1:
arg1 = 1
arg2 = 2
foo(arg1, arg2)
if __name__ == "__main__":
main_file1()
* * *
file2:
from file1 import *
def somefunc():
main_file1()
However, im not sure why you would want to do that anyways. Usually you only have 1 main function in your whole project to get things rolling and call other functions from there.
And ultimately this kind of fails the purpose of a main function of a file
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "python, namespaces, pytest, program entry point"
}
|
Regex to match as many times as possible, but within constraints
Here's my string:
`"ab1 ab-1 f-12 g-12 ffff-123 456"`
I'd like to pick out things that have:
* Up to 2 letters
* An optional hyphen
* Up to 2 numbers
* **Valid** : ab1, ab-1, f-12, g-12
* **Not Valid** : ffff-123, 456
So I created the regex:
`[\w{1,2}]-?\d{1,2}`
But it returns too many things:
>>> re.findall('[\w{1,2}]-?\d{1,2}', "ab1 ab-1 f-12 g-12 ffff-123 456")
['b1', 'b-1', 'f-12', 'g-12', 'f-12', '456']
The problems:
1. `[\w{1,2}]` needs to be isolated from `-?`.....I think they are being stuck together
2. `[\w{1,2}]` is getting the smallest possible match e.g. `b-1` from `ab-1`, when it should get the largest possible match up to 2 characters, `ab-1`
Any ideas?
|
The RE should be:
[a-z]{1,2}-?\d{1,2}
The expression `[\w{1,2}]` means any single character that's either a word character, `{`, `1`, `,`, `2`, or `}`.
Note that in your string this will match `ff-12`, since this part of `ffff-123` matches the expression. If you don't want this to happen you need to add `\b` around the expression, so that it only matches at word boundaries.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "regex, regex greedy"
}
|
How to change pivot table data source in Excel?
I want to change it from one database to another.
There don't appear to be any options to do this on the pivot table context menu
|
right click on the pivot table in excel choose wizard click 'back' click 'get data...' in the query window File - Table Definition
then you can create a new or choose a different connection
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 24,
"tags": "excel, business intelligence, xls, pivot table"
}
|
How to display an array data in a single line for CDetailView
The code:
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'tag', // problem here
),
));
If there is an array in the attribute "tag" in this model ($model->tag), how can I display all items in the array?
The attribute 'tag' has an array like this:
$model->tag = array('A', 'B', 'C', 'D');
I want this result:
Tag: A, B, C, D
|
Try this:
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
array(
'name'=>'tag',
'type'=>'text',
'value'=>implode(", " , $model->tag)
)// 'tag',
),
));
Read more about CDetailView attributes, and php's implode.
Hope this helps.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "arrays, yii"
}
|
Does get request need content type and accept header?
I am making web request and method is get.Does I need to mention content-Type and accept for get method?or it just require for post method
string strURL = "web address";
Uri uri = new Uri(strURL);
HttpWebRequest webRequest = System.Net.WebRequest.Create(uri) as HttpWebRequest;
webRequest.Method = WebRequestMethods.Http.Get
webRequest.ContentType = "application/json";
webRequest.Accept = "application/json";
|
**content-type** : It is not required in the GET request as you are not sending any content in the request body.
> content-type indicates the media type of the entity-body sent to the recipient.
**Accept** : It depends on your requirement. If you want to restrict the media type in your response then you can use it otherwise leave it.
> The Accept request-header field can be used to specify certain media types which are acceptable for the response.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 0,
"tags": "asp.net"
}
|
Upload Assets Manually
Is it possible to upload assets into the folders listed in the asset section on the server manually/directly? And then "sync up" the system so the ui sees these?
Used to be able to do this in expression engine via a sync button and i don't see how to do that here, but perhaps im missing the trick?
Thanks
|
Yes, after uploading via FTP, you will need to tell Craft to go and index the new assets: **Settings** > **Tools** > **Update Asset Indexes**
|
stackexchange-craftcms
|
{
"answer_score": 2,
"question_score": 1,
"tags": "assets"
}
|
The Microsoft.Office.Interop.Excel is not working when the system has installed Kingsoft sheets while it works when has MS excel or WPS
Microsoft.Office.Interop.Excel.Application ExcelApplication = new Microsoft.Office.Interop.Excel.Application();
gives error :
> {"Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070002 The system cannot find the file specified. (Exception from HRESULT: 0x80070002).":null}
|
Excel Interop is provided by Microsoft Office, Kingsheet does not provide it. Upshoot: If possible, use some abstraction of excel worksheets whih works without Interop (which has other drawbacks, too), e.g. EPPLus.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "c#, excel"
}
|
Galois group of $x^6-9$
$f = x^6-9 = (x^3-3)(x^3+3)$ Let $L_f$ be splitting field therefore $L_f = \mathbb{Q}[\sqrt[3]{3},e^{\frac{2\pi i}{3}}]$, $[L_f:\mathbb{Q}] = 9$. Also $Gal\space x^3±3/\mathbb{Q} = S_3$ and $Gal\space f/\mathbb{Q}$-orbits is roots of $x^3-3$ and $x^3+3$ therefore, i think, that $G = Gal\space f/\mathbb{Q} = S^3\times S^3$. But $|G| = 36 \ne [L_f:\mathbb{Q}]$. What's wrong?
|
A few issues:
Firstly $e^{2\pi i/3}$ is a root of the polynomial $X^2+X+1$, so the degree of $L_f$ over $\mathbb Q$ will be $6$.
Secondly, as quid has mentioned, both $X^3\pm3$ have the same splitting fields. Hence, the splitting field of $f$ is the same as the splitting field of either of those polynomials, so you can just find the Galois group of one of them.
With these two facts you should be able to find that the group is $S_3$.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 2,
"tags": "field theory, galois theory"
}
|
Remove trailing string
In a bash script I have the following command which removes the trailing `\r\n` from the last line of a file.
# Copy the new last line but remove trailing \r\n
tail -1 $TMPOUT | perl -p -i -e 's/\r\n$//' >>$TMPOUT.1
It's currently using Perl to trim the `\r\n` off, but the target system I'll need to run this on won't have Perl or any other scripts (uClinux/Busybox embedded device).
How can I achieve the same in 'pure' bash?
|
Use `tr` command then,
tail -1 $TMPOUT|tr -d '\r\n'
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "linux, bash, terminal, command"
}
|
how we plan for Windows updates in SharePoint 2013
we have plan to install Windows updates in production SharePoint farm 2013, which services and functionalities these updates will impact mostly and how we plan for Windows updates in SharePoint 2013
|
You should check with corresponding KB articles for the update, what fix include in it and which module it will touch. i.e check this KB
Now for SharePoint, we never enabled the automatic updates for windows but we plan it. Typically, we do the following things
* Stop the SharePoint Timer and Admin services.
* Unshceudle our Search Crawl
* Stop the Profile Sync.
* Stop the IIS
Now apply the updates and then start the service and test it. Yes we perform this in our qa farm 1st.
|
stackexchange-sharepoint
|
{
"answer_score": 3,
"question_score": 3,
"tags": "2013, windows server 2012 r2"
}
|
Which will Boone use better, a Sniper Rifle or an Anti Material Rifle?
How effective is boone at using an anti Material rifle, compared to using a sniper rifle?
|
Boone needs armor that grants +1 to STR, such as power armor, to take advantage of the Anti Material Rifle, as the AMR has a STR req. of 8, and Boone starts out at a default of 7, so he will suffer a disadvantage.
If you can circumvent that obstacle and get power armor or armor that gives him STR, it's clearly better to take the Anti Material Rifle over the Sniper Rifle.
Of course though, remember your companions will require ammo to use weapons you give them, so if you give them an AMR, make sure to provide plenty of .50 ammo.
|
stackexchange-gaming
|
{
"answer_score": 2,
"question_score": 2,
"tags": "fallout new vegas"
}
|
When passing data between Activities with Intent Extra I keep getting the same value
In my game I am trying to pass the score from the PlayGame activity to the Scoreboard activity using an Intent Extra. On finishing the game, I go to the scoreboard in this way:
Intent intentScoreboard = new Intent(getApplicationContext(), Scoreboard.class);
intentScoreboard.putExtra("com.example.game.SCORE", score_counter);
startActivity(intentScoreboard);
and then in the Scoreboard class I retrieve it in the onResume() method like this:
Bundle b = getIntent().getExtras();
int score = b.getInt("com.example.game.SCORE");
This works fine the first time, but if I then play another game and on finishing return to the scoreboard, I still get the score from the first game.
What am I missing?
|
you are missing calling setIntent()
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "android, android intent"
}
|
Understanding electronic loads
I found an article about electronic loads and tried to simulate the circuit in LTSpice. However it didn't work.
Here is the link to the full article, where I tried to recreate the following figure:
 instead of the lone operation amplifier.
|
There's nothing wrong with the conceptual circuit. It's a simple 1A current sink. If you simulate this with practically any op-amp and a MOSFET such as a 2N7000 it will work fine at relatively low currents (from uA up to say 100mA)
In actual practice at the 1A level it **might** not be stable without compensation for the MOSFET gate capacitance loading, but that is highly dependent on the op-amp characteristics and on the MOSFET characteristics (in particular Cgs). Here is an op-amp designed to be stable with very heavy capacitive loads, but it's not hard to accomplish with ordinary op-amps by closing the loop for higher frequencies separately from the gate DC. The gate then charges through an isolation resistor but that's not really PI control, as Tim says.
!schematic
simulate this circuit - Schematic created using CircuitLab
|
stackexchange-electronics
|
{
"answer_score": 0,
"question_score": 0,
"tags": "operational amplifier"
}
|
Regular expression to select all characters except letters or digits
I have this regular expression:
^[a-zA-Z0-9]
I am trying to select any characters except digits or letters, but when I test this, only the first character is matched.
When I use
[a-zA-Z0-9]
the matches are correctly digits and letters. I need to negate it, but the `^` does not work.
|
Below is a quick summary of regexps and how you can group together a query set using the commands below. In your case place the `^` inside the `[a-zA-Z0-9]` to achieve the desired result.
. Single character match except newline
"." Anything in quotations marks literally
A* Zero or more occurrences of A
A+ One or more occurrences of A
A? Zero or one occurrence of A
A/B Match A only if followed by B
() series of regexps grouped together
[] Match any character in brackets
[^] Do not match any character in brackets
[-] Define range of characters to match
^ Match beginning of new line
$ Match end of a line
{} Cardinality of pattern match set
\ Escapes meta-characters
| Disjunctive matches, or operation match
|
stackexchange-stackoverflow
|
{
"answer_score": 13,
"question_score": 3,
"tags": "regex"
}
|
feedback on re-design scene from [Rec]
Hello. I'm a wannabe sound designer. All times i'm trying to learn as much as i can by reading, watching, listening and trying. Before I start working with young filmmakers in no-budget productions, I want to build my portfolio by re-designing the sound of my favourite movies. So here is one of those. I recorded everything by myself with a Zoom H4 and a Rode NT1 (except guns). The most difficult part was ADR as I havent got professional actors to record the dialogues. I would appreciate any feedback.
so here it is--- rec redesign
thanks. Maciej.
|
Very nice!
Can i suggest just the bullet casings falling after the shots? And maybe putting some bullhorn shouting outside, as well as a bit more reverb on the sirens, and in the end muffling the girl's sighs just a little and a bit of verb, bit since her back is turned to the camera (unless the idea is that she's wearing a lav)
nice work!
|
stackexchange-sound
|
{
"answer_score": 0,
"question_score": 1,
"tags": "feedback, horror"
}
|
Google Sheets - Autofill cells using conditional formatting
I want cell I2 to autofill the text "completed" only if cell M2 contains the text "t4" or "tfour"
<
|
To set values, use a formula `=IF(OR(A11="t4", A11="tfour"), "completed", "incomplete")`
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "google sheets, formatting, conditional statements, rules"
}
|
What is the purpose of the large resistance from gate to drainin this MOSFET circuit?
In the circuit below, what is the purpose of the very large resistance (\$5 M \Omega\$) between the MOSFET gate and drain terminals?
 {
getData(); // init
setInterval(() => {
getData();
}, 10000 * 60 * 60); // every hour
}
updateEveryHour();
So currently this does work when I'm running the app local, but when I build it to Heroku and, for example, wait few hours then nothing has happened. (nothing has been added to my database). Unless I refresh my page on Heroku.
|
For this type of use case, I'd suggest you look up a scheduler like Heroku Scheduler or similar. Scheduled jobs like this shouldn't be called from the frontend, as you saw it's unrealistic to have the application running for an extended period of time.
<
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "node.js, heroku"
}
|
What to do when there is no explanation about downvotes?
I just _answered_ a question with this answer.
First, it got accepted and was ok. Then however, quickly after that I got multiple downvotes, 1 at the beginning (probably because I was a little sloppy with the wording). I then edited it to improve it and asked with a comment under _why?_ At which point I noticed I have accumulated 2 more, but still without any sort of feedback.
Now being totally puzzled, what should my next step be?
EDIT:
At the end as a result I have:
+(-1) right after being accepted
+(-2) since asked why in the comments
+( ~~-1~~ -3) since asked here
The timing of the above values may vary. Bet I wouldn't have a singe one if not accepted by OP, or maybe just one. SO is _strange place_ to say the least.
|
Right there on the downvote arrow it says for answers: "This answer is not useful". Thats all explaination that is given, and all that is needed.
Comments asking for downvotes to be explained are usually seen unfavorably by the community and lead to further downvotes.
Considering the answer is properly formatted, the reason that I think lead to it is that you're advocating sloppy coding. In essence you're glossing over the fact that OP is invoking some undefined behavior. Since OP is clearly a beginner, you shouldn't give them an easy way out to hold on to their bad habits in coding.
But asides from the technical merits of your answer, if you don't want to change it a bunch, you should just leave it alone. 4 downvotes aren't a big deal, and fratting about it too much is likely counterproductive.
|
stackexchange-meta_stackoverflow
|
{
"answer_score": 10,
"question_score": -8,
"tags": "discussion, answers, downvotes, downvote reason"
}
|
How do you add a forms controls to a cell in a Excel spreadsheet for each row
How do i add a forms control in excel to a cell, I know I can draw it, but I need to make it a member of each row and it's values attached to that cell/row.
|
There are several ways to do this but the easiest, assuming Excel 2007 is:
Set cb = MyWorkSheet.CheckBoxes.Add(left, top, width, height)
cb.LinkedCell = "$A$1"
cb.Display3DShading = True
You have to experiment a little with placement as I don't think there is a direct way to align the control with a particular cell. Another way would be to use the `Shapes` collection of the worksheet:
Set shape = MyWorkSheet.Shapes.AddFormControl(xlCheckBox, l, t, w, h)
However, keep in mind that the above method returns a `Shape` object and not a `CheckBox` object so you can't manipulate its properties directly. There are similar methods to the above like using the `OLEObjects` collection but that's just adding more pain.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 3,
"tags": "c#, excel"
}
|
Changing text value of 1st item in checklistbox
i have a asp.checklistbox.
I have 1 item in it.
I want to change the text value of this entry using jquery/javascript but after spending sometime not sure if it can be done.
The code:
<asp:CheckBoxList ID="chkEmailClients" runat="server" ClientIDMode="Static" RepeatLayout="Table">
<asp:ListItem></asp:ListItem>
</asp:CheckBoxList>
jQuery(function ($) {
$("#btnChangeCaption").click(function () {
$("#chkEmailClients").items[0].val('different text');
}
|
Please try with below code:
$('#<%= btnChange.ClientID %>').click(function () {
$('#<%= chkEmailClients.ClientID %>').find('input[type="checkbox"]:eq(0)').closest('td').find('label').html('hello')
return false;
});
Actually `<asp:CheckBoxList />` generates table with caption in `<label>`, so you need to change the text/html of `<label>`. You can have look at your generated HTML code. I did the same to solve your query.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -4,
"tags": "javascript, jquery"
}
|
fhem interface not started
I followed this tutorial to install fhem on my **Raspberry Pi** :
But the fhem interface is not started in my web navigator when I put:
"192.168.1.5" is my raspberry pi address
I checked processes in Linux, perl is listening on the port 8083:
tcp 0 0 0.0.0.0:8083 0.0.0.0:* LISTEN 2207/perl
PS: KURA eclipse project is installed on my **Raspberry Pi**.
What is wrong? what I have missed?
Thanks a lot for your help!
|
If you have installed Kura, it is acting as a firewall so you need to use the Kura Web UI to open tcp port 8083, which is filtered by default.
!Kura Firewall
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "linux, perl, raspberry pi, port"
}
|
nginx issue with following all redirects
I have two redirects in a file at /etc/nginx/redirect.conf:
rewrite /this-link redirect;
rewrite /this-link-too redirect;
Attempting to go to < or < both go to <
Is there a way to force exact matching?
Example config below:
server {
listen 80;
server_name www.example.com;
index index.html;
error_page 404
location / {
try_files $uri @redirect;
}
location @redirect {
include /etc/nginx/redirect.conf;
}
|
The `rewrite` directive accepts a regular expression, so `/this-link-too` matches `/this-link`, and thus your first rewrite always gets used. `Rewrite` should be avoided unless you actually need to match a regular expression or do substitutions.
You should consider using exact `location` matches with `return` instead.
For example:
location = /this-link {
return 302
}
|
stackexchange-serverfault
|
{
"answer_score": 2,
"question_score": 2,
"tags": "nginx, redirect"
}
|
How to protect my private key from an unexpected new owner of the address that already belongs to me?
I understand that the situation I am describing is unlikely (because we have 1.46 Quindecillion possible Bitcoin addresses), but let's imagine that someone generated the same address as mine.
**Is there any protection against a duplication of private and public keys if someone's new address matches the existing address where bitcoins are already stored?**
|
The mitigation _is_ the absolutely massive address space. Other than that, there is no way to 'protect' or otherwise 'claim' a keypair/address as yours and yours alone. If someone (by some unfathomable coincidence) manages to generate the same address that your wallet did, then you will both be able to spend any funds locked to that address.
Thankfully, the chances of this happening are **super duper incredibly small**. You would expend far more energy (money) looking for an already-used address than you could ever be expected to make by taking the bitcoin you are hunting for.
Perhaps worth mentioning: the above holds true iff the private keys for the address in question are generated in a suitably random (high entropy) way. If you use a poor source of entropy, then it become much, much easier for someone to brute force search for your keys.
|
stackexchange-bitcoin
|
{
"answer_score": 4,
"question_score": 2,
"tags": "wallet, address, private key, key collision"
}
|
How to resolve missing SELECT keyword error when trying to insert select
It doesn't matter how I write this statement, I always get the ORA-00928 missing select keyword error.
I'm trying to insert values from a query into a table. The result of the query has the same amount of columns as the table where it needs to be inserted to. I have tried making it as an CTE. Even a select-query from an existing table returns the same error.
Code is like:
WITH FIRST_CTE(FrstCol1,FrstCol2)
AS
(
SELECT 't', '1' from dual UNION ALL
SELECT 's', '2' from dual
)
,
SECOND_CTE(SndCol1,SndCol2)
AS
(
SELECT 't', '3' from dual UNION ALL
SELECT 'z', '4' from dual
)
INSERT INTO TABLE_1
SELECT *
from
(SELECT * FROM FIRST_CTE) A
JOIN
(SELECT * FROM SECOND_CTE) B
ON A.FrstCol1 = B.SndCol1
;
Any suggestions?
|
No problem occurs if you put `INSERT` part to the beginning, since `SELECT` statement starts by `WITH` clause ( for this case )
INSERT INTO TABLE_1
WITH FIRST_CTE(FrstCol1,FrstCol2)
AS
(
SELECT 't', '1' from dual UNION ALL
SELECT 's', '2' from dual
)
,
SECOND_CTE(SndCol1,SndCol2)
AS
(
SELECT 't', '3' from dual UNION ALL
SELECT 'z', '4' from dual
)
SELECT *
from
(SELECT * FROM FIRST_CTE) A
JOIN
(SELECT * FROM SECOND_CTE) B
ON A.FrstCol1 = B.SndCol1;
provided that `TABLE_1` is such a table that is created as
create table TABLE_1(FrstCol1 varchar2(100),FrstCol2 varchar2(100),
SndCol1 varchar2(100), SndCol2 varchar2(100))
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "sql, oracle, sql insert"
}
|
IIS7 - what does MaxProcesses do?
Does anyone know what this value is for?
If it is set to 1, then it seems that you can only have one request going to the server at once. For example, we have a classic ASP file that loads fine, but also has images in it (which come from the same script on the server). The page will load, but the images will never load in... the page just spins forever.
Upping the MaxProcesses value in IIS7 fixes this, but then each time a new process is spawned we then run into problems with session values not persisting as well as long page loads that we don't get when MaxProcesses is set to 1.
There is probably some other setting I don't know about that works in tandem with this.
See this question for the answer (server side debugging was on).
|
Gets or sets the number of worker processes associated with the application pool. Default = 1; A value other than 1 indicates a Web garden. In this scenario, if you want to preserve your session you need to choose an out of proc method for sessions (for example using SQL Server).
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "iis 7"
}
|
Formatting error: Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '.'
I'm trying to get each variable to print out with two decimal places but I do not know what I'm doing wrong. Any help?
System.out.printf("%.2",custNum + "\t" + beginBal + " \t " + financeCharge + "\t\t" +
purchases + " \t " + payments + "\t\t" + endBal);
|
Your format `String` should be `%.2f` and one for each term. Something like,
System.out.printf("%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f%n", custNum, beginBal,
financeCharge, purchases, payments, endBal);
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "java, formatting"
}
|
Where can I find the 'of the Wild' set?
I've completed all of the shrines and I was informed that my gift from the sages is in a temple somewhere (can't really remember where exactly).
So, when you have done all of the shrines, where will the 'of the Wild' armor set be?
|
According to this article, you will find the set in the Forgotten Temple.
> All pieces of the armor set can be found in The Forgotten Temple.
From the page about the quest which rewards this armor set:
> The reward which is an “of the Wild” armor set lies waiting at the foot of the Goddess Statue placed behind the local shrine.
For directions to the Forgotten Temple, here's where the wikia says it is:
> It is a large building found at the northernmost end of Tanagar Canyon.
|
stackexchange-gaming
|
{
"answer_score": 9,
"question_score": 7,
"tags": "zelda breath of the wild"
}
|
Notice: Undefined variable: startdate
I am using open cart v 1.5.6.4. I am getting following error after using magic zoom module.
> Notice: Undefined variable: startdate in C:\Users\kailash.SYSTEM1\workspace\designhut2\vqmod\vqcache\vq2-catalog_view_theme_METROPOLITEN_template_product_product.tpl on line 28
|
You have two possibilities :
* Go in the source and initialize the undefined variable (like : `$startdate = '';`)
* Update your .htaccess to remove the display of the notices (or display_error off)
|
stackexchange-stackoverflow
|
{
"answer_score": -1,
"question_score": 1,
"tags": "opencart"
}
|
How can I modify the md-input-container in angularJS
I am working on designing a form with angularJS. I am facing this issue from a long time. Whenever I use a text field (md-input-container) and drop down (md-select), this causes a height difference.
When I inspect the code, I find out that the md-input-container has an extra md-error div tag.
, default camera and lamps.
!viewport
And when I render, it looks like this:
!render
Correct me if I'm wrong, but shouldn't I see the different boxes? Is it normal that the shadows are so dark that they hide all edges?
|
The problem is that you don't have enough lamps at the right positions (as said in the comments by someonewithpc and PGmath). You can fix this in various ways:
1. Just keep adding/duplicating more point lamps, and spread them around.
2. Keep only one lamp, and set its mode to Sun.
3. Have two lamps, one of them a Sun lamp (like in #2), and the other one a Hemi light. Then set the energy of the hemi light to ~0.2, and the energy of the sun light to ~0.8. That way you will illuminate all the faces (so no pure black), and will have shadows. ( **Note** : If you add lights from the 'Create' menu, then you will have no shadows by default. Enable them by scrolling down, and selecting 'Ray Shadow' (only present on the Sun light))
!Image
|
stackexchange-blender
|
{
"answer_score": 3,
"question_score": 1,
"tags": "rendering, blender internal render engine, light"
}
|
Sort flat array by multiple rules
I would like some help regarding my sort function for an array as it is not working as I expected.
This function is to sort array of [0,1,2,3,4,...23] into array [9,10,11,12,...,23,0,1,2,3,4,5,6,7,8], I was planning on integrating this function to sort data in my matrix table.
I cant figure out why the values [0,1,2] are out of place.
Here is the code:
<?php
function cmp($a, $b)
{
if ($a == $b) return 0;
if ($a == 9) return -1;
if ($b == 9) return 1;
return strcmp($a, $b);
}
$a = array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23);
echo'<br>';
usort($a, "cmp");
//print_r($a);
echo '<pre>';
print_r($a);
echo '</pre>';
$arrlength=count($a);
for($x=0;$x<$arrlength;$x++)
{
echo $a[$x];
echo "<br>";
}
?>
|
It appears you'd like to sort integers by number of digits in reverse, then sequentially within each digit count group. Also, there is a special constraint that 9 counts as a double-digit number.
This function generates the expected output but may require modifications to handle conditions not obvious from your test case, such as numbers 90 and over (but from the comments, this relates to time, so it's probably sufficient):
function cmp($a, $b) {
// Handle nines
if ($a == 9) { return -1; }
if ($b == 9) { return 1; }
// Perform a comparison by digit count
$cmp = strcmp(strlen($a), strlen($b));
if ($cmp === 0) { // Same digit count, sort sequentially
return $a - $b;
}
return -$cmp; // Different digit counts; sort in reverse
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "arrays, sorting, usort"
}
|
React not supporting map method
Following react.js tutorial I've got an error: Uncaught TypeError: Cannot read property 'map' of undefined.
I have a state like this :
this.state = {
input: '',
array1:[{name:"john"}, {name:"Tom"}, {name:"Walt"}, {name:"Peter"}]
}
and shared this as props to ResponseList component
<ResponseList apiRes = {this.state.array1} />
In the ResponseList I can't map through the array1
const ResponseList = ({ array1 }) => {
return(
<div>
{
array1.map((data,x) => data.name)
}
</div>
)
}
|
You should use `apiRes` as a props param, not `array1`. Make the name same.
const ResponseList = ({ apiRes }) => {
return(
<div>
{
apiRes.map((data,x) => data.name)
}
</div>
)
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "reactjs, dictionary"
}
|
xlsx writing - where specified?
I'm trying to write a parser in python at the moment, that reads nessus reports and generates xlsx files.
Is there a detailed description of the inner workings of xlsx? I have a hard time trying to find out just by looking at the xml files, where I specify which style is applied to which cell on which sheet.
|
You can find full details of the OfficeOpenXML standard on the ECMA site but why not use one of the existing Python libraries (such as Eric Gazoni's openpyxl) to actually generate the xlsx file rather than building your own?
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "python, xml, xlsx"
}
|
Laravel 5.1 - hasMany relation on multiple fields inside one table
I'm trying to get proper date returned for a hasMany relation. The difference between 'normal' hasMany relationships is that I'm trying to use 1 table which can be used by multiple models.
I have a setup as such (with a few more fields, but not important for example)
news:
* id
* title
* body
project:
* id
* title
* body
media:
* id
* file
* type (enum project / news)
* type_id
I do get results with the following in my models:
public function media()
{
return $this->hasMany('App\Media','type_id');
}
And getting the results with the:
->with('media')
But when I have a news item with the same id as a project this will return the wrong data back. Is there a way, in eloquent, to also set the type=project||news in both Project and News model?
|
You probably want a polymorphic relationship. It will manage a `type` and `id` field for you and base the queries on them.
Eloquent Relationships - Polymorphic
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "php, laravel, eloquent"
}
|
AWS API Gateway xml request
I have a question about using API Gateway passing an XML request. I'm trying to determine how to create a model (schema validation) if the incoming request is in XML rather than JSON. Everything I've found thus far that describes how to create a model is doing so against a JSON request. It also seems when creating a model it's done so using JSON. Is it possible to create a model for an incoming XML request? I've seen many threads that states you can pass XML request using pass-through when adding the below snippet as the mapping template in the Integration request, but I'm trying to determine how to create a model when the request is XML. Has anyone here done this before?
{
"body" : $input.json('$')
}
|
Currently request validation and models only support JSON as they are written in JSON schema.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "api, aws api gateway"
}
|
Delete part of numeric id of divs
Firstly I added the numeric id to most of my div `class="line"`
var adder = document.getElementsByClassName("line");
for(var i = 0 ;i<adder.length;i++){
adder[i].id=i;
}
How to remove the divs which id is larger than, for an exaple, 10?
I fell into trouble when using parameter as the id in JS. It seems that it's illegal to write like this `document.getElementsById(i);`
PS: Is that appropriate to set id as pure Arabic numbers?
|
I am guessing what you are trying to do is not add ids above the number 10? If that's the case then why not just do:
var adder = document.getElementsByClassName("line");
for(var i = 0 ;i<10;i++){
adder[i].id=i;
}
If you want to do this as a seperate operation for some reason then:
var adder = document.getElementsByClassName("line");
for(var elem in addr){
if(parseInt(addr[elem].Id) > 10){
element = document.getElementById(addr[elem].Id);
element.parentNode.removeChild(element);
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "javascript, html"
}
|
Shortest distance from point to curve
I could use some help solving the following problem. I have many more like this but I figured if I learn how to do one then I can figure out the rest on my own. Thanks in advance!
> A curve described by the equation $y=\sqrt{16x^2+5x+16}$ on a Cartesian plane. What is the shortest distance between coordinate $(2,0)$ and this line?
|
Start by finding the distance from some point on the curve to $(2,0)$ in terms of $x$. Using the distance formula, we get $$D=\sqrt{(x-2)^2+(\sqrt{16x^2+5x+16}-0)^2}$$ $$D=\sqrt{x^2-4x+4+16x^2+5x+16}$$ $$D=\sqrt{17x^2+x+20}$$ This will end up being a messy derivative. However, since the distance $D$ will never be negative, we can minimize $D^2$ instead of $D$ and still get the same answer. So now we get $$D^2=17x^2+x+20$$ $$\frac{dD^2}{dx}=34x+1$$ Now we set this equal to $0$ and solve for $x$: $$34x+1=0$$ $$x=-\frac{1}{34}$$ So the distance is minimized at $x=-\frac{1}{34}$, and to find the minimum distance, simply evaluate $D$ when $x=-\frac{1}{34}$.
|
stackexchange-math
|
{
"answer_score": 8,
"question_score": 12,
"tags": "calculus, linear algebra, algebra precalculus"
}
|
What kind of question are asked in Magento 2 Certified Associate Developer exam?
> What kind of question are asked in Magento 2 Certified Associate Developer exam ?
The exam is designed to validate the skills and knowledge of Magento 2 in the **areas** of
* **UI modifications**
* **database changes**
* **admin modifications**
* **customizations**
* **catalog and checkout structure**
* **functionality changes**
Then what kind of question are asked from above areas, just an idea will be enough so whoever appertaining for the exam can prepare accordingly.
Is Anyone appeared for the exam and have any idea regarding the same ?
|
I have passed the M2 Associate Developer exam recently. Question can not be remember as they are in multi line and hard to understand. The main point is question understanding. If you understand the question correctly, you get the answer easily.
You can check my profile below:
<
You can find the complete Exam_Study_Guide on magento website But swiftotter guide is very helpful.
<
**UI modifications:** This section will cover question based on block type, XML tags, my account section changes, theme and template hierarchy
**database changes:** This section will cover question based on sales and quote tables, relationship of products with categories
**admin modifications:** Admin controller, menu and ACL
**customizations:** all questions are based on business logic
**catalog and checkout structure:** all questions are based on business logic
**functionality changes:** all questions are based on business logic amd ask the best approach
|
stackexchange-magento
|
{
"answer_score": 15,
"question_score": 6,
"tags": "magento2, certification"
}
|
Is the complement of a Max Prefix Sum a Min Suffix Sum?
Given an array `A` of `n` real numbers, are the maximum prefix sum and minimum suffix sum (and vice-versa) of A complements?
I.e. Given `A[1..n]` and its maximum prefix subarray `P[1..i]`, is its minimum suffix subarray `S[j..n]` where `i+1 = j`?
Or stated another way, is `sum(A) = maxPrefixSum(A) + minSuffixSum(A)` true?
_For an array of only negative numbers, let's assume that`P` is empty and `maxPrefixSum(A) = 0`. Similar logic applies in the opposite case._
|
It depends on whether the maximum prefix and minimum suffix are unique. Consider for example the array $0$ -- you can easily find a counterexample to your claim. Suppose therefore that $\sum_{i \leq j \leq k} A[j] \neq 0$ for all $i \leq k$. Let now $j$ maximize $\sum_{i=1}^j A[i]$, and let $k$ minimize $\sum_{i=k+1}^n A[i]$. We want to show that $j=k$. Otherwise, there are two cases:
1. If $j < k$, let $S = \sum_{i=j}^{k-1} A[i]$. By assumption $S \neq 0$. If $S > 0$ then $\sum_{i=1}^{k-1} A[i] > \sum_{i=1}^j A[i]$, and otherwise $\sum_{i=j+1}^n A[i] < \sum_{i=k+1}^n A[i]$.
2. If $j > k$, let $S = \sum_{i=k}^{j-1} A[i]$. By assumption $S \neq 0$. If $S < 0$ then $\sum_{i=1}^{k-1} A[i] > \sum_{i=1}^j A[i]$, and otherwise $\sum_{i=j+1}^n A[i] < \sum_{i=k+1}^n A[i]$.
|
stackexchange-cs
|
{
"answer_score": 1,
"question_score": 1,
"tags": "arrays, maximum subarray"
}
|
Getting Tab Component To Consume UIID
I have tried everything possible to style my Tab component but its not getting reflected. I want my selected Tab to have a white background and red foreground. Even though I have edited Style using Theme designer. Its still doesnt work. I read the docs and I am aware Tab component is now like a toggle. I did the suggestion to setTabUIID(null) but still cant get it to work. How can this be done.
|
You don't need the `setTabUIID(null);` just make sure to style both selected and unselected styles. Also override the Border to `Empty` if you don't define a border.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "codenameone"
}
|
How do you remove NAs?
penguins %>%
select(bill_length_mm) %>%
filter(!is.na(bill_length_mm)) %>%
mean(as.numeric(bill_length_mm), na.rm=TRUE)
Error message: argument is not numeric or logical: returning NA[1] NA
Examining the dataset after filtering shows numeric data with no NAs.
Why am I getting this error? Shouldn't line two or line three of the code remove all NAs?
Thank you.
|
Try wrapping `mean` in `summarize`, like
penguins %>%
select(bill_length_mm) %>%
filter(!is.na(bill_length_mm)) %>%
summarize(mean(as.numeric(bill_length_mm), na.rm=TRUE))
This is happening because `mean` is expecting a vector, but you are passing a dataframe (from the pipe).
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "r, dplyr, na.rm"
}
|
Tools for (semi) automated woodland tracing from satelite images
I'm trying to draw woodlands in OpenStreetMap, using Yahoo sattelite images.
JOSM editor has some plugins that try to automate the process - you have to click inside the area and the plugin finds the boundries. But the quality is pretty bad.
I'm looking for some libraries/algorithms to get good quality boundaries.
The images i'm working with look like this:
|
You are better off using a remote sensing application. Of course, you need to have the raster imagery on your computer. There are tons of methods that can help you determine woodland areas, such as: using Neural Networks, trained patches of imagery, supervised/unsupervised segmentation and classification. I'm not sure if this solves your problem, but it's a start.
There are free DIP (digital image processing), such as GRASS, SPRING (I think it's only available in pt-BR) and OSSIM (I'm not sure about this one)
|
stackexchange-gis
|
{
"answer_score": 5,
"question_score": 9,
"tags": "openstreetmap, tools, satellite"
}
|
confirmation dialogue is not showing when making a phone call in ios 10.2.1 but showing in 10.3
I am using this code to make a phone call. But confirmation alert is not showing in the device which have iOS `version 10.2.1` but showing in iOS `10.3`.
if let url = URL(string: "tel://\(selectedNumber)"){
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
}
}
But i want to show the confirmation alert in all of the iOS version .
|
i have found the solution if i use "telprompt://" it shows confirmation dialogue i in all kinds of ios version. but in ios 10.3 confirmation dialogue shows if use "tel://" or "telprompt://".
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "ios, swift, phone call, openurl"
}
|
xslate/Catalyst::View::Xslate wrapper
I have a Catalyst application that uses TT for views: <
and I would like to try out <
We use the WRAPPER directive with Template Toolkit and I am curious if it is at all possible to reuse the wrapper somehow with xslate or would I have to break them into headers and footers?
|
You can in theory, by using TTerse syntax. According to the manual, enabling this allows you to use a lot of TT compatible code, including a simple `WRAPPER` statement.
However, there are caveats, as documented here. Given the philosophical differences between Xslate and TT, you might find it easier to bite the bullet and just rewrite your wrapper as header and footer Xslate code.
Or hold off on Xslate until your next project. Like horses, Templating engines are difficult to change mid-stream. :-)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "perl, catalyst, template toolkit"
}
|
Is it possible to prevent a DLL from being modified?
Is it possible to sign or otherwise protect a managed (.NET) DLL from being modified? I'm looking for possible solutions that would detect changes to DLLs and prevent them from being loaded by the .NET runtime. I don't mind if someone can load the DLL in Reflector or ILSpy - as long as a modified DLL cannot execute, I'd be fine with that.
I did some searches on this topic, but most articles / discussions recommend obfuscation which is not what I'm looking for. I thought digitally signing the DLL would accomplish this but a chat with my colleagues made me doubt that and I only have superficial knowledge in this area.
Any advice would be appreciated.
|
Signing a DLL doesn't stop other people from decompiling and then modifying your DLL. What it _does_ prevent is them doing that _and then passing the result off as the original_. In other words, the modified DLL will execute if the caller decides to trust it, but any code which expects it to have _your_ public key token will reject it.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": ".net, code security"
}
|
Will NodaTime work in a web application which has been hosted in a intranet environment without internet connection?
I have a Web application which is hosted in an Intranet Environment without Internet connection. Will NodaTime work in the web application and will it be able to retreive the TimeZone information from the TZDB/ OLSON DB without internet connection?
|
Yes, a version of TZDB is built into the NodaTime assembly, and is accessible via `DateTimeProviders.Tzdb`. It's typically the version which was the latest at the time of the release build.
You can supply a newer version too, should you wish to (still without a network connection at execution time, because you'd take this step separately).
What _doesn't_ exist at the moment (and it sounds like you don't need) is using an internet connection to fetch the latest version and use it at execution time.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "timezone, nodatime"
}
|
mean value property and the poisson kernel
d = \frac{1}{2 \pi i} \int_{\gamma} \frac{f(z)}{z-z_0}dz$. But I am not sure how to proceed.I would appreciate some headway. Thank you for the hints below.
For part (iii), I am using the hint given in the problem, and considering, $\frac{1}{2\pi i} \int_{\gamma, 0,1} f(w) \frac{1}{2} (\frac{1+s/w}{1-s/w}) dw + \int_{\gamma,0,1} f(w) \frac{1}{2}\frac{1+sw}{1-sw}dw$. How do I compute this integral in two different ways?
|
Let $ \gamma(t)=z_0+re^{it}$ for $t \in [0, 2 \pi].$
Then
$$f(z_0) = \frac{1}{2 \pi i} \int_{\gamma} \frac{f(z)}{z-z_0}dz= \frac{1}{2 \pi i}\int_0^{2 \pi}\frac{f(z_0+re^{it})}{re^{it}}ire^{it} dt= \frac{1}{2 \pi }\int_0^{2 \pi}f(z_0+re^{it}) dt.$$
Can you proceed ?
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "complex analysis"
}
|
Remove punctuations from list and convert string value to float in python
I want to remove the dollar signs and commas from the column and cast to float. This is what I do so far, it didn't work. Actually nothing changed. The data look like["$200,00","$1,000.00"..."$50.00"]
import pandas as pd
import string
y_train = train.iloc[:,-1]
needtoclean=y_train.to_list()#''.join(y_train.to_list())
to_delete = set(string.punctuation) - {'$',','}
clean = [x for x in needtoclean if x not in to_delete]
|
list_ = ['$58.00', '$60.00'] #Your Lise
new_list = [] #Initialise new list
for elem in list_: #Iterate over previous list's elements
elem = elem.replace("$", '') #Replace the `$` sign
new_list.append(float(elem)) #Add the typecasted float to new list
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "python, python 3.x, string, training data, punctuation"
}
|
Can't verify CSRF token authenticity Rails/React
I have a react component in my rails app where I'm trying to use `fetch()` to send a _POST_ to my rails app hosted on localhost, this gives me the error:
ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
I'm using devise gem to handle `user/registrations` and `logins`.
I have tried to remove `protect_from_forgery with: :exception`
Here is the code for my fetch,
this.state.ids.sub_id});
fetch(POST_PATH, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: body
}).then(res => res.json()).then(console.log);
How can I get the csrf token and send it through the form so that it will pass?
Ideally I would like to just send it through the headers but I have no idea how to access the token.
|
The simplest way to do this, if you are merely embedding a react component in your Rails view, is to retrieve the csrf token from your rails view and then pass it as a header in your fetch api call.
You can get the csrf token by doing something like this:
const csrf = document.querySelector("meta[name='csrf-token']").getAttribute("content");
And then you just pass it as a header in your fetch call: ` ... headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf }, ... `
I normally don't use fetch, so not too sure about the exact syntax, but this should help guide you.
|
stackexchange-stackoverflow
|
{
"answer_score": 20,
"question_score": 10,
"tags": "ruby on rails, reactjs, csrf, protect from forgery"
}
|
read multiple files with same name but different extension Python
i trying to read and write files from folder with same names, BUT different extensions => extract data from them => rewrite. Here is my code:
for header_name in glob.glob(os.path.join(folder_path, "*.json")):
for nii_name in glob.glob(os.path.join(folder_path, "*.nii")):
with open(header_name, "r") as f:
nii_meta = json.load(f)
add_stc = slicetime(header_name).tolist()
nii_meta["SliceTiming"] = add_stc
with open(header_name, 'w') as f:
json.dump(nii_meta, f, indent=2)
i tried to do check:
h_name = os.path.splitext(os.path.basename(header_name))[0]
n_name = os.path.splitext(os.path.basename(nii_name))[0]
if h_name == n_name:
do smth with data form files
but without succes Names of files are sub01_T1w.json, sub01_T1w.nii.gz, sub01_T1w1.json, sub01_T1w1.nii.gz ...
|
I'd suggest working with pathlib, it's a relatively new part of the python standard library that makes working with paths and files a bit easier. A solution using it could look like this:
from pathlib import Path
p = Path('parent/folder/of/my/files')
json_names = {f.stem for f in p.iterdir() if f.suffix == '.json'}
nii_names = {Path(f.stem).stem for f in p.iterdir() if f.suffixes == ['.nii', '.gz']}
for file_name in json_names & nii_names:
json_path = p / (file_name + '.json')
nii_path = p / (file_name + '.nii.gz')
with open(json_path) as json_file, open(nii_path) as nii_file:
... # do things with the files' contents
If you want to write to them, remember to re-open the target with `open(json_path, 'w')` after exiting the read-only `with`-block.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "python, json, nifti"
}
|
Where and how is a value's data type stored, in JavaScript?
In JavaScript, we have 6 primitive data types (each with their own object wrapper) and 1 object data type.
Where / how does v8 store a value's data type?
|
The data type is part of the value. The type of JS values is a sum type that lets us distinguish the primitive types and objects. For example `typeof` is an operator that lets us access (parts of) the bit that stores the type.
Of course, an optimising compiler is free to drop that information when it can prove that a certain variable will only ever store values of the same type, so in the implementation the information might be moved to an annotation on the variable.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -2,
"tags": "javascript, c++, v8"
}
|
Lemmatizing txt file and replacing only lemmatized words
Having trouble figuring out how to lemmatize words from a txt file. I've gotten as far as listing the words, but I'm not sure how to lemmatize them after the fact.
Here's what I have:
import nltk, re
nltk.download('wordnet')
from nltk.stem.wordnet import WordNetLemmatizer
def lemfile():
f = open('1865-Lincoln.txt', 'r')
text = f.read().lower()
f.close()
text = re.sub('[^a-z\ \']+', " ", text)
words = list(text.split())
|
Initialise a `WordNetLemmatizer` object, and lemmatize each word in your lines. You can perform inplace file I/O using the `fileinput` module.
#
import fileinput
lemmatizer = WordNetLemmatizer()
for line in fileinput.input('1865-Lincoln.txt', inplace=True, backup='.bak'):
line = ' '.join(
[lemmatizer.lemmatize(w) for w in line.rstrip().split()]
)
# overwrites current `line` in file
print(line)
`fileinput.input` redirects stdout to the open file when it is in use.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 3,
"tags": "python, nltk, lemmatization"
}
|
Parsing xml to html in Java
I googled many Java API's to parse the xml into HTML but confused from where I start. I never did any xml to html parsing task. This is ouput of resume parsing 3rd party in shape of xml data and I have to transform it into html.
Best regards
|
There is no "parse to html", maybe you mean "transform to html", in that case take a look at XSLT.
XSLT is a language (written in XML itself) to transform XML to another XML, and XHTML happens to be an XML, so using XSLT you can transform from one to another.
As for the Java library to use, you can use directly classes in the JRE, namely javax.xml.transform.TransformerFactory and related classes. Otherwise you can use XALAN directly (see < or SAXON, or Cocoon 3 ( which makes parsing, transforming and saving the result file transparent.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -2,
"tags": "html, xml, parsing, xml parsing"
}
|
SqlDataReader poisition
When the code reaches the loop what will be the position of the reader, is it suppose to be 0 or 1? Why does it behave this way?
bool tag= sqlDataReader.Read();
if (tag)
{
while (sqlDataReader.Read())
|
There is no concept of position in a `DataReader`. You are always at the first position. It is forward-only. The `DataReader.Read` reads the next record and returns True if a row was read, or False if no rows were read.
So, to answer your question, If your `sqlDataReader` had 0 rows, `tag` will be False. In such a case it won't ever enter the `If` block and hence never reach the `While` statement. If it had one or more rows, then `tag` will be True, and your `While` loop will execute until all rows have been read from the DataReader.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "vb.net"
}
|
Change format of date from mm/dd/yyyy to yyyy-mm-dd
How would I change 02/01/1999 to 1999-02-01 using perl? Ive tried this but it is returning DATE IS -00-00
sub changeDate{
my $date = shift;
my @adate=split (/\//, $date);
my $ndate=$adate[2]."-".sprintf("%02d", $adate[1])."-".sprintf("%02d",$adate[0]);
say "DATE IS $ndate";
return $ndate;
}
|
What you have is correct.
$ perl -e'
use feature qw( say );
sub changeDate{
my $date = shift;
my @adate=split (/\//, $date);
my $ndate=$adate[2]."-".sprintf("%02d", $adate[1])."-".sprintf("%02d",$adate[0]);
return $ndate;
}
say changeDate("02/01/1999");
'
1999-01-02
You must have passed something other than `02/01/1999` to `changeDate`.
Note that `changeDate` can be reduce to the following:
sub changeDate { sprintf '%3$d-%1$02d-%2$02d', split /\//, shift }
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "perl"
}
|
My netbook volume + and volume - buttons stopped working after 12.04 update
That's it...
Brightness buttons are still working great but volume button simply won't do anything...
What can I do?
Thanks.
ps
I have an Asus 1215n and Ubuntu 12.04
|
Ok it sounds STRANGE but it worked :/
I booted into windows (from hybernating state) and keys and keys were also dead there.
I've rebooted windows normally and keys were back working.
I've rebooted Ubuntu and keys were also working there.
:/
|
stackexchange-askubuntu
|
{
"answer_score": 1,
"question_score": 1,
"tags": "volume control"
}
|
GLM feature selection method
I use General Linear Model (GLM) to do feature extraction and to get a beta-matrix. I also got a class-label-matrix. It is a multiple class problem.
Now I want to use t-test to do feature selection based on GLM feature extraction. Can anyone tell me how to write t-test to do this feature selection? Thank you so much!
|
Have you tried using the function `fitglm`? It can fit general linear models and returns p-values and t statistics for all your regressors automatically:
`mdl = fitglm(X,y,'linear','Distribution','normal')`
If you'd prefer calculating the t-tests yourself, you can run a t-test for testing whether your weights are significantly different than 0 by calculating the t-statistic: `beta/SE(beta)` for each of your weights `beta`, where `SE(beta)` is the standard error of your betas (or, the square root of the diagonal of the variance-covariance matrix). You can read more about the t-test for regressors here.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "matlab, statistics"
}
|
Integral of meromorphic function.
Let $f(z)$ be meromorphic function in $\Omega\subset\mathbb{C}$ with a pole $z=z_0$. Then, is it true that there is a number $N$ such that $$\sum_{n=1}^{\infty} \int_C f(z)(z-z_0)^{n-1}dz=\sum_{n=1}^{N}\int_C f(z)(z-z_0)^{n-1}dz$$ where $C$ is closed contour containing $z_0$. This integral and summation are principal part of coefficient of Laurent series. I guess, for any meromorphic function $f$, $$f(z)=(z-z_0)^N g(z)$$ for some $N\in \mathbb{N}$ and holomorphic function $g(z)$ in $\Omega$. But, I am failing it.
|
No try with $z_0=0$, $f(z)= \frac1{z(z-1)}$ and $C$ the circle of radius $2$. Then for all $n\ge 2$, $$ \int_C f(z)z^{n-1}dz= 2i\pi $$ If you meant that $0$ is the only pole of $f$ and $\Omega$ is **simply connected** then yes sure, for $n$ large enough $f(z)z^{n-1}$ is analytic on $\Omega$ and its integral on a closed-contour contained in $\Omega$ is $0$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "complex analysis"
}
|
How to make warnings persist in visual studio
Suppose I have files `a.cpp` and `b.cpp` and I get warnings in `a.cpp` and an error in `b.cpp`. I fix the error in `b.cpp` and recompile -- since Visual Studio doesn't have to recompile `a.cpp`, it doesn't remind me of the warnings it found before.
I'd like to somehow have the warnings persist; however, I **don't** want it to treat warnings as errors (I'd like it to still compile/run even with warnings). Is this possible?
|
Essentially, you're out of luck. The C++ compilation will discard all of the errors and warnings. Because it only recompiles .CPP files that have a missing .OBJ file (i.e. the ones that had errors and failed last time), you'll only see the errors.
You have a few options. Off the top of my head:
* Write a macro that responds to the build complete event. If it sees any warnings, it could delete the .OBJ file. The .CPP file would be compiled again next time. Unfortunately, this means that your program may not run without recompilation.
* You could write a macro that works the other way: on build start, look to see if there are any warnings, and then delete the .OBJ file.
* Write a VS addin that remembers warnings until the .CPP file is compiled again.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c++, visual studio, warnings"
}
|
Converter from SQL to Linq to Fluent Nhibernate
I am wondering if there is a converter where I can type an SQL statement and receive its fluent Nhibernate equivalent?
I have this SQL statement:
SELECT F.*
From Foo F
INNER JOIN HamSandwich HS
ON F.HamSandwichId = HS.HamSandwichId
Where
HS.MustardId =
(Select MustardId
From HamSandwich
Where HamSandwichId = 1)
And I want to turn it into a fluent Nhibernate query.
session.QueryOver<Foo>()
.JoinQueryOver(foo => foo.HamSandwich)
.Where() // this is where I am still drawing a blank
|
Assuming some things about your entites and mappings, this is the equivalent QueryOver:
IList<Foo> foos = session.QueryOver<Foo>()
.JoinQueryOver(foo => foo.HamSandwich)
.WithSubquery.WhereProperty(hs => hs.Mustard.Id).Eq(
QueryOver.Of<HamSandwich>()
.Where(hs => hs.Id == 1)
.Select(hs => hs.Mustard.Id))
.TransformUsing(Transformers.DistinctRootEntity)
.List<Foo>();
This generates the following SQL:
SELECT this_.*
FROM [Foo] this_
inner join [HamSandwich] hs1_
on this_.HamSandwichId = hs1_.Id
WHERE hs1_.MustardId = (SELECT this_0_.MustardId as y0_
FROM [HamSandwich] this_0_
WHERE this_0_.Id = 1 /* @p0 */)
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "nhibernate, fluent nhibernate"
}
|
MONGO_URL not being picked up by Meteor app
I have a Meteor app. and before running it I set the MONGO_URL like this:
MONGO_URL="mongodb://127.0.0.1:3001/my-db"
I echo the env var to make sure it has taken using:
echo $MONGO_URL
and all is good. Anyway, when I then run:
sudo meteor run
the app. starts, with no errors, but the database that it is connecting to is not the 'my-db' database - it is connecting to the default 'meteor' database! How is this happening when I am explicitly setting the MONGO_URL beforehand?
|
You need to do one of two things:
**use the variable inline**
$ MONGO_URL="mongodb://127.0.0.1:3001/my-db" meteor
**export the variable**
$ export MONGO_URL="mongodb://127.0.0.1:3001/my-db"
$ meteor
An `export` is required in the latter case so the variable will be available to the subprocess.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "mongodb, meteor"
}
|
Solving $\mathrm{exp}(z^2) = 1$
Solve $\mathrm{exp}(z^2) = 1$ where $z\in\mathbb{C}$.
This is what I did, however, testing values shows that it's incorrect.
$$\begin{align}\mathrm{exp}(z^2) &= 1 \\\ \mathrm{Log}(\mathrm{exp}(z^2)) &= \mathrm{Log}(1) + 2k\pi i \qquad \text{where Log is the principal logarithm, k$\in\mathbb{Z}$} \\\ z^2 &= 2k\pi i \\\ \mathrm{exp}(2\mathrm{Log}(z)) &= 2k\pi i \\\ 2\mathrm{Log}(z) &= \mathrm{Log}(2k\pi i ) + 2n\pi i, \qquad \text{n$\in\mathbb{Z}$} \\\ 2\mathrm{Log}(z)&=\ln(|2k\pi|) + 2n\pi i \\\ \mathrm{Log}(z) &= \frac{1}{2}\ln(|2k\pi|) + n\pi i \\\ z&= \sqrt{|2k\pi|} (-1)^n \end{align}$$
However, testing for $k=3,n=5$, the expression equals $\exp(6\pi)\neq 1$...
|
The actual mistake I see is your evaluation of the logarithm of $2k\pi i$, which is missing the $\pm \frac{\pi}{2}i$, covering the cases where $k$ is positive or negative (ignoring $0$).
But once you have $z^2 = 2k\pi i$ you need only know how to take square roots of $\pm i$ to finish. The four roots of $\pm i$ are $\pm \frac1{\sqrt 2}\pm \frac{1}{\sqrt2}i$, so you have those multiplied with $\sqrt{2k\pi}$ with $k$ a _nonnegative_ integer.
Square roots are ambiguous in the sense that $\sqrt{a}$ in general has two values, but solving the equation $z^2 = a$ means finding both square roots of the complex number $a$. The polar form of the number makes it easier to do so in general.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 2,
"tags": "complex analysis"
}
|
Selecting from multidimensional numpy array
I have a multidimensional array a with shape (nt, nz, ny, nx). The dimensions are time, z, y, x. For each time, x and y, I've selected the appropriate z in a new index array J with shape (nt, ny, nx). J contains the indices along the height dimension that I'd like to select. Using Python, I could do this in a loop:
b=J.copy()
for t in range(nt):
for y in range(ny):
for x in range(nx):
z=J[t,y,x]
b[t,y,x]=a[t,z,y,x]
But I want to do this faster, without the loops. This is probably trivial, but I can't get my head around it. Anyone?
|
You can use `numpy.indices()` together with advanced indexing:
t, y, x = numpy.indices(J.shape)
b = a[t, J, y, x]
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 4,
"tags": "python, arrays, multidimensional array, matrix, numpy"
}
|
Looping through the elements of a path variable in Bash
I want to loop through a path list that I have gotten from an `echo $VARIABLE` command.
For example:
`echo $MANPATH` will return
`/usr/lib:/usr/sfw/lib:/usr/info`
So that is three different paths, each separated by a colon. I want to loop though each of those paths. Is there a way to do that? Thanks.
Thanks for all the replies so far, it looks like I actually don't need a loop after all. I just need a way to take out the colon so I can run one `ls` command on those three paths.
|
You can use Bash's pattern substitution parameter expansion to populate your loop variable. For example:
MANPATH=/usr/lib:/usr/sfw/lib:/usr/info
# Replace colons with spaces to create list.
for path in ${MANPATH//:/ }; do
echo "$path"
done
Note: Don't enclose the substitution expansion in quotes. You want the expanded values from MANPATH to be interpreted by the for-loop as separate words, rather than as a single string.
|
stackexchange-stackoverflow
|
{
"answer_score": 16,
"question_score": 39,
"tags": "linux, bash"
}
|
Finding order of poles of complex functions
Complex function $\frac{1}{1-cos z}$ has order 2 poles when $z= 2n\pi, n\in \mathbb Z$. I can find the values of $z$ on poles but how to find the order of the poles?
|
The order of a pole of $f$ at a point $a$ is the order of $a$ as a zero of $\frac1f$. And, if $n\in\Bbb Z$ and if $f(z)=1-\cos z$, then$$f'(2\pi n)=\sin(2\pi n)=0\quad\text{and}\quad f''(2\pi n)=\cos(2\pi n)=(-1)^n\ne0.$$So, $2\pi n$ is a zero of order $2$ of $f$, and therefore a pole of order $2$ of $\frac1{1-\cos z}$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "complex analysis, complex numbers"
}
|
Writing matrix summation in equation form
In Python I can sum along a matrix axis like so
import numpy as np
a = np.ones( (10,10) )
# now sum all rows
a_sum = a.sum(axis=0)
I would like to write that summation as an equation in a manuscript I am preparing. Is there a standard notation of doing this? I have thought about using the summation symbol (Sigma), but my concern is this will be too convoluted for the reader.
|
should the direct summation $\sum_{i}A_{i,j}$ be too "convoluted", one could rewrite it as, e.g., $v^\mathsf{T}.A$, where $v=(1,1,\ldots,1)$ is a vector with all elements equal to $1$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "matrices, summation"
}
|
Is there a way to embed C# code into a Lua script?
I have a program which forces Lua as a choice for programming plugins. I'd like to take some existing C# code, and use it in this program. Is this possible?
I should add that I know one can easily embed Lua code into C#, but I haven't found the reverse anywhere. Thanks guys!
|
Take a look at LuaInteface:
> LuaInterface is a way for Lua programs to access the CLR (Common Language Runtime), otherwise known as .NET in the Windows world and Mono on Linux.
I'm not sure that's the official site, and there are multiple versions/forks (like MonoLuaInterface). Just search for LuaInterface.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 6,
"tags": "c#, lua"
}
|
Unacaught process is not defined even when used inside an if (process) {} block?
So I'm trying to swap between API links in my angular app based on the origin, but it is an SSR app so I'm trying to account for an environment variable as well as window location, the code is as follows:
const getApiUrl = (): string => {
if (process && process.env?.AZURE_ENV === 'development') {
return 'devlink for SSR';
} else if (
window &&
window.location.origin === 'devclient'
) {
return 'devlink for frontendclient';
} else {
return 'link.com/';
}
};
Now the error being thrown out is:
Uncaught ReferenceError: process is not defined
I've digged into the 'compiled' script and have 100% confirmed it's coming from this piece of code.
Shouldn't this still work though?
I've also tried a vesion where I just have if(process) and get the exact same result as above.
|
Probably it is not there so it will fail to evaluate, maybe testing it like `typeof process !== 'undefined'` will help
If `process` has never been defined in any accessible context I think it will fail with an UncaughtReferenceError because it is trying to access something not in the context. Undefined means that the variable exists but it has no value set and this error says that the variable is just not there, thats why checkinng the type of it will probably solve the issue.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "javascript, node.js"
}
|
Set thread priority for job in grails
I have a job running on a grails app that I need to run with lower priority. Is there a configuration to set that?
|
You can set the priority on a Quartz trigger like this:
myTrigger.setPriority(10);
If the priority is not set explicitly, it defaults to 5. In Grails, you can presumably (I haven't tested this) specify this within the `triggers` closure of the job class like this:
class MyJob {
def execute() {
println "Job running!"
}
static triggers = {
simple name:'highPriority', priority: 10, startDelay:10000, repeatInterval: 30000, repeatCount: 10
cron name:'lowPriority', priority: 1, startDelay:10000, cronExpression: '0/6 * 15 * * ?'
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "grails, groovy, quartz scheduler"
}
|
Prove: $|\dddot{\gamma}|^2=\kappa^4+\kappa^2 \tau^2+\dot{\kappa}^2$, $\langle \dot{\gamma}, \dddot{\gamma} \rangle =-\kappa^2$
We have $\gamma (t) $ (parametrised regulary) that has a curvature $\kappa$ and torsion $\tau$. Prove:
> 1. $|\dddot{\gamma}|^2=\kappa^4+\kappa^2 \tau^2+\dot{\kappa}^2$
> 2. $\langle \dot{\gamma}, \dddot{\gamma} \rangle =-\kappa^2$
> 3. $\langle \ddot{\gamma}, \dddot{\gamma} \rangle =\kappa \dot{\kappa}$.
>
Can anyone help me?
|
I assume $\gamma(s)$ is parametrized by arc-length $s$. Then
$\dot \gamma = T, \tag 1$
the unit tangent vector;
$\ddot \gamma = \dot T = \kappa N, \tag 2$
where $N$ a unit vector normal to $T$; thus
$\dddot \gamma = \dfrac{d(\kappa N)}{ds} = \dot \kappa N + \kappa \dot N; \tag 3$
by Frenet-Serret,
$\dot N = -\kappa T + \tau B, \tag 4$
so (3) becomes
$\dddot \gamma = \dot \kappa N - \kappa^2 T + \kappa \tau B; \tag 5$
since $T$, $N$, and $B = T \times N$ form an orthonormal triad, (5) yields
$\vert \dddot \gamma \vert^2 = \langle \dddot \gamma, \dddot \gamma \rangle = \kappa^4 + \kappa^2 \tau^2 + \dot \kappa^2; \tag 6$
using (1) and (5) we find
$\langle \dot \gamma, \dddot \gamma \rangle = \langle T, \dot \kappa N - \kappa^2 T + \kappa \tau B \rangle = -\kappa^2; \tag 7$
finally, using (2) and (5) we obtain
$\langle \ddot \gamma, \dddot \gamma \rangle = \langle \kappa N, \dot \kappa N - \kappa^2 T + \kappa \tau B \rangle = \kappa \dot \kappa. \tag 8$
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "differential geometry, curves, curvature"
}
|
Remote Access WAMP from phone
I've the same problem as describe in this question
Forbidden error when accessing wamp from local network
I tried all this thing but doesn't work :(
|
I found the solution of my problem.
in `httpd.conf`file change the following
DocumentRoot "J:/wamp/www/"
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
and this too,
# onlineoffline tag - don't remove
Order Allow,Deny
Allow from all
Allow from 127.0.0.1
</Directory>
and it works fine for me.
I found the solution from Github
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "apache, permissions, wamp, local, configure"
}
|
Node.js reusing function
i have written a function in file hello.js
* * *
dep1=require('dependency');
function hello(Args, callback){
modifiedData= dep1.someFunction(Args);
console.log(modifiedData);
callback(modifiedData);
}
module.exports=hello;
* * *
how would i re-use this function in other file?
h=require("./hello");
h.hello("Howdy!", function(err,args){
do something;
}
Any pointers?
|
That looks acceptable, although it is a bit hard to read. But when your callback has `err` as the first argument, make sure you send a `null` object as the first parameter:
callback(null, modifiedData);
When you are using `module.exports`, then the module itself can be called as that function. So you will reuse that function like this:
h = require("./hello");
h("Howdy!", function(err, args) {
//do smth
});
Otherwise, in order for your example to work, just delete `module.` and add the name (can be a different one):
exports.hello = hello;
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "node.js"
}
|
How to redirect from subfolder with .htaccess?
i have some question for you, pardon me before. I have some trouble when i want to redirect my website to another location. A url i have trying is like this :
=> Default URL
I want to redirect my Default url to here:
=> What i want
My **.htaccess** code is :
Redirect 301 public /
im using **laravel** framework
|
Put your .htaccess file in "public" folder:
RewriteEngine on
RewriteRule (.*)$ /mywebsite/$1 [R=301,L]
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, .htaccess, redirect, frameworks, laravel"
}
|
Verify LL(1) grammar with ANTLR
I understand that ANTLR can accept an LL(*) grammar. But, is there any way to check a grammar whether it is an LL(1) or not using ANTLR?
|
options {
k = 1;
}
It will give a warning if your grammer is not in LL(1).
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 2,
"tags": "antlr, grammar"
}
|
Function not returning integer value (C)
So I have this code, when I print N it comes out as 0, can someone explain to me why this is happening and how to avoid it?
#include <stdio.h>
#include <math.h>
int enter(char[],int);
int main(void){
int N,M,i,j,f=1;
double C=0;
enter("Enter number N: ",N);
printf("%d",N);
return 0;
}
int enter(char s[], int a){
do{
printf("%s",s);
scanf("%d",&a);
}while(a<1||a>15);
return a;
}
|
You need to save the value returned by the enter function into 'N'
Like this
`N = enter("Enter number N: ",N);`
Also initialize 'N' to something like N=0, as by default N will be a garbage value.
Or You can pass 'N' by reference instead of value
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -2,
"tags": "c"
}
|
Evaluating the sum: $S_n=\sum_{k=1}^\infty\dfrac{k^n}{(k!)^2}$
The sum: $$S_2=\sum_{k=1}^\infty\dfrac{k^2}{(k!)^2}$$ is equal to: $S_2=I_0(2)$ where $I_0(2)$ is the modifyed Bessel function of the first kind $I_0(x)$ calculated for $x=2$. $$S_3=\sum_{k=1}^\infty\dfrac{k^3}{(k!)^2}$$ is equal to: $S_3=I_0(2)+I_1(2)$. For $n\gt3$ the result is a more complicated form involving Hypergeometric functions. My question is: is it possible to find a closed formula for $$S_n=\sum_{k=1}^\infty\dfrac{k^n}{(k!)^2}?$$ Thanks in advance for any answer or hint.
|
By using Stirling numbers of the second kind we have: $$ k^n = \sum_{j=0}^{n}{n \brace j}(k)_j $$ where $(k)_j$ is the falling Pochhammer symbol: $(k)_j = k(k-1)\cdot\ldots\cdot(k-j+1).$ Since: $$\sum_{k=1}^{+\infty}\frac{(k)_j}{(k!)^2}=I_{-j}(2)$$ it follows that:
> $$\sum_{k=1}^{+\infty}\frac{k^n}{(k!)^2}=\sum_{j=0}^{n}{n \brace j}I_{-j}(2)=\sum_{j=0}^{n}{n \brace j}I_{j}(2).$$
Have a look at this OEIS entry, too.
|
stackexchange-math
|
{
"answer_score": 9,
"question_score": 7,
"tags": "sequences and series, bessel functions"
}
|
How to write "replace" once in a SQL query having 3 times like operator
Here is my sql query. I don't want to write the "replace" 3 times. How can I optimize it ?
select * from table1 where col1='blah' AND
(
replace(replace(col2,'_',' '),'-',' ') LIKE ? OR
replace(replace(col2,'_',' '),'-',' ') LIKE ? OR
replace(replace(col2,'_',' '),'-',' ') LIKE ?
)
|
In MySQL you can use a column alias in the HAVING clause even without any aggregation:
select *, replace(replace(col2,'_',' '),'-',' ') as col2_replace
from table1
where col1='blah'
having col2_replace like ?
or col2_replace like ?
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "mysql, sql, query optimization"
}
|
How to implement hashtag view in Android?
, it says that `org-outline-overlay-data` has been removed.
But there is no `org-outline-overlay-data` in the `expand-region` code when I search the package directory.
#### System Info
- OS: gnu/linux
- Emacs: 26.1
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. fba6d38bf)
- Graphic display: t
- Distribution: spacemacs
|
just delete `~/.emacs.d/elpa/*/develop/expand-region*` and spacemacs will re-install it.
<
> @flatwhatson
> The problem is that expand-region is byte-compiled with the built-in org, but then the org layer installs a newer version from ELPA which has changed the definition of the org-save-outline-visibility macro, leading to the symbol error.
* * *
As an alternative, you can try to update/reinstall the `expand-region` package via `M-x package-reinstall RET expand-region RET` (you might have to do `M-x package-refresh-contents RET` first to update your package index from ELPA.)
|
stackexchange-emacs
|
{
"answer_score": 6,
"question_score": 4,
"tags": "org mode, debugging"
}
|
using ajax url to call php file
Cant seem to connect the ajax url to a php file. I've been fiddling around for ages.
File path of JavaScript: h******ze.com/public_html/wp-content/themes/buddyboss-theme-child/assets/js
needs to be be linked to file path PHP:
h******ze.com/public_html/wp-content/plugins/buddyboss-platform/bp-templates/bp-nouveau/buddypress/activity/user-duration.php
setInterval(function(){
$.ajax({
url: '/public_html/wp-content/plugins/buddyboss-platform/bp-templates/bp-nouveau/buddypress/activity/user-duration.php',
success: function(data) {
$('.result').html(data);
}
});
}, 3000);
|
Assuming the website is visible at h???????ze.com and not h??????ze.com/public_html your URL should be /wp-content/plugins/buddyboss-platform/bp-templates/bp-nouveau/buddypress/activity/user-duration.php
public_html is the root of your website and will contain index.php so you need to point it there. The browser has no access to anything before this in the URL you are using.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -2,
"tags": "php, ajax, path"
}
|
regex for address field in Laravel
Hello I need to validate addresses like the following
C/s-2, abc, pqr
C/s/2, abc, pqr
221B Baker Street
101, Baker Street, London, UK
221-B, Baker Street etc
basically looking for standard address types that I can validate using laravel's validation
I have tried following expressions
'address' => 'required|regex:/^(?=.*[0-9])[- ,\/0-9]+$/',
'address' => 'required|regex:/[^a-zA-Z0-9\/-]|[,\/]$/s',
'address' => 'required|regex:/(^([0-9]+ )?[a-zA-Z ]+$)/',
'address' => 'required|regex:/(^[A-Za-z0-9 ]+$)/',
but nothing has worked for me can you please help to get the right regex for such addresses
Thank you :)
|
finally got something that is working for me I don't know whether it will work for long or not but presently it is working well.
'address' => 'required|regex:/(^[-0-9A-Za-z.,\/ ]+$)/'
however the previous posted answer is also working well I don't know why he deleted that answer anyway I'm pasting his demo which worked for me
'address' => 'required|regex:/([- ,\/0-9a-zA-Z]+)/',
**WORKING DEMO**
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 3,
"tags": "php, regex, laravel, laravel 5, laravel validation"
}
|
Use of smoothed target variable when evaluating forecasting performance
I am working on a forecasting model for the stock price using nonlinear autoregressive network with exogenous inputs (NARX) with MATLAB software. I have achieved good performance and good results in the neural network model. For denoising, the variables (time series data) I have used SMA (simple moving average) for both input and target variables. Am I allowed to use the moving average for smoothing the output variable? Is it a big problem or challenge for interpreting my findings when I have used the data smoothing technique for my target (output) variable? Is it possible to interpret my result?
My skepticism is more about the mathematical and computational aspect of the theorem. Could I have reached unrealistic and high-error results due to output manipulation?
|
The original target variable (a stock price) is most likely unpredictable as it is roughly a random walk (RW) – unless you have some weird stock, that is. By using moving-average smoothing on it, you are introducing predictability. The predictability is entirely an artefact of smoothing.* Thus, if you find that you are able to predict your smoothed target variable, you should not conclude that you are able to predict the underlying stock price. It is also not obvious for me why you would be interested in predicting a smoothed variable rather than the actual one.
*You can check that by simulating a random walk and then smoothing it. Look at the autocorrelation function (ACF) of the increments of the original RW and the smoothed RW. You will see the former shows no predictability while the latter shows some (perhaps even considerable) predictability, depending on exactly what kind of moving average you have used for smoothing.
|
stackexchange-stats
|
{
"answer_score": 0,
"question_score": -1,
"tags": "neural networks, forecasting, interpretation, model evaluation, moving average"
}
|
Populate form with file name from mysql database
I've created a series of forms for users to add and edit records in a database. The database includes audio and image file names (the actual files are moved to folders on submit).
My problem is that I can't get the file names to display on the edit forms. Which means that unless the user uploads the files again, those fields are blanked in the database! I understand the "type='file'" does not take a "value" attribute. I was able to get around that in my textareas by simply displaying the php variable in the textarea. I tried that with file names, and they do display, but outside of the input box, which means... see above, blanked fields within the database.
Here's the code I'm using:
<li>
<label for=se_ogg">Sound excerpt (upload .ogg file)</label>
<input id="se_ogg" type = "file"
name = "se_ogg">' . $row['se_ogg'] . '</input>
</li>
Any ideas? Can this be done?
|
The file input field doesn't allow you to define a value for security reasons otherwise you could hide a file field and use it to grab files from unsuspecting peoples computers. If you just want to display the filename of the file just uploaded just display it as formatted text.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "mysql, forms, populate"
}
|
Efficient MIP reformulation for binary integer problem
Consider an integer programming model where there is some term $x_ix_j$ where the variables $x_i,x_j \in \\{0,1\\}$
I want to reformulate this into an efficient mixed-integer programming (MIP) problem.
I can create a new variables $y_{ij}\in R_+$ as a substitute and then add the following constraints:
$y_{ij} \leq x_i \\\ y_{ij} \leq x_j \\\ y_{ij} \geq 1 - (1-x_i) - (1-x_j)$
I imagine there are various MIP reformulations possible. Is there a more efficient reformulation strategy?
|
If your optimization function doesn't depend on $y_{ij}$ directly, you may eliminate the last constraint by adding $\epsilon \cdot y_{ij}$ to the objective function (the sign of $\epsilon$ would depend on whether you are maximizing ($\epsilon > 0$) or minimizing ($\epsilon < 0$)).
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "optimization, integer programming, mixed integer programming"
}
|
ls: cannot access file : No such file or directory.
In the shell script, I will have to access the binary logs stored in /usr/local/mysql/data. but when I do this,
STARTLOG=000002
ENDLOG=000222
file=`ls -d /usr/local/mysql/data/mysql-bin.{$STARTLOG..$ENDLOG}| sed 's/^.*\///'`
echo $file
I get the below error :
ls: cannot access /usr/local/mysql/data/mysql-bin.{000002..000222}: No such file or directory.
But when I manually enter the numbers in the range the shell scripts runs normally without error.
|
Try using `seq(1)`:
file=`ls -d $(seq --format="/usr/local/mysql/data/mysql-bin.%06.0f" $STARTLOG $ENDLOG) | sed 's/^.*\///'`
|
stackexchange-serverfault
|
{
"answer_score": 1,
"question_score": -2,
"tags": "bash, shell, ls"
}
|
R - grepl conditions on vector to exclude exact match
I am struggling to properly exclude variables when I use `grepl`.
Imagine my vector is
vec = c("POP MUSIC", "TOP THE POPS", "POPEYE", "MARY POPPINS")
I want to `grepl` `POP` when I visually recognise pop music. In my example I want then to exclude `"POPEYE", "MARY POPPINS"`.
How could I do something like ? And why this line of code does not work ?
vec[ grepl("POP", vec ) & grepl("^POPEY$", vec ) & grepl("^MARY POPPINS$", vec ) ]
**desired results**
`"POP MUSIC" "TOP THE POPS"`
thanks
|
You can use the following `grep` solution:
vec = c("POP MUSIC", "TOP THE POPS", "POPEYE", "MARY POPPINS")
grep("(?i)\\bPOPS?\\b", vec, value = TRUE)
See IDEONE demo
The regex `(?i)\\bPOPS?\\b` matches a whole word `POP` or `POPS` in a case-insensitive way (due to `(?i)`) and if found, the value is returned (due to `value=TRUE`).
You may need to adjust the regex as per your needs (e.g. `(?i)\\bPOP(S|PING)?\\b` to also allow `popping`).
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "regex, r, grepl"
}
|
Pagination, items per page dependant on number of results (PHP)
long time lurker first time asker.
I'm trying to piece together a pagination function that will take into account the total amount of items and increase the results per page to ensure each page is fully populated.
For example if I had 35 results and I wanted a minimum of 10 results per page it would ideally return 12, 12 & 11 results per page.
Clearly my logic-fu is weak because I for the life of me cannot seem to comprehend this seemingly simple task. Embarrassing (it pains me to ask) as I've been at this for a week now and I know there's a simple answer to this.
I'm not necessarily asking for a solution (though that would be appreciated) as a hint in the right direction may be all I need.
|
Supposing you have at least 10 items (test it) :
nbPages = floor(nbItems/10)
nbItemsPerPageMax = 10 + ceil((nbItems - 10*nbPages)/nbPages)
You won't need to adjust for the last page as the `limit` clause don't need the exact number or items in this case (just use `limit numPage*nbItemsPerPageMax, nbItemsPerPageMax`).
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "php, pagination"
}
|
Allow resize on "Designed for iPad" App for Apple Silicon Mac
Is there a way to allow an App running in _Design for iPad_ mode on an Apple Silicon Mac to be resized? I thought it was enough to choose "Optimize Interface for Mac", but that doesn't work.
Is it a feature that I can enable only compiling the App for Catalyst or Rosetta?
 so you have to adapt the interface.
. I expect the input to be of the form
1 2 3
4 5 6
7 8 9
if it has 3 rows.
So far I've gotten this:
(defun read-2d-array (rows &rest args)
(values (read-from-string
(concatenate 'string "#2A("
(dotimes (i rows)
(concatenate 'string "("
(apply #'read-line args)
")"))
")"))))
The problem with this is that while the outer concatenate seems to work, I'm having trouble trying to concatenate across the loop iterations and get the form:
#2A((1 2 3)(4 5 6)(7 8 9))
Any help will be appreciated. Thanks!
|
All this concatenating is not the best approach.
Common Lisp can read and print using strings.
**Just print to a string output stream, created by`WITH-OUTPUT-TO-STRING`**:
(defun convert-text-to-array-string (stream)
(with-output-to-string (out-stream)
(write-string "#2A(" out-stream)
(loop for line = (read-line stream nil nil)
while line
do
(write-string "(" out-stream)
(write-string line out-stream)
(write-string ")" out-stream))
(write-string ")" out-stream)))
When returning from `WITH-OUTPUT-TO-STRING`, the form returns the string resulting from the output done to the stream.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "multidimensional array, common lisp"
}
|
Why `0.4/2` equals to `0.2` meanwhile `0.6/3` equals to `0.19999999999999998` in python?
I know these are float point division. But why did these two formula behave differently?
And I did some more investigation, the result confusing me even more:
>>>0.9/3
0.3
>>>1.2/3
0.39999999999999997
>>>1.5/3
0.5
What's the logic here to decide whether the result is printed with one decimal place or more?
PS: I used python3.4 to do the experiment above.
|
Because the exact values of the floating point results are slightly different.
>>> '%.56f' % 0.4
'0.40000000000000002220446049250313080847263336181640625000'
>>> '%.56f' % (0.4/2)
'0.20000000000000001110223024625156540423631668090820312500'
>>> '%.56f' % 0.6
'0.59999999999999997779553950749686919152736663818359375000'
>>> '%.56f' % (0.6/3)
'0.19999999999999998334665463062265189364552497863769531250'
>>> '%.56f' % 0.2
'0.20000000000000001110223024625156540423631668090820312500'
>>> (0.2 - 0.6/3) == 2.0**-55
True
As you can see, the result that is printed as "0.2" is indeed slightly closer to 0.2. I added the bit at the end to show you what the exact value of the difference between these two numbers is. (In case you're curious, the above representations are the exact values - adding any number of digits beyond this just adds more zeroes).
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 0,
"tags": "python, floating point, floating accuracy, ieee 754"
}
|
How to use multiple mics while streaming on twitch local
Me and my family have been streaming some games on our Xbox One but we've only been able to get one mic working. Is there a way to make it so all of us can be heard on stream? We tried all getting into a party but still only one works. I know a capture card would work but I was hoping for a cheaper solution. Any ideas would be helpful.
|
Twitch will only capture audio for the microphone that belongs to the player that logged into twitch, respectively the player that started Twitch. As only one account can be logged in at a time, that is the one the sound will stem from.
There is a functionality to co-stream on Xbox One, I think using Mixer. You might want to give it a try.
|
stackexchange-gaming
|
{
"answer_score": 2,
"question_score": 1,
"tags": "xbox one, twitch"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.