INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Combine multiple Map<String,List> structs by joining lists with keys of the same name
What would be the cleanest way to do this?
I have
Map<String, List<String>> map1 = ...;
Map<String, List<String>> map2 = ...;
Map<String, List<String>> map3 = ...;
The maps all have the exact same keys, and no duplicate values. I want to append the Lists of map2 and map3 to the end of the list of map1, for each key.
This is how I am currently trying to do it:
Map<String, List<String>> conversions = new HashMap<String, List<String>>();
List<String> histList = new ArrayList<String>();
for(String key : map1.keySet()){
histList.addAll(map1.get(key));
histList.addAll(map2.get(key));
histList.addAll(map3.get(key));
conversions.put(key,histList);
}
|
If you don't want to make a temporary list, you could directly add to list one, instead of replacing it.
for (String key: map1.keySet()) { //iterate over all the keys
map1.get(key).addAll(map2.get(key)); //add all the values in map 2 to map 1
map1.get(key).addAll(map3.get(key)); //add all the values in map 3 to map 1
}
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 8,
"tags": "java, dictionary, java 8"
}
|
what is the difference in bitcoin core between ? getblocktemplate or generatetoaddress?
What is the difference between
bitcoin-cli getblocktemplate '{"rules": ["segwit"]}'
and
bitcoin-cli generatetoaddress 11 "myaddress"
as I understand both are for mining?
What's the best option for solo mining bitcoin core wallet without extern miner software?
like in the past `set generate true`.
any help would be appreciated
|
> what is the difference between:
>
> bitcoin-cli getblocktemplate '{"rules": ["segwit"]}'
This implements the GBT protocol, specified in BIP21, for letting mining hardware and (in practice, mostly) pool software communicate with Bitcoin Core.
It outsources the mining computation to software/hardware external to Bitcoin Core. It is the only practical option for mining BTC on mainnet today.
> and
>
> bitcoin-cli generatetoaddress 11 "myaddress"
This is a slow, unoptimized, test-only, simplistic way of constructing a block directly by Bitcoin Core. It will mine 11 blocks, with whatever transactions Bitcoin Core knows about in its mempool, and pay out the proceeds to the specified address.
It is only practical to use this on test networks, like testnet and regtest. On mainnet it would _literally_ take a billion years before it found anything.
> what's the best option for solo mining bitcoin core wallet without extern miner software.
Don't.
|
stackexchange-bitcoin
|
{
"answer_score": 1,
"question_score": 0,
"tags": "bitcoin cli, solo mining"
}
|
Read multiple text file in single dataframe
I'm trying to read multiple text files into a single DataFrame in Pyspark and then apply the show() but getting the error in second file path.
`BUYERS10_m1 = spark.read.text(Buyers_F1_path,Buyers_F2_path)`
BUYERS10_m1.show()
Py4JJavaError: An error occurred while calling o245.showString.
: java.lang.IllegalArgumentException: For input string: "s3a://testing/Buyers/File2.TXT"
Does anyone have any idea why I'm getting this error and how to resolve it ?
|
Following should work.
spark.read.text("s3a://testing/Buyers/File{1,2}.TXT")
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python 3.x, apache spark, pyspark"
}
|
Netty 4 ChannelInboundMessageHandlerAdapter
Which methods of class ChannelInboundMessageHandlerAdapter will actually get called when this class has been instantiated and connected to a pipeline? obviously messageReceived is (as was the case in Netty 3). What about the other methods listed on its documentation?
Must an implementation override any of its other methods other than messageReceived in order to process messages?
|
You only need to override messageReceived to process messages. You "can" override others if you want some "special" handling.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "netty"
}
|
Is it possible to add a version number to a file that will be visible in Properties/Details in windows explorer
I have an unmanaged C++ project where I am writing data to a custom file format that I have defined.
What I would like to know is if there is a way to add a header that is compatible with Windows Explorer so that a version number will be displayed, as in the example below showing a Windows font.
!Example
The purpose of this is so that non-tech savvy users could simply right click and identify the version of the file, without having to open it in Notepad etc.
Any help would be appreciated.
Tom
|
You cannot achieve this for a file in general. But if your file format stores a version information, you can teach the Windows Explorer to display it.
You have to write a _Shell Extension_ for the Explorer, that can extract arbitrary information out of your files. This extension must be installed on the target computer and registered in the registry.
An excellent guide on how to write and register Shell Extensions can be found here on CodeProject. (Part VIII should cover what you need)
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 5,
"tags": "c++, windows"
}
|
Python - compare previous row value and fill upwards when max is reached
I have this dataset:
col1 = [1,2,3,4,5,6,7,8]
col2 = [2,3,5,1,4,3,4,5]
df = pd.DataFrame({'Column1': col1, 'Column2': col2})
Column1 Column2
1 2
2 3
3 5
4 1
5 4
6 3
7 4
8 5
I am trying to get it so when the Column2 has stopped increasing that it fills the previous values so the expected output would be:
Column1 Column2
1 5
2 5
3 5
4 4
5 4
6 5
7 5
8 5
I tried doing this by a for loop comparing the previous to the current, but this would require lots of for loops. Is there an efficient way of doing this?
|
`groupby` increasing stretches and `transform` with the `last` value:
df['Column2'] = (df.groupby(df['Column2'].diff().lt(0).cumsum())['Column2']
.transform('last')
)
output:
Column1 Column2
0 1 5
1 2 5
2 3 5
3 4 4
4 5 4
5 6 5
6 7 5
7 8 5
intermediate to define the group:
df['Column2'].diff().lt(0).cumsum()
0 0
1 0
2 0
3 1
4 1
5 2
6 2
7 2
Name: Column2, dtype: int64
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "python, pandas, dataframe, for loop"
}
|
Recursive function acts weird in php
I got stuck when I learned about recursive functions in PHP. I know recursive function are those which are being called by itself. My code is:
function addition_no($x,$y) {
if($x==0) {
return $x;
}
return addition_no($x+$y);
}
echo addition_no(1,2);
When I tried executing this code I get:
> Warning: Missing argument 2 for addition_no(), called in /web/com/13978781902261/main.php on line 6 and defined in /web/com/13978781902261/main.php on line 2
What i need is to add two numbers via recursion.
|
I created this code in order to summarize values in an array using recursivity is:
<?php
//values to add
$add = array(5,4,4,6,7);
function addval($add,$pos) {
if($pos == 0) {
return $add[0];
}
else {
return $add[$pos] + addval($add,$pos-1);
}
}
//last position in vector
$last_position = count($add)-1;
echo addval($add, $last_position);
?>
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "php"
}
|
Sql statement to prevent duplicates added to the database of a web site
I have created this code in order to register users in my database. What I cannot manage to do, is to prevent adding the same user again and again. Here is my code:
connectDB();
$safe_fullname = mysqli_real_escape_string($mysqli,$_POST['fullname']);
$safe_email = mysqli_real_escape_string($mysqli,$_POST['email']);
$safe_password = mysqli_real_escape_string($mysqli,$_POST['pass']);
$addStatement="Insert into Users (Fullname,Email,Password,Is_Admin) values ('".$safe_fullname."','".$safe_email."','".$safe_password."','N')";
$result = mysqli_query($mysqli,$addStatement) or die(mysqli_error($mysqli));
|
Add unique to you table for (if it is meant to be unique) email or Username column:
ALTER TABLE Users ADD UNIQUE (Email);
OR
ALTER TABLE Users ADD UNIQUE (Username);
This way database only accepts one record with same email address or Username.
Other way to do this, is to select values from DB with given details. For example, let's use Email column:
$res = mysqli_query($mysqli, "SELECT Email FROM Users WHERE Email = '{$_POST['email']}'");
if(count($res) > 0) {
//exists => do stuff
} else {
//doesn't exist => do stuff
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -3,
"tags": "php, mysqli"
}
|
how to generate thumbnail image of a video using flowplayer?
We can use a png image as the first screen of a video. Can flowplayer generate or create an image based on the video and use it as thumbnail image?
|
As far as I know, it can't. This is caused by the fact, that Flowplayer is a player. The better practice is to get the thumbnail in another way (maybe as described here in Flowplayer docs) and display it as splash image (described here in Flowplayer docs) or as first item of a playlist (described here in Flowplayer docs).
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "flowplayer"
}
|
Hide high value chips
I get it is totally unethical.
Can you hide high value chips in the bottom of a stack out of view?
|
Must be visible at all times, you can get a penalty for hiding them. You'll get a warning normally first but you will get a penalty if you keep hiding them in most places. In general I'll ask a player once to move their large chips out in front of their stack, after that I'll call floor if they don't.
You as a player have the entitlement to know what size stack you're against, just as much as the other players have that same entitlement. Not exact size, but a solid estimate, i.e. if you're stack is 200,000 but someone counts 190,000 fine. But imagine you had say 8 or 10 25k chips behind that stack, that's not fair to the other player. By hiding your higher value chips you're potentially unfairly effecting someone's decision.
|
stackexchange-poker
|
{
"answer_score": 11,
"question_score": 7,
"tags": "rules"
}
|
Calling @afterThrowing advice from catch block for printing thrown exception
We are using Spring AOP with Log4j for logging in our application. I have implemented @Before, @After, @AfterThrowing advice in the application. But I am facing following issue :
When any exception gets caught in catch block then it does not invoke @AfterThrowing advice for printing error stack trace.
public void create() throws Exception
{
try
{
throw new NullPointerException();
}
catch(NullPointerException ex)
{
// want to call any advice for printing ex.printStackTrace();
}
}
I want to print "error stack trace" for the exception caught in catch block. Means whenever any exception occurs in try block and caught by catch then some advice should get called for printing error details.
Thanks in advance !!!
|
Spring AOP can only intercept method executions, so if you catch the exception in the method it won't reach the interceptor. You can advise exceptions being thrown in AspectJ, I believe (using the `handler()` pointcut designator).
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "java, spring, exception, log4j, spring aop"
}
|
ModuleNotFoundError: No module named 'icalendar' google Cloud
.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "windows phone 7"
}
|
Start and End Dayof a selected date
I am trying to get the start and end day of a selected day. I have used moment-timezone.js but I am only getting the start and end of today using this
start = moment().tz('America/New_York').startOf('day').unix();
end = moment().tz('American/New_York').endOf('day').unix();
I dont know how to get the start and end of a given date, such as 01/03/2018 I have tried this
start = moment().tz('01/03/2018','MM/DD/YYYY','American/New_York').startOf('day');
but it gave me this error:
> Moment Timezone has no data for 01/03/2018. See <
|
According to Moment Timezone docs, the correct usage is:
start = moment.tz('01/03/2018', 'MM/DD/YYYY', 'America/New_York').startOf('day');
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, timezone, momentjs"
}
|
Unable to retrieve email folders on specific mail server.. possible causes
I am failing to retrieve the folders of my email account using ImapX:
ImapX.ImapClient m_ImapClient = new ImapX.ImapClient( ImapServerAddress, (int) ImapServerPort, System.Security.Authentication.SslProtocols.Ssl3, false);
m_ImapClient.Connect();
m_ImapClient.Login( EmailAddress, EmailPassword);
//the two functions above each return true
//this last statement throws an exception:
ImapX.Collections.FolderCollection vFolders = m_ImapClient.Folders;
and that is:
'm_ImapClient.Folders' threw an exception of type 'System.NullReferenceException' ImapX.Collections.CommonFolderCollection {System.NullReferenceException}
What's wrong, I'm using IMAP, ssl, port 993. ImapX 2. This works for imap.google.com on 993, but doesn't work for another network server.. Any ideas of why this could happen?
|
This issue has been fixed, thank you! For details see Issue: Unable to get mail folders after successfull login on IMAP server. The problem occured on parsing the information returned by the IMAPX server about folders. Some servers do not quote the folder names.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "c#, .net, imapx"
}
|
What's the effect of standby (spindown) mode on modern hard drives?
I just assembled a new Linux file server with several Samsung HD103UJ 1TB hard drives and I am currently optimizing it.
The question I can't find an answer to is: is it reasonable to set a spindown timeout (with hdparm -S) for the drives? Can the spindown/spinup be harmful to the disk in the long run?
My previous file server did not have this timeout and the hard drives have been operational for 3+ years with no problems (always on) so I am not sure if I need this optimization at all.
What are your thoughts on this?
Thanks!
|
I'm by no means expert on disk drive physics, but I see disproportionally many hard drives fail soon after the spinup. Probably the temperature change just does not serve them well. I would say: let them spin forever.
|
stackexchange-serverfault
|
{
"answer_score": 16,
"question_score": 28,
"tags": "hard drive, hdparm"
}
|
Best way to handle cue points in an audio file (from microphone)
I'd like to record audio from a microphone and I'd like the user to be able to add cue points during the recording so when he loads the file afterwards, he can jump easily to a specific position.
I don't really know what file format I should use and how to store the metadata (cue points)
I thought about
1. encoding a wav/mp3 and stores metadata in a .cue file (easy to do but 2 files to store)
2. storing XMP data in a mp3 file (seems a bit harder but standard metadata embedded in 1 file)
3. flv/f4v with audio only and standard cue points but I'm not sure I can create them directly from the client
What do you think?
|
Did you know that the WAV file format supports embedded CUE chunks?
The spec says:
The <cue-ck> cue-points chunk identifies a series of positions in
the waveform data stream. The <cue-ck> is defined as follows:
<cue-ck> -> cue( <dwCuePoints:DWORD> // Count of cue points
<cue-point>... ) // Cue-point table
<cue-point> -> struct {
DWORD dwName;
DWORD dwPosition;
FOURCC fccChunk;
DWORD dwChunkStart;
DWORD dwBlockStart;
DWORD dwSampleOffset;
}
For a WAV file with a single data chunk (the standard), fccChunk should be "data", chunkStart and blockStart are 0, and SampleOffset is the sample you want to mark.
This might be the most portable way to record your cues.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "flash, air, metadata, microphone"
}
|
advance url rewriting
how can i change
<
to
<
i have google it but not found any ans...please help me...
i am using apache server with unix
|
You should use mod_rewrite. Add to your .htaccess file those lines:
RewriteEngine On
RewriteBase /
RewriteRule ^\s+\.php\?key=(\d+) \?k=$1
Read about mod_rewrite and RewriteRules here: <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -2,
"tags": ".htaccess"
}
|
Hide woocommerce-message in couple seconds
I tried to use this code to hide woocommerce-message but it doesn't work.
setTimeout(function() {
$('.woocommerce-message').fadeOut('fast');
}, 5000); // <-- time in mseconds
Do you any another solutions ? I tried to put this code into header.php and my template has space for Custom Header JavaScript Code but nothing works.
|
This worked for me.
setTimeout(function() {
$('.woocommerce-message').fadeOut('fast')
}, 5000);
If you're using wordpress, try
setTimeout(function() {
jQuery('.woocommerce-message').fadeOut('fast')
}, 5000);
This link may help you as well: jQuery | on click fade out and / or automatically fade out
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "javascript, php, html, wordpress, woocommerce"
}
|
Uninstall NVidia drivers?
I've upgraded from 10.04 to 10.10 (in order to be able to upgrade to 11.04).
It seems like the current graphics drivers are incompatible with the latest kernel I have. I don't know if I have installed drivers only from apt or if I have downloaded. I think it's only apt thou.
How do I uninstall all Nvidia drivers and revert to the default drivers? I've used at least 2 different multi monitor setup utilities, but it was last year so I don't remember much.
What config files do I need to change so that the default drivers works?
|
Try renaming the xorg.conf file and reboot:
sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.nvidia
To remove the drivers:
sudo apt-get purge nvidia-settings nvidia-current
|
stackexchange-askubuntu
|
{
"answer_score": 6,
"question_score": -1,
"tags": "upgrade, xorg, nvidia, apt, uninstall"
}
|
How to count item in list<int>, which match with a value (true/false) in all records in another table in c# (better than with linq)
I have data as below:
!image
I also have list int `list Int = new List<int>(new int[] { 1, 2, 3, 13, 102 } );`
So, how to count elements in list int, what have `value == "AnswerId"` and have "`IsCorrected == true`" in picture table data by linq?
The result will be 3.
|
I hope I understood your question correctly and you're looking for how to query this using LINQ on something line EF. You can use the following where MyTable is the table name and IsCorrected property is a boolean.
var count = dbContext.MyTable.Count(p=> Int.Contains(p.AnswerId) && p.IsCorrected);
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "c#, .net, linq"
}
|
Unsigned 32 bit integers in Javascript
How can I emulate 32bit unsiged integers without any external dependencies in Javascript? Tricks with `x >>> 0` or `x | 0` don't work (for multiplication, they seem to work for addition / subtraction), and doubles lose precision during multiplication.
For example, try to multiply 2654435769 * 340573321 (mod 2^32). The result should be 1.
This answer has multiplication. What about addition / subtraction / division?
Here's a link to wolfram alpha, presenting the equation above.
|
A 32-bit unsigned int fits within Javascript's 64-bit float \-- there should be no loss of precision when performing addition, subtraction, or division. Just mask with `0xffffffff` to stay within a 32-bit integer. Multiplication goes beyond what fits, but you already have a solution for that.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 9,
"tags": "javascript, integer, unsigned integer"
}
|
wildcard, generic in java
I get a compile time error on countList method.
public static void countList( List<? extends Number> list, int count ){
for( int i = 0; i < count; i++ ){
list.set(i, i-1);
}
}
public static void clearList( List<?extends Number> list){
list.clear();
}
It says: The method set(int, capture#2-of ? extends Number) in the type List is not applicable for the arguments (int, int)
What does this error message mean? Why can't I set the elements in the list? Why is it OK to clear the list?
|
Because it's a list of "Something that extends number, but I don't know what." You can't go just putting integers in there, what if it's actually a list of doubles?
List<Double> list = new ArrayList<Double>();
list.add(Double.valueOf(4.5);
countList(list, 1);
Double d = list.get(0); //what happens here? You put an Integer in there! class cast exception
You can clear the list because for that operation it doesn't matter which subtype of Number is actually in there. clear is clear is clear.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "java, generics"
}
|
Don't reload Activity orientation change but still reload Fragments
Im using a MainActivity with a few Fragments.
In the Activity I connect to a server.
I used: `android:configChanges="orientation|screenSize"` in my Manifest.
So that the Activity keeps the connection on orientation change.
But now I cant use different layout for port/land (Fragments).
Is there a way to force the Fragments to reload on change without the Activity reloading?
|
You need to move your network operations outside of the Activity/Fragment lifecycle so that your Activity and Fragments can work as intended and you can have long running network operations that aren't interrupted by Activity and Fragment lifecycles. Remember that Activities and Fragments are meant to be dynamic, have narrow concerns, etc. They're not designed for network operations. That's why there's SO much emphasis on using background threads for various things and why there are Services. For example, you could use an IntentService to handle your network operations. Here's an example of how to your Activity would deal with resuming/updating information when configuration changes happen: <
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "android, android fragments, screen orientation, android configchanges"
}
|
Formulas not updating if the other work book is closed
I have the below formula which makes reference to another workbook in the same folder but when the file is open it just works fine, the problem is when the other excel file is closed because the formula wont get updated
Formula when the other workbook is open
=IFERROR(COUNTIFS(Auto_Zero.xlsx!MonthDB,B6,Auto_Zero.xlsx!CSRDB,C2),"")
Formula when the other file is closed
=IFERROR(COUNTIFS('C:\Users\csamayoa\Desktop\QA
Test\Auto_Zero.xlsx'!MonthDB,B6,'C:\Users\csamayoa\Desktop\QA
Test\Auto_Zero.xlsx'!CSRDB,C2),"")
I have tried a lot of different suggestions and the formula does not wok when the other file is closed :(
|
Excel Functions like COUNTIFS and SUMIFS does not recalculate when referenced to closed workbook. You could try using Excel Query Designer which work like ADO codes. Allows retrieval from closed books, db etc. Hope this helps.
the simplest way to achieve this without using advanced tools will be to use the code below to open the file, do the calculation and close the file back. Not sure if this help. Please change the 'H:\My Documents\4674576.xlsx' to your source file path. Paste this code in new module of your excel workbook. run the code and see if this helps.
` Sub loadfileandCalc() Dim acWb As Workbook Dim wb As Workbook Set wb = Workbooks.Open(Filename:="H:\My Documents\4674576.xlsx", UpdateLinks:=False, ReadOnly:=True) Set acWb = ActiveWorkbook ActiveSheet.Calculate Set acWb = Nothing wb.Close False Set wb = Nothing
End Sub `
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "excel, excel formula"
}
|
take characters after spaces in java
I have a string and it has two words with 3 spaces between them. For example: `"Hello Java"`. I need to extract "Java" from this string. I searched for regex and tokens, but can't find a solution.
|
All you have to do is split the string by the space and get the second index since Java is after the first space. You said it has 3 spaces so you can just do:
string.split(" ")[1];
In your case, if string is equal to Hello Java with three spaces, this will work.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "java, regex, string, token"
}
|
Pandas Cumsum skip rows
I have a dataframe like the following.
idx vals
0 10
1 21
2 12
3 33
4 14
5 55
6 16
7 77
I would like to perform a `cumsum` (and avoid a `for`) but only considering rows with the same `idx` `mod 2`. For instance, for row 3 I would like to obtain `21+33=54`, while for row 4, `10+12+14 = 36`.
Any ideas?
|
You just need `groupby` here
df.vals.groupby(df.idx%2).cumsum()
Out[75]:
0 10
1 21
2 22
3 54
4 36
5 109
6 52
7 186
Name: vals, dtype: int64
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 3,
"tags": "python, pandas, cumsum"
}
|
How do I calculate the flag that a coset of $SL(n) \backslash B$ stabilzes?
Let $SL(n)$ be the special linear group of rank $N$ and $B$ a borel subgroup. It is known that the quotient group $SL(n) \backslash B$ is a flag variety of complete flags: < I understand how the "standard" borel subgroup of upper triangular matrices will stabilize the "standard flag".
My question is, given a coset in $SL(n) \backslash B$, say $xB$, how do I compute the flag that it represents?
Thank you very much.
|
Here is an alternative to Claudius' description in the comments. A coset $xB$ has a stabilizer $xBx^{-1}$ which is a conjugate of the Borel. Everything I'm about to say about this conjugate can be checked by checking it for the standard Borel $B$ itself.
This conjugate of the Borel fixes a unique $1$-dimensional subspace $V_1$ of $\mathbb{C}^n$; this is the first space in the flag. This induces an action on $\mathbb{C}^n/V_1$, which again fixes a unique $1$-dimensional subspace, corresponding to a $2$-dimensional subspace $V_2 \supseteq V_1$; this is the second space in the flag. Etc.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 2,
"tags": "linear algebra, algebraic geometry, lie groups"
}
|
java.lang.InterruptedException while running a batch file
I am trying to run a batch file which has set of services I want to restart. When I call this batch file from my Java application I get Interrupted Exception.
My batch file
call net stop app-service
call net start app-service
call net stop ui-service
call net start ui-service
call net stop custom-app
call net start custom-app
call net stop MSSQLSERVER /Y
call net start MSSQLSERVER
My java code to run the batch file
File file = new File(System.getProperty("user.dir") + File.separator + "restart.bat");
String time="cmd /c "+file.getAbsolutePath();
Process p = Runtime.getRuntime().exec(command);
int exitvalue = p.waitFor();
I'm getting the following error
java.lang.InterruptedException
at java.lang.ProcessImpl.waitFor(ProcessImpl.java:451)
What am I doing wrong?
|
Looks like the problem is with the batch file. Calling stop and start immediately is what's causing the issue. Make sure the SQL server and services are stopped, then start the server and those services.
Please check this answer:
Stop and Start a service via batch or cmd file
> Use the SC (service control) command, it gives you a lot more options than just start & stop.
>
> DESCRIPTION: SC is a command line program used for communicating with the NT Service Controller and services. USAGE: sc [command] [service name] ...
>
>
> The option <server> has the form "\\ServerName"
> Further help on commands can be obtained by typing: "sc [command]"
>
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java, multithreading, batch file, interrupted exception"
}
|
SlickGrid selection issues on sort
When using SlickGrids `selection` and `sorting` together I found that the selection is storing the index of the selected rows rather than storing the selection for the data you selected.
How can I fix this so that the selected data is remembered instead of just an index?
* * *
A demo of the issue can be found here: <
> To reproduce the issue take the following steps;
>
> 1. Select the first item in the grid
> 2. Sort on name
>
|
You need to call `dataView.syncGridSelection(grid, true)`.
See <
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 5,
"tags": "javascript, sorting, datagrid, selection, slickgrid"
}
|
How to add variable by variable value type?
I have a data.frame with varibale _job_ with levels - Manager, Supervisor, SelfEmployed, Official, Highly professional employee, Low skilled worker, Unskilled worker. I want to add new column with variable class where will be value 1 for high _class_ workers and 2 for low class workers.
Data.frame will be like:
head(df)
# Job Class
# Manager 1
# Supervisor 1
# Low skilled worker 2
# Low skilled worker 2
# Unskilled worker 2
# Manager 1
|
In `base R` you can use:
df$Class <- ifelse(df$Job %in% c("Manager", "Supervisor"), 1, 2)
`dplyr` solution:
df <- df %>%
mutate(Class = ifelse(Job %in% c("Manager", "Supervisor"), 1, 2))
`data.table` solution:
setDT(df)
df[, Class := fifelse(Job %in% c("Manager", "Supervisor"), 1, 2)]
Data:
df <- tribble(
~Job, ~Class,
"Manager", 1,
"Supervisor", 1,
"Low skilled worker", 2,
"Low Skilled worker", 2,
"Unskilled worker", 2,
"Manager", 1
)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "r"
}
|
Closing all jquery dialog windows in JavaScript
How does one close all jquery ui dialog windows in javascript?
Situation:
The page has multiple things that can be opened using the dialog boxes. I need a way to close all previous windows before opening a new one.
|
They all have the `.ui-dialog-content` class, so select by that and close them, like this:
$(".ui-dialog-content").dialog("close");
|
stackexchange-stackoverflow
|
{
"answer_score": 94,
"question_score": 40,
"tags": "jquery ui, jquery ui dialog"
}
|
How to create a smooth black and white texture without jaggies?
The following code creates a random black and white texture with ugly jaggies (pixelized "stairs") all around the shapes, because of the `Binarize` command. I could add a final `Blur` or `GaussianFilter` to remove them, but the result is too blurry. How can I modify that code to get nice smooth shapes, without bluring it?
randomTiles = Table[{RandomReal[], RandomReal[], RandomInteger[{0, 1}]}, {n, 1, 1000}];
Binarize[Blur[ListDensityPlot[
randomTiles,
InterpolationOrder -> 0,
Frame -> False,
PlotRangePadding -> 0,
ImageSize -> {400, 400}
], 10]]
Preview of what this code is doing:
 : vector size cannot be NA`
`In addition: Warning message: In nx * ncoef : NAs produced by integer overflow`
Unfortunately, I cannot upload the dataset and unfortunately, you could not replicate my code. Instead, I'll try to explain my code as much as I can:
Below is the code that I run to fit a natural spline fit:
fit.temp <- lm(y ~ ns(x,knots = seq(1, nrow(data), by = 10)),data = data)
In my dataset, x is a sequence from 1 to the number of rows in data which is 424742.
I know this question is somewhat a vague question, but after spending a lot of energy, I didn't have any luck figuring out what this error is and how to solve it.
Thanks very much,
|
Somewhere within the code, it is trying to multiply two integers but the result is greater than the maximum integer that can be stored on your machine (`.Machine$integer.max`).
Without delving too much into the code, your inputs must be too big for this tool. Either work with a smaller `data`, or fewer knots by increasing the `by` argument to `seq`. Roughly, `(nrow(data)^2 / .Machine$integer.max` should give you a lower bound on how big `by` should be.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -2,
"tags": "r, splines"
}
|
Deserialize float number into a 'float' type instead of default 'double' in Json.NET
Actually, the question is in the title already. Providing more details, I have to specify that I know about a custom converters and would like to avoid this scenario. I hope may be there is a _setting_ which I can use to tune serializer for using `float` instead of `double` by default.
For example, we can use `FloatParseHandling.Decimal` for same purpose to use `decimal` instead, but not for `float`.
The model, which I expect to deserialize into:
public class Figure
{
public float SideA { get; set; }
public float SideB { get; set; }
public float SideC { get; set; }
}
|
There is no problems when deserializing. Show your code
#r "nuget:Newtonsoft.Json/13.0.1"
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
var json = "{ \"num\": 1.5 }";
var jAnon = JsonConvert.DeserializeAnonymousType(json , new { num = 0.0f }); // Use anonymous type
var jClass = JsonConvert.DeserializeObject<Json>(json); // use class
var jObj = JObject.Parse(json);
var value = jObj.GetValue("num");
value.Value<float>(); // use JObject
class Json {
public float Num {get;set;}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c#, floating point, json.net"
}
|
Integrate SFDC with our personal websites
We do not have SFDC Devs in our environment; we will be utilizing our webmaster for this integration execution. I hope to guide him from an administrator perspective, but I have little knowledge of integrations and plenty admin skills.
Could you please guide me with some information I should present in our initial meeting of expectations and how to's and requirements in order to integrate our SFDC to sync from our private website that data is entered to sync once submitted. (Ideally would like information to sync both ways)
|
Salesforce provides **REST API** which can be used to integrate Salesforce with any external system. It all depends what is your existing language. Salesforce also provides SDK for different languages such as PHP, JAVA, .NET
You can check Example section of REST API to understand how easy it is to create, update, delete records in Salesforce using REST API.
<
If you want to send data out of Salesforce you can also do httprequest callout which can post data to your external webservice once any record created/update inside Salesforce.
You can also use external ID concept of Salesforce which can work as primary key between your external system and Salesforce.
Using the Lightning connector you can show external system data on real time basis inside Salesforce.
You can also use Streaming API for your requirement.
Salesforce work in multitenant architecture it has some limit so you should opt your option wisely.
here are the resource for API limits
<
<
|
stackexchange-salesforce
|
{
"answer_score": 1,
"question_score": 0,
"tags": "integration, website integration, sync, data synchronization"
}
|
JUNIT запуск тестового класса
При запуске тестового класса перед каждым методом создается новый экземпляр этого класса. Почему? {
logAnalyzer = new LogAnalyzer();// если я коментирую эту строку то второй тест должен быть красный
logAnalyzer.initialize();
}
У меня постоянно создается новый экземпляр LogAnalyzer, потому что при запуске второго метода создается новый экземпляр TestLogAnalyzer. На скринах показал
|
Библиотека Junit предполагает, что тесты являются независимыми друг от друга. Создание нового экземпляра класс для каждого метода позволяет гарантировать. Подробнее можно посмотреть здесь < или в книге JUnit in Action, Third Edition. Возможно, вам поможет аннотация @BeforeClass, <
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java, junit"
}
|
How to access RTF field in popup aspx page?
I am customizing the ribbon toolbar and adding a button to it.Whenever I click on that button,it will open a aspx page allows authors to select some data- onclick of submit button (in popup aspx page) data gets appended to the existing RTF field content.
Our requirement is to replace the portion of the content where the cursor is positioned, with the selected data in the aspx page. Please let me know which object should be used? Can we access it through $display.getView().getItem()? Is that information will be present in the "component model object", if so share us the pointers?
Early response will be appreciated.
Thanks in advance.
|
The function that triggers the popup to open should have a "target" parameter. The target has an "editor" property. You should be able to use the editor to do what you propose. editor.applyHTML will insert HTML at the cursor location. There should be a method that allows you to replace a selection rather than just insert - it might even be the same method, have you tried it?
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, asp.net, tridion"
}
|
Can't a PHP file be stored in .html extension? I've heard that .php is not supported by some browsers i'm not sure What might be the remedy for this?
This is my sample Hello World program. Which din't work with .html extension but it is working with the . php extension.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns="
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<div>
<?php echo 'Hello World!!' ?>
</div>
</body>
</html>
Is it possible to save this file with .html extension? and is it true that some of the browsers doesn't support .php files?
|
PHP is server side languages it has nothing with browser image below explain how php works
!enter image description here
Image source and good read
Normally use just **`.php`** extension
|
stackexchange-stackoverflow
|
{
"answer_score": 10,
"question_score": 5,
"tags": "php, html"
}
|
How to rename all files which end with ".BAK"
I have a windows file system where a hiccup in our backup software renamed hundreds of files.
The change looks like this:
"ABC.PDF" -> "ABC.PDF.BAK"
This happened to some, but not all files in a directory.
I would like to rename such files to their old name, but the script should output or ignore cases where this is not possible, because a "ABC.PDF" already exists.
I am not familiar at all with batch scripts, but powershell is available too.
|
You can do something like this in powershell:
$files = dir *.BAK
foreach($file in $files) {
Rename-Item $file $file.BaseName -ErrorAction Ignore
}
There will only be an error if those files no longer exist, or if you are trying to overwrite a file.
If you want to see what it will do first, add the -WhatIf flag.
|
stackexchange-superuser
|
{
"answer_score": 1,
"question_score": 0,
"tags": "powershell, cmd.exe, batch rename"
}
|
When a Row is deleted how Can I delete all associated rows in other tables? LARAVEL 5.4
I wrote this function but wondering if there's a "laravel" way to do the same functionality?
I want to delete all the rows in my other tables that are related to the row I'm deleting.
$id = 6;
$query = "SELECT TABLE_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME = 'exercise_id'";
$tables = DB::select($query);
foreach ($tables as $table) :
$rows = DB::table($table->TABLE_NAME)
->select($table->COLUMN_NAME)
->where($table->COLUMN_NAME, '=', $id)
->delete();
endforeach;
|
This would typically be done with cascading deletes on the foreign keys when modifying the schema.
See < There, the docs state:
> You may also specify the desired action for the "on delete" and "on update" properties of the constraint:
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
PS: This approach is not neccesarily limited to laravel (laravel way of doing it)
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "laravel"
}
|
Update JTable when Data changes
The question might been answered already and I read many similar ones but doesn't work for me. So I have my `JTable` with Custom Table model that extends `DefaultTableModel`. My data is `Object[][] data` and Column Names `String[] columnNames`. So when my data changes how do I update the table? I have been using `tableModel.setDataVector(data, columnNames)` and it is working but it resets my custom cell renderer to default. Thanks.
|
Don't change the Arrays! The DefaultTableModel will copy the data from the Arrays to the internal storage used by the DefaultTableModel.
Instead, you need to change the TableModel directly by using the `setValueAt(...)` method of the JTable or the TableModel. The TableModel will then notify the table that changes have been made.
> I have been using `tableModel.setDataVector(data, columnNames)` and it is working but it resets my custom cell renderer to default
If you need to recreate the entire TableModel for some reason then you can use:
table.setAutoCreateColumnsFromModel( false );
AFTER you create the table using a TableModel the first time. Now the next time you use the `setDataVector(...)` method the `TableColumnModel` of the table will NOT be recreated which means you won't lose the custom renderers.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "java, swing, jtable, tablemodel"
}
|
How to get GoogleSheet_ID to use it in 'google_drive' gem
I have user `google_drive` gem, Using oAuth2 I have received the access_token details too. But while I am going to fetch content of one of my google sheet, I found error notfound as like below :
notFound: File not found: 1s-APBHuCQLhvAFUeAQyFpyJJiNwyy_ZenQUe91WDru0
Below is my code :
session = GoogleDrive.login_with_oauth(@client) // @client is my googleAuth Object
sheet = session.spreadsheet_by_key("1s-APBHuCQLhvAFUeAQyFpyJJiNwyy_ZenQUe91WDru0").worksheets[0]
My Sheet URL is : `
Please help me out to find Google Sheet Id.
|
I think the ID you are using is correct, maybe other reason is causing this issue.
If you check the Google Drive API error,
> 404: File not found: {fileId}
>
> The user does not have read access to a file, or the file does not exist.
>
> Suggested action: Report to users that they do not have read access to the file or that the file does not exist. Tell them that they should ask the owner for permission to the file.
Maybe you are missing some authorization scopes. Try to use the full permission with this.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "ruby on rails, api, google drive api, google sheets api"
}
|
Setting variable to substring of itself for query
I have a query I am using to return values:
DECLARE @ VALUE varchar(1000) = 'ACELLA PHARMA [A200]'
select
a.item_id,
attr_vals = concat(a.attr_val, ' ', quotename(b.attr_val))
from
ndc_attr as a
left outer join
[NDC_ATTR] b
on b.field_id = 144
and a.field_id = 225
where
b.attr_val is not null
and b.attr_val like '%' +@ VALUE + '%'
The thing is I need the value within the parenthesis: A200 in this example.
I have tried to break up the query by adding an if statement in it:
if @VALUE like '%[%' and @VALUE like '%]%'
begin
SET @VALUE = SUBSTRING(@VALUE, CHARINDEX('[', @VALUE) + 1, LEN(@VALUE) - 1)
end
But oddly, the full string is returning ('ACELLA PHARMA [A200]').
How can I break up this value so only the string within the brackets is on @VALUE?
|
If you want the part in the _square_ braces _and_ the values look the the example, then here is a shortcut:
select replace(stuff(@value, 1, charindex('[', @value), ''), ']','')
I am not sure what the query has to do with the question, but the sample logic can be applied in a query, of course.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "sql, sql server"
}
|
listview in android activity
I have a table as **contents** name. In content table there are 4 field : `id,lable,des,typ`.
`content` table is used for poems data.
`id` is filled by Integer and it's **PrimaryKey**.
`lable` is label of poem.
`des` is full description of poem .
`type` is type of poem and it filled by "old" or "new".
Now , I'm going to display lables as listview when typ is equal "old" then I want to click on its each node and starts a new activity . I hope in new opened activity display des of poem .
(I can create a listview for a specific data and display them and start a new activity when I click on its node BUT I can't display des of poem in new activity)
How can I do it ?
|
One solution, you can search for the des with the id of the lable that was clicked before you start the second activity. The des you can easily forwarded to the second activity.
Intent i=new Intent(context, Poem.class);
i.putExtra("des", yourDes);
context.startActivity(i);
Second activity (in the onCreate method):
Intent intent = getIntent();
String des = intent.getStringExtra("des");
more defenseve:
Bundle extras = getIntent().getExtras();
String des;
if (extras != null)
{
des = extras.getString("des");
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "android, listview"
}
|
How to find out my user id?
Ok so I got the Stack Overflow addon for Firefox (and the Gnome Panel Applet) and I just realised my UserID is not the same as Username, its a numerical value. How can I find this to make sure I have the correct stats?
The way I know it is a numerical value
1. Open Prefrences of AskUbuntu Firefox Addon
2. Look at the User ID field, there is a one.
3. Try typing in letters... It won't work
|
Click on your profile and look at the URL: meta.askubuntu.com/users/ **2733** /russjr08
Your user ID is **2733**.
|
stackexchange-meta_askubuntu
|
{
"answer_score": 4,
"question_score": 5,
"tags": "support, add on, user accounts"
}
|
Show/Hide TR Angular
I have two `<TR>` as in the example below, I need to add a button on the first `<TR>` when pressed to show / hide the TR son.
Can somebody help me.
<tr ng-repeat-start="categoria in vm.categorias track by categoria.id">
<!-- content -->
</tr>
<tr ng-repeat-end ng-repeat="categoriaAux in categoria.hijos track by categoriaAux.id">
<!-- content -->
<tr>
|
Here's a working fiddle <
<table>
<tr ng-repeat-start="categoria in vm.categorias">
<td>categoria {{categoria.id}}</td>
<td>
<button type="button" ng-click="showCategoria = !showCategoria">Show/Hide</button>
</td>
</tr>
<tr ng-hide="showCategoria" ng-repeat-end ng-repeat="categoriaAux in categoria.hijos">
<td>categoriaAux: {{categoriaAux}}</td>
</tr>
</table>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "angularjs"
}
|
Vue js "this" is overridden with image.onload "this"
I have a vue app. I use `this.data` to access it's data variables and methods.
In a certain method I have to use img.onload to get the width of an image. But there are 2 " **this** " now and vue js methods and variables are not working now. I need an alternative solution so both will work.
vueMethod(url) {
var img = new Image();
img.onload = function() {
this.size = {this.width,this.height} //size is a vue variable
}
img.src = url;
}
|
You could assign `this` to a variable called `vm` before calling `img.onload` function as follows
vueMethod(url) {
var img = new Image();
let vm = this;
img.onload = function() {
vm.size = { this.width, this.height } //size is a vue variable
}
img.src = url;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 5,
"tags": "javascript, node.js, vue.js, vuejs2"
}
|
Replacing string based on line number
I have a situation where i want to replace a particular string in many files
Replace a string **AAA** with another string **BBB** but there are lot of strings starting with AAA or ending in AAA ,and i want to replace only one on line 34 and keep others intact.
Is it possible to specify by line number,on all files this string is exactly on 34th line.
|
You can specify line number in sed or NR (number of record) in awk.
awk 'NR==34 { sub("AAA", "BBB") }'
or use FNR (file number record) if you want to specify more than one file on the command line.
awk 'FNR==34 { sub("AAA", "BBB") }'
or
sed '34s/AAA/BBB/'
to do in-place replacement with sed
sed -i '34s/AAA/BBB/' file_name
|
stackexchange-unix
|
{
"answer_score": 138,
"question_score": 82,
"tags": "sed, awk"
}
|
What are these commands for?
Yesterday I had to install a Windows with its Grub override.
Well, it's not the first time I had to fix Grub, so I used LiveCD, mounted the root partition (I don't have boot, just `/` and `home`) and ran `grub-install --root-directory=/mnt/ /dev/sda`. However, it didn't work.
After Googling a while I found a tutorial in which instead of just mounting the Linux partition, he also did `mount --bind /mnt/dev /dev` and `mount --bind /mnt/proc /proc/`. After that `chroot` to `/mnt` and then installed Grub, and using this method, it worked.
What are the `mount --bind` commands for? I'm familiar with the usage of `--bind used` (man page) but I do not know why it was used on this example.
|
`proc` and `sys` filesystems are provided by the running kernel -- when the kernel is not running, they cease to exist. This means that when you chroot into another operating system, these filesystems are not present. Many programs expect them to exist so that they can function, for example, they may require information about the running system, or want to modify the way the kernel handles something. It is often enough simply to provide `/proc` and `/sys` from the current kernel for these programs to work as expected.
A symlink would not suffice, as the act of chrooting would invalidate the file paths used. In Linux, you also cannot hard link directories (other than `.` and `..`, as provided by `mkdir`). This means that a third option has to be used to mirror these filesystems to the chrooted environment -- bind mounting. A bind mount is provided by the kernel directly, and works as expected within a chroot.
|
stackexchange-unix
|
{
"answer_score": 10,
"question_score": 9,
"tags": "linux, mount, grub2"
}
|
ADT design choices
How do you go about deciding which of the following two representations (in F# syntax) is the right choice in a particular situation?
type Choice = A of string | B of string
Or:
type ChoiceKind = A | B
type Choice = { Kind: ChoiceKind; Value: string }
I'm deliberately avoiding giving a more specific example, as either approach can "feel more natural" in a particular scenario; I'm interested in the general reasoning that goes into the design choice.
|
In my opinion the former makes more sense if there's not much you can sensibly do without knowing whether you have an `A` or `B`. If you wanted to unconditionally get the string with the former declaration, you'd end up with redundant cases in the pattern match. Of course, you could easily write a function to do it.
I would imagine the latter is easier for other .NET languages to work with since they lack pattern matching, but you can fake it well enough in C# using named arguments and lambda expressions.
Disclaimer: I've never coded in F# but I'm familiar with Standard ML, which is related (through OCaml).
|
stackexchange-softwareengineering
|
{
"answer_score": 2,
"question_score": 1,
"tags": "design, algebraic data type"
}
|
Delete Takes a Long Time
I've got a table which has about 5.5 million records. I need to delete some records from it based on date. My query looks like this:
DELETE FROM Table WHERE [Date] between '2011-10-31 04:30:23' and '2011-11-01 04:30:42'
It's about 9000 rows, but this operation last very long time. How can I speed it up? Date is type of datetime2, table has int primary key clustered. Update and delete triggers are disabled.
|
It's very possible that [Date] is being cast to a string on every row resulting in a sequential scan of the entire table.
You should try casting your parameters to a date instead:
DELETE FROM Table WHERE [Date] between convert(datetime, '2011-10-31 04:30:23') and convert(datetime, '2011-11-01 04:30:42')
Also, make sure there's an index on `[Date]`
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "tsql, sql server 2008r2 express"
}
|
How to make a batch file differentiate numbers
I don't know if I worded this right, but how would I make a batch file differentiate numbers?
For example; In my code, I have a string of code:
IF %var% GTR 0 && LSS 3
When I launch it, it loads the variable and then crashes. I discovered that it was this command causing the prompt to crash.
I want to tell whether if or not a number is greater than 0 and less than 3. For example, 2.
|
This will still error if %var% is empty, so you can add a test for that also.
IF %var% GTR 0 IF %var% LSS 3 echo %var%
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "batch file"
}
|
Integral limits of polar coordinate transformation
In an integration exercise, I need to find the volume of the region bounded by the paraboloid $z=x^2+y^2$ and below by the triangle enclosed by the lines $y=x$, $x=0$, and $x+y=2$ in the $xy$-plane.
Here is the illustration of $xy$-plane and the standard solution:
^2+(r\cdot sin\theta)^2]\cdot|J|~drd\theta=\iint_R r^3~drd\theta $$
I think the limits of $\theta$ should be $\frac{\pi}{4}\sim\frac{\pi}{2}$, but I'm not sure what are the inner limits. Thanks for helps.
|
You're doing it right, well done!
For the limits, as you said, $\theta$ goes from $\dfrac{\pi}{4}$ and $\dfrac{\pi}{2}$. For $r$, some drawing helps:. For the highest value, you see in the drawing that $\cos\alpha=\dfrac{\sqrt{2}}{r}$ so $r=\dfrac{\sqrt{2}}{\cos\alpha}$, and you have $\alpha=\theta-\dfrac{\pi}{4}$...
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 2,
"tags": "integration"
}
|
Google map widget custom data
in Google Documents on some spreadsheets you have that world map widget/plugin that you can give country codes and frequencies and it'll generate a heatmap of the world with that data?
Can anyone suggest something similar to use in Grails? Obviously googling "Google Map" gives a million and one things about the actual Google Maps API, etc.
Thanks!
|
Found it from a friend- it's referred to as a 'Geochart',
<
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "grails, maps"
}
|
Trouble with auto import React component when using vscode 1.28
Recently I don't know why auto import suggestion doesn't work as it used to. For example I want to auto import component, as I hit enter when the suggestion list appears, it only show this:
<import('./components/CourseList').CourseList
instead of `<CourseList />` and import line
EDIT: after reinstall VSC 1.26 it works again but it doesn't work on 1.28
|
You are running into this bug. It should be fixed early next week by VS Code 1.28.1.
As a workaround, upgrade the version of typescript that VS Code uses by following these instructions
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "reactjs, visual studio code"
}
|
What are wettable flanks in semiconductor packages?
What are wettable flanks? Is there any difference between packages with wettable flanks and other leadless packages?
. In contrast, non-wettable lands are basically LGA type joints, and must be x-rayed.
|
stackexchange-electronics
|
{
"answer_score": 6,
"question_score": 2,
"tags": "pcb, diodes, surface mount, semiconductors, packages"
}
|
ASP.Net MVC 4, kendo UI Scheduler customize add edit popup
I'm new to to Kendo UI and currently struggling to find a way to customize the add edit popup. And help and guidance is appreciated.
Thanks.
|
There are two ways to customize the edit form
1. Override it completely via the editor.template option
2. Customize the existing one by handling the edit event.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "asp.net mvc 4, kendo ui"
}
|
How to use "FB.Canvas.setAutoResize" with the php SDK?
I want to make the scrollbars in my iFrame application disapear. So I checked the "Auto-resize" radio button under "Facebook Integration" and I understand I need to call "setAutoResize" so the canvas will grow to the height of my page.
But I can't find any documentation about the php SDK or explanation of how and where shall I call this function (and on what object). I can only find relevent documentation abput the JS SDK which is very different.
|
You cant do that with PHP SDk (i think) You should use the magic javascript provided by Facebook in order to resize according to the contents :
<div id="FB_HiddenIFrameContainer" style="display:none; position:absolute; left:-100px; top:-100px; width:0px; height: 0px;">
</div>
<script src=" type="text/javascript"></script>
<script type="text/javascript">
FB_RequireFeatures(["CanvasUtil"], function(){ FB.XdComm.Server.init("xd_receiver.htm");
FB.CanvasClient.startTimerToSizeToContent(); });
</script>
<
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php, facebook"
}
|
Can't connect sqlplus hr/hr using Oracle Developer days on OVM VIrtualBox
I want to connect my database with `hr database` in my Oracle Developer Days using Oracle VM VirtualBox. When I connect my database using `sqlplus sys/oracle as sysdba`, It's successful and the status is `OPEN`. But, when I open a new tab, and I put `sqlplus hr/hr on [oracle@localhost ~]$`. It doesn't work, and has a warning `ERROR:ORA-01017: invalid username/password; logon denied`. After that, I can enter the username, but I can't enter the password. And show a warning again (`ERROR:ORA-01017: invalid username/password; logon denied`.) I got the `sqlplus hr/hr` from my lecturer and she can logon with it. Do I missing something?
|
Is the **HR** user created properly?. If not create the user and give all session privileges using the instructions given in this thread :
No usename HR in Oracle 12c.
To know that user exists, u may run this query by logging in dba(as u said: `sqlplus sys/oracle as sysdba`)
select * from all_users where USERNAME='HR' ;
And if you find that the user exists and you are not sure about the password, run
ALTER USER hr IDENTIFIED BY hr ACCOUNT UNLOCK
as sysdba to reset the password to _hr_ . Try logging in after these steps and it should work fine.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "sql, database, oracle, virtualbox, database administration"
}
|
how many processes can be created with python os.fork()
If I do this below:
for i in range(10000):
os.fork()
What's going on? don't consider reaping.. I just wanna know about os.fork() can make how much processes in linux, if it 's just like windows, only can make about 2000 processes, how the next 8000 processes will do?
Thanks.
|
`os.fork()` spawns a new OS-level process. Any limits on the number of those aren't dependent on Python, but on the operating system. According to this previous question, on Linux you can find out about any software-imposed constraints on that by looking at:
cat /proc/sys/kernel/pid_max
but that might be further restrained by `/etc/security/limits.conf`. If those don't hit you first, you will eventually run into problems with available hardware resources - your code is a fork bomb, and type of trivial denial of service attack (any software limits on the number of processes are set to _avoid_ this kind of attack).
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "python, fork"
}
|
each function in javascript for new elements
I have a page with infinite scroll that appends new elements as the user scrolls down. ".product-variation" is one such element. I want to remove the first option of all newly arriving elements. The code below does the job but I think it goes up and down the DOM a bit too much - retarding performance in the process. Is there a better and more efficient way of removing the first option of just the newly arriving elements?
The first option of all newly arriving element is always '' and that's what I am trying to remove.
jq(".product-variations").each(function(){
var fresh_variant = jq(this).find("option:nth-child(1)").val();
if(fresh_variant == '')
{
jq(this).find("option:nth-child(1)").remove();
}
jq(this).trigger('change');
});
|
I'd put a flag :
jq(".product-variations:not([data-set])").each(function(){
var fresh_variant = jq(this).find("option:nth-child(1)").val();
if(fresh_variant == '')
{
jq(this).find("option:nth-child(1)").remove();
}
jq(this).trigger('change');
jq(this).attr('data-set',1);
});
So now , when you add item , you set a flag "set".
Next time , you scan only new ones.(who don't have the flag)
Oh , and BTW here is a better version of your code :
jq(".product-variations:not([data-set])").each(function(){
var $this=jq(this);
var $opt=$this.find("option:nth-child(1)");
var fresh_variant = $opt.val();
if(fresh_variant == '')
{
$opt.remove();
}
$this.trigger('change');
$this.attr('data-set','whatever');
});
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "javascript"
}
|
If $x<y$ then $\exists\, M \in \mathbb{N}$ such that $\frac{1}{n}<y-x\;\forall\; n>M$
I am wondering how I would
Prove for every pair of positive integers $x$ $y$ where such $x<y$ there exist a natural number $M$ such that if $n$ is a natural number and $n>M$ then $\frac{1}{n}<(y-x)$
So I did $y>x$ so then $y-x>0$
let $M=\frac{1}{y-x}+1$ and I guess you could use floor function on the $\frac{1}{y-x}$
So then if $n>M>\frac{1}{y-x}$ then $1/n<\frac{1}{y-x}$
not sure if this proof is ok.
|
You're on the right path. Just choose $M \in \mathbb{N}$ such that $M>\frac{1}{y-x}$ (existence is guaranteed by Archimedean property).
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "calculus, solution verification"
}
|
Can 'trains' be used as a synonym for 'postponement'
Was solving a cryptic crossword clue recently which reads
> Coaches for postponement (6)
The answer is 'trains' obvious from coaches , but dont get the postponement reference. The solution mentions
> Trains = postponement (collective noun)
Is this correct? Or is it even a synonym reference or something else?
|
I think they might be having a little fun by suggesting that the collective noun for trains is _a postponement_ as in
> A postponement of trains
I'm not sure if it is the proper collective noun for trains, but it's quite amusing. I found one reference in wiktionary where they say the collective noun for trains is `A postponement, cancellation of trains` and another here A compendium of collective nouns, Woop Studios
_Coaches for camels (6)_ might have been better because the collective noun for _camels_ is _train_.
> A train of camels
|
stackexchange-english
|
{
"answer_score": 3,
"question_score": 2,
"tags": "meaning, nouns, synonyms, collective nouns"
}
|
Java Play 2.2 doesn't support javaagent
With previous version of the Java Play framework, we could provide a command line argent to load monitoring agents. For example, NewRelic could be loaded as
./path/to/start -javaagent:/path/to/newrelic.jar
With the release of the 2.2, the Play team has significantly changed the start script. From what I can tell, it no longer supports javaagents. Has any else gotten NewRelic running with Java Play 2.2+? Play is great, but its useless tech if you can't monitor it in a production environment...
|
It seems that you can prefix _Java options_ with `-J` (in a manner similar to _system properties_ using `-D`):
$ bin/<app> -J-javaagent:lib/newrelic.jar
Discovered this while poking around in the script itself but it is noted in the usage summary:
$ bin/<app> -h
Usage: [options]
...
-J-X pass option -X directly to the java runtime
(-J is stripped)
...
|
stackexchange-stackoverflow
|
{
"answer_score": 14,
"question_score": 9,
"tags": "playframework, newrelic, playframework 2.2"
}
|
Interviewed for dream job, bad written test: how can I recover?
Recently, a recruiter from my dream company reached out for an interview.
I showed my interest and he responded with two emails 3 days back, one with an online programming test and the other asking for things like the reason for the change, current salary, and expected salary etc.
I attempted the online interview test and it didn't go well. I did it half correct. I haven't replied to the other email yet.
What can I do to salvage the situation after that bad test attempt? Is it professional to write an email with salary expectations (asked in the other mail), which are in the upper range of the company, when I was not able to perform well in the test?
|
The recruiter made two requests of you: take this test, and answer these questions. The poor test result might doom your application, but you have an opportunity left to make a positive impression regardless. If you don't respond you won't get the job -- not only did you do poorly on the test but you failed to follow through on the other part. It sounds like you want this job, so why not spend a little time on a response instead?
Answer his questions. Acknowledge the test score and, if you can do it without making excuses or lying, say in a sentence or two why you hope he'll still consider your application. Maybe you have some specialized skill that is interesting to them, for example.
Don't burn bridges with someone who can affect your prospects (not just now but if you should re-apply in a year or two). Not answering his questions is burning bridges. As long as you're answering anyway, do any _credible_ damage-control that you can. It can't hurt and it might help.
|
stackexchange-workplace
|
{
"answer_score": 14,
"question_score": 5,
"tags": "software industry, recruitment"
}
|
how to tell if a hypothesis is plausible based on a small p value
 is very small? and thus its highly probable that h1 is true and it is out of calibration?
|
The $p-$value for a test of $H_{0} : \mu = \mu_{0}$ against the alternative $H1 : \mu \neq \mu_0$ is the probability, under $H_0$, that the variable you are looking for takes a value at least as extreme as your observed data, hence a small $p-$value means you have a small probability to get more extreme values, hence your observed data is big(or small, depending on the null hypothesis).
But assuming the null hypothesis, you usually want to impose some behaviour on the random variable - for example make it follow the normal distribution or the $t-$distribution, hence smaller $p-$values are problematic since your observed data is big(small).
Not sure that helped since is a bit general, but think of $p-$values as indicators whether your observed data is big(or small) which means it's not as you would expect them to be
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "probability, hypothesis testing"
}
|
SAML handler instantiated on non-SAML authentication requests
I am using the Sustainsys SAML library along with IdentityServer4 for Okta authentication, and have a working setup. However, I notice that the Saml2Handler is being instantiated for non-SAML authentication requests (even though it does not act on those requests because ModulePath does not match).
It is a concern because I intend to support multiple Okta instances, and it feels wasteful to hit the handler when it is not required. Is this expected behaviour for this SAML library, or for handlers in general?
Currently I create a scheme per-customer, with the handler as an argument. This is set up on first request for the customer rather than in startup. Thanks
|
The handler need to check if the incoming request is a response for its endpoint (Acs, Logout or Metadata). As far as I know all handlers work this way.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "asp.net core 2.0, identityserver4, sustainsys saml2"
}
|
BGP regular expression .+_.+_.+_.+_.+_.+_.+_.+_.+_.+_.+_.+
could anyone tell me what `ip as-path access-list 100 deny .+_.+_.+_.+_.+_.+_.+_.+_.+_.+_.+_.+` stands for?!
I searched over the internet for the meaning of this regular expression, but I was unable to find any info.
|
Every time you see `.+_`, that regular expression represents a single BGP autonomous system. This as-path list denies BGP as paths equal to or longer than 12 paths long.
The regular expression works because `.` represents any character, `+` is a wild card which optionally repeats the previous character an unlimited number of times, and `_` represents the space between the autonomous system paths. For more information, refer to the Cisco IOS Regular Expression guide, or this INE BGP Regular Expressions blog.
|
stackexchange-networkengineering
|
{
"answer_score": 18,
"question_score": 14,
"tags": "cisco, routing, router, bgp, acl"
}
|
How to optimize performance of sequential condition checks in Java?
I am writing a program that looks for a solution of a diophantine equation. The program is cycling
for (int d = 0; d <= max; d++) {
for (int c = 0; c < d; c++) {
boolean possibleSolution = true;
possibleSolution =test1(c,d);
if(possibleSolution) {possibleSolution =test2(c,d);}
...
if(possibleSolution) {possibleSolution =test30(c,d);}
if(possibleSolution) solutionFound(c,d);
}
}
My `testN` methods are reasonably optimized. Most solutions are removed by a simple `test1`, but program has to run 30 pointless `if(possibleSolution)` checks. Is there a way to directly go to a new cycle of the `testN` yields `false`. Can a `try ... catch` block or some similar structure be adopted for this purposes?
|
Based on your question `break;` will NOT work for you. You want to skip all further steps in this cycle, do `c++` and go for a new round. This is done using `continue`. Break will end inner cycle do `d++` and start inner cycle from 0.
|
stackexchange-softwareengineering
|
{
"answer_score": 1,
"question_score": 1,
"tags": "java, performance, conditions"
}
|
Why does the command 'apt install php' try to install Apache?
I'm trying to install WordPress + LEMP on my Ubuntu 18.04. I have no interest in installing Apache. Why does the PHP installer assume I do?
|
According to this answer on AskUbuntu: How to install php without Apache webserver?:
> Ubuntu package details says `php` (`php7.2`) depends on `libapache2-mod-php7.2` OR `php7.2-fpm` OR `php7.2-cgi`.
>
> It seems to default to the first package, which itself depends on `apache2`. But if you install one of the latter first, and `php` afterwards, `apache2` will not be installed.
If you're using nginx, you probably want:
sudo apt install php php7.2-fpm
|
stackexchange-serverfault
|
{
"answer_score": 24,
"question_score": 18,
"tags": "nginx, php, apt, ubuntu 18.04"
}
|
Jquery / Javascript - Turn <br> inside div to line break?
I have little problem after sanitizing the content. I'm using laravel 4 and it's {{{ }}} way to sanitize user input when printing it out in view. However I'd like to allow br tags so users could use it as a line break
I did try few examples which I found from stackoverflow but they did not work. such as:
$('.myclass').html().replace(/(<br \/>)+/g, "\n");
but it has no effect.
So basically I have
<div class="myclass">
<h3>this is <br> description</h3>
</div>
And what I see is:
this is <br> description
And I would need to br tag to simply make a line break instead of br tag showing up in text. Any help how to do this with jquery / javascript?
UPDATE: When I look the page source I see:
<h3>this is <br> description</h3>
instead
|
Ok, sorted it out. This will help for those who might need it in the future:
$('h3').each(function(){
var $this = $(this);
var t = $this.text();
$this.html(t.replace(/<br\s*\/>/g,'<br>'));
});
I used h3 instead of div class because using the class seems to remove the css from it.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "javascript, jquery"
}
|
Java regex to match (group of words) subclass of (group of words)
I would like to write a regular expression in Java to match a sequence of word characters and spaces followed by the sequence of characters "subclass of" a sequence of word characters and spaces:
Example strings which should be matched:
a subclass of b
a and b subclass of c
a and b subclass of c and d
The following strings should not be matched:
subclass of
a subclass of
subclass of b
a subclass of b subclass of c
I tried the following regex:
[a-zA-Z0-9 ]+subclass of[a-zA-Z0-9 ]+
(?:(?!subclass of).)+subclass of(?:(?!subclass of).)+
but they both fall short of what I need.
|
You can use this regex:
^\\w+(?:\\s+and\\s+\\w+)?\\s+subclass\\s+of\\s+\\w+(?:\\s+and\\s+\\w+)?$
Here is the Live Demo:
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "java, regex"
}
|
Generating random number of N-digits using gmpy2 library in Python
I want to generate a random number of N-digits using `gmpy2` library in Python. I know that it is possible to do this using `random` library, but using `gmpy2` is a requirement.
**mpz_random()** function generates a random number from 0 to N-1. I am not sure how to use this library to get a random number of length N, e.g., N=100.
**INPUT:** N (the number of digits)
**OUTPUT:** A random integer of length N
**EXAMPLES:**
| INPUT | OUTPUT |
| ------- | ------- |
| N=1 | 8 |
| N=2 | 80 |
| N=4 | 3224 |
**My current code is:**
import gmpy2
n = 100
rs = gmpy2.random_state(hash(gmpy2.random_state()))
p = gmpy2.mpz_random(rs, n)
print(p)
|
You should specify the minimum, and maximum number of random numbers given N as follows:
**Code:**
# conda install -c conda-forge gmpy2
def get_ranged_random_integer(rand_min, rand_max):
import gmpy2
rs = gmpy2.random_state(hash(gmpy2.random_state()))
return rand_min + gmpy2.mpz_random(rs, rand_max - rand_min + 1)
def get_random_intger_of_N_digits(n):
rand_min = 10**(n-1)
rand_max = (10**n)-1
return get_ranged_random_integer(rand_min, rand_max)
if __name__ == '__main__':
n = 100
p = get_random_intger_of_N_digits(n)
print(f"[main] length: {len(str(p))}, random: {p}")
**Result:**
[main] length: 100, random: 2822384188052405746651605684545963323038180536388629939634656717599213762102793104021248192535427134
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, random, gmpy"
}
|
Disjoint balls on Euclidean space
I'm doing some self-study and I'm stuck on a proof. Prove that if two open balls on $N$-dimensional Euclidean space are disjoint then $d(x,x') \ge r + r'$
$x$ and $x'$ are the centers of the balls, $r$ and $r'$ are the radii, and the distance between $x$ and $x'$ is given by:
$d(x,x') = \sqrt{ (x_1-x'_1)^2 + (x_2-x'_2)^2 + ...(x_N - x'_N)^2 }$
Also, $x$ and $x'$ are distinct points.
|
HINT: Look at the line segment $S$ with endpoints $x$ and $x'$: $$S=\Big\\{\alpha x+(1-\alpha)x':\alpha\in[0,1]\Big\\}\;.$$ When $\alpha=0$, you get $x'$; as $\alpha$ increases towards $1$, the point moves along $S$ towards $x$, reaching $x$ at $\alpha=1$. When $\alpha=\frac12$, the point is midway between $x$ and $x'$. Let $p_\alpha=\alpha x+(1-\alpha)x'$; show that
$$d(p_\alpha,x')=\alpha d(x,x')$$ and $$d(p_\alpha,x)=(1-\alpha)d(x,x')\;.$$
Now suppose that $d(x,x')<r+r'$. Show that there is an $\alpha\in[0,1]$ such that $d(x,p_\alpha)<r$ and $d(x',p_\alpha)<r'$, and conclude that $p_\alpha\in B(x,r)\cap B(x',r')$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 2,
"tags": "real analysis, general topology"
}
|
Why is my radiator hissing?
I've never had a radiator before, all central air for me, but I'm living in an apartment that has them now. All of the radiators in my apartment have been hissing, and pouring out steam from the "valve" on the side. I'm not sure what the "valve" is or even if it's a valve, but it seems to relieve pressure and it's not always on when the radiator is so I'm guessing there is an 'on' and 'off' position. Here is a a wikipedia picture of one that has the same type of "valve":
!radiator with valve on side
My questions are as follows:
* Should it be hissing? (it's really loud)
* Is there anything I can do to make it quieter?
* If there isn't, would an unorthodox solution, such as putting something that allows air through over the "valve" be safe? I've used a wet sponge for short periods when it really annoys me.
|
This is basically going to be landlord work unless you plan playing heating technician and checking the basement pipes. Here's the gist:
* Air vents on the radiator must flow air out so it can be replaced by steam to heat. They sometimes have adjustment valves on them so you can balance the system.
* Air vents that are producing a lot of noise are either
* too small of a vent
* **clogged up / broken** (this is you because you're leaking steam)
* Improperly designed systems can also push a lot of air out of the radiators. The steam delivery pipes should also have air vents on them before the radiators.
When working properly, those **air valves should not let steam through**. They should close when the steam reaches them, and open when there isn't steam. If there are showing visible steam, they need replacement.
I found this to be a good article on caring for steam vents that will provide more detail.
|
stackexchange-diy
|
{
"answer_score": 12,
"question_score": 9,
"tags": "radiator, steam"
}
|
Transition between 3 ImageViews placed one after another
I am working on an application which shows the Most recent active users in group. It is being shown by 3 ImageViews having the display images of the users. When a new user other than one in the present 3 becomes active he must be shown in the first imageview with FadeIn animation and the last one must be fadeout. the other two must be shifting to next Imageviews. I want to know how should I make a transition animation between those ImageViews.
Edit : Images are not bigger ones. This will be similar to fb messenger. When ever a new user becomes active his image must be displayed with the above transition.
 to save an Adobe Premiere Pro project file so that it's compatible with an older version of the software? The scenario I have is that I use Adobe Premiere Pro CS5.5 but I need to send project files for editing to someone who only has CS3.
|
I dont know of any software for Premiere that can do this (there are plugins for After Effects but cant find any for Premiere - thats not to say they arent out there).
I think your best option would be to **export your sequence as an XML**. You will loose any CS5.5 features there are not in CS3, but this would occur regardless of which method you use to get the project into CS3.
> 1. Choose File > Export > Final Cut Pro XML.
> 2. In the Save Converted Project As dialog box, browse to a location for the XML file, and type a file name.
> 3. Click Save.
>
* * *
|
stackexchange-avp
|
{
"answer_score": 4,
"question_score": 11,
"tags": "software, premiere"
}
|
Can you keep your feet warm in ski boots on a very cold day?
After a few ski trips in slightly painful hire boots, I decided to buy a pair that would fit properly. After trying quite a lot of pairs, I eventually found some that fitted well all over my foot, which fit with either one thick pair of socks, or two thin ones. I've generally gone for one thick pair. For most of my current trip, they've been amazing, making skiing easier, avoiding painful feet, and keeping my feet toasty.
However, today it was a lot colder, especially on the higher runs, and my toes got very cold (almost painfully). Without buying a second pair that'd be big enough for two thick pairs of socks just for the odd very very cold day, is there anything that can be done to avoid cold feet on very cold days skiing?
|
You have several options for keeping your toes warm, but ultimately, toes are going to get cold on really cold days... it is just part of the fun.
Try the following:
* Unbuckle your boots while riding up a lift (or stoppping to rest in the back-country) -- this allows circulation to more freely access your toes.
* Wiggle your toes within your boots to keep the blood flowing
* Err on thinner socks to keep the amount of insulating area in your boots at its maximum. Cramming more fabric into your boot is counter-intuitively a bad idea.
* Try boot coozies. (I was just gifted a pair, but haven't tried them. I'll post here if if/when my pride can allow me test them...)
* Pocket hand/toe warmers contain different chemicals/powders that can create heat when activated. Try placing these _inside and the back of your thigh along your arteries_ to warm the blood heading to your toes.
* For the truly desperate: electric boot warmers
|
stackexchange-outdoors
|
{
"answer_score": 9,
"question_score": 10,
"tags": "boots, skiing"
}
|
Create jar with fix name excluding version using gradle
I want to create a `fat jar` using `gradle` only with name, not include a version of the project.
I am using `gradle 5.1` and `spring boot 2.1.1`.
I have tried the following solutions with no luck
1. <
2. <
* Default jar name `project-0.0.1-SNAPSHOT.jar`
* Expected jar name `project-xyz.jar`
|
I found the solution, finally!
`jar { archivesBaseName="project-name" project.version="" }`
I have also tried with `version` instead of `project.version`. But, it's not working anymore in gradle 5.1 as it is deprecated as per the documentation.
<
`archivesBaseName` changes only the prefix name, not remove the version from the jar name.
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 4,
"tags": "spring boot, gradle"
}
|
Why hydrogen emission spectrum is discrete?
It is generally known that the emission spectrum of hydrogen is discrete, which is usually explained as follows: when a photon is emitted, the atom jumps to a lower energy eigenstate, the energy difference being the energy of the emitted photon.
However, energy eigenstates are not the only quantum states an atom can be in, since any linear combination of those is a pure state as well (provided we take care of normalization). So, my question is: **why cannot a hydrogen atom jump from an excited $2s^1$ state to a linear combination of $1s^1$ and $2s^1$, emitting a photon with some random energy, provided that the expectation of total energy is still the same?**
I feel that this has something to do with the measurement problem & wavefunction collapse, yet I cannot grasp what is going on.
|
In the case where the atom transition into a superposition of two separate energy levels, the photon will also be in a superposition, corresponding to the two states with different energies. However these energy-differences will still be discrete. Once measured, only one of the energy-differences will be detected.
Over a statistical ensemble (such as of many different hydrogen atoms) you will get a lot of values that correspond to different measurement results. But a discrete set.
In a realistic situation, of course, the levels are not sharp but rather 'smeared' due to interactions etc. What you get is a statistical distribution that correspond to the density of states of the ensemble, which has peaks around the energy differences of the hydrogen atom energies.
|
stackexchange-physics
|
{
"answer_score": 2,
"question_score": 1,
"tags": "quantum mechanics, energy, wavefunction collapse, photon emission"
}
|
How to push() data in array in once
if ($file_extension == "xlsx") {
include("excel/PHPExcel.php");
include("excel/Excel2007.php");
$objPHPExcel = PHPExcel_IOFactory::load($_FILES['filename']['tmp_name']);
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
foreach($sheetData as $row) {
//// How to put all cells in array in one shot because we can not assign each like $row['A'] ,$row['B']
array_push($array, strval($row['A']));
//row A2;
//array_push($array,strval($row['B']));
//etc...
}
}
How to put All Cells in an array without specifying name for each?
Because it's very difficult to write `$row['A']`, `$row['B']`, `$row['C']` ...... For Each.
How to put all data in an array without assigning names of rows?
|
You can merge the arrays
$array = array_merge($array, $row);
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, arrays, excel"
}
|
The intersection of open sets contains a closed subset.
> Prove that if $F=\\{x\\}\subset\mathbb{R}^n$, there exist open sets $U_1,U_2,\ldots$ such that $F = U_1\cap U_2 \cap \cdots$.
Thoughts so far: from the definition of any open set we know for any $U_i$ there is a open ball of radius $r$ around every vector $a \in U$ (i.e.$B_r(a)\subseteq U$). Secondly from the nested interval theorem the intersection of nested intervals is non-empty. I am not sure how to combine these two theorems.
|
Let $(X,d)$ be a metric space, $x\in X$, and $F=\\{x\\}$.
_Remark_ : In your case, $X=\mathbb{R}^n$ and $d(x,y)=|x-y|$ is the absolute value distance between numbers. If you get confused by the use of $d$ below, simply replace instances of $d(x,y)$ with $|x-y|$.
**Definition** : $B(v;r)=\\{w \in X\colon d(v,w) < r\\}$ is the open ball of radius $r$ centred at $v$.
**Claim** : there exist open sets $U_1,U_2,\ldots$ such that $F=U_1 \cap U_2 \cap \cdots$.
_Proof_ : Let $U_n = B(x;1/n)$ for each $n \geq 1$. By the definition of $B$, $x\in U_n$ for each $n \geq 1$. Moreover, for any $v \neq x$, since $d(v,x)>0$, we can find $N$ large enough such that $v\notin U_n$ for all $n\geq N$. Therefore, $v\notin U$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "real analysis, sequences and series"
}
|
Не работают медиа-запросы в sass
Вот пример кода
@media only screen (max-width: 750px)
.ic
display: inline-block
|
Всему виной может быть вложенность... Эта проблема и в less
Смысл такой, если в примере такая конструкция
html, body
width: 100%;
height: 100%;
#wrapper
width: 100px;
height: 100px;
То в css при компиляции записывается так
html, body{
width: 100%;
height: 100%;
}
html, body #wrapper{
width: 100px;
height: 100px;
}
а когда ты задаешь @media
@media only screen (max-width: 750px)
#wrapper
width: 100px;
height: 100px;
что бы изменить только wrapper не слушает медиа
надо дописать в медиа и вложенность
@media only screen (max-width: 750px)
html, body
#wrapper
width: 100px;
height: 100px;
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "css, sass, less, media queries"
}
|
Delete the 2nd to 9th file and loop for a timelapse Python
I have a folder of 1000 photos that I'd like to make a timelapse of. The photos are shot every 60 seconds, and I'd like to make a 10 minute interval timelapse. So I need to delete every 2nd to 9th photo and have it loop. For example, given 1000 photos in a folder, I'd like the script to keep photo 1, 10, 20, 30 and so on and so forth. At the end of this script, the folder should only contain 100 photos.
The following code removes every "10th" photo, which doesn't do exactly as I want:
import os
dir_to_clean = '/Users/myname/Desktop/TBD'
l = os.listdir(dir_to_clean)
for n in l[::10]:
os.unlink(dir_to_clean + '/' + n)
How do I modify this code so that it deletes every 2nd-9th photo? It should still be able to run if the folder does not have an even number of files (e.g. if it has 1005 files).
|
First of all, you should not depend on the underlying OS indexing to do the sorting for you - you should sort the image list yourself (hopefully their names are in a lexicographical order).
Second, once sorted, just enumerate your list and don't delete every 10th item, e.g.:
import os
dir_to_clean = '/Users/myname/Desktop/TBD'
images = sorted(os.listdir(dir_to_clean))
for i, image in enumerate(images):
if i % 10 != 0:
os.remove(os.path.join(dir_to_clean, image))
For an image list like: `["image000.jpg", "image001.jpg", "image002.jpg", "image003.jpg", ... "image035.jpg"]` this will delete all images except `image000.jpg`, `image010.jpg`, `image020.jpg` and `image030.jpg`.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, python os"
}
|
Android - When scanning for bluetooth devices, is my device discoverable?
Quick question, As the title says - Is my device discoverable when it is searching for other discoverable devices?
Thanks
|
Unless you check the box to be discoverable(See your Bluetooth settings) your device will remain stealth during the search .
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "android, bluetooth"
}
|
Why won't <meta http-equiv="refresh" ... /> work? Nothing happens?
I've added a meta refresh to my page, but nothing happens at all. I'm using
<meta http-equiv="refesh" content="0;URL=
I'm in Google Chrome too.
|
It looks like you misspelled "refresh" as "refesh". You need an "r" between f and e.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 0,
"tags": "html, redirect, refresh, meta tags"
}
|
JSF dynamic javascript escape quotes
<a class="btn btn-primary" onclick="myPrintFunction(#{myValue})">
Print</a>
This works fine unless myValue contains an apostrophe.
How do I work around this?
|
Use the JSF utility library OmniFaces already, then you can also just use its of:escapeJS() function:
<html ... xmlns:of="
'#{of:escapeJS(_selectedItem.item.webName)}'
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, jsf, escaping"
}
|
If the Warlord destroys a player's eighth district, does the game still end?
In _Citadels_ , if the Warlord destroys a player's eighth district, assuming no other players have eight districts, does the game still end at the end of the round?
If so, does that player still get the "first to build eight districts" bonus points?
What if on the last round, Alfred finishes eight districts, Betty finishes eight districts, and Charlie Warlords one of Alfred's districts. Who gets what bonus points here? Alfred was the first to build eight districts, but does not _have_ eight districts at the end.
|
I believe the Warlord is not allowed to destroy a building if that person already has 8 built.
|
stackexchange-boardgames
|
{
"answer_score": 12,
"question_score": 4,
"tags": "citadels"
}
|
How do I use sets on the contents of my file to create a list of all the characters used in the file?
I've been struggling to use set to create a list of characters that came from the file.
> myFile = open("WaP.txt")
>
>> > set = ()
after this, I am simply lost.
|
you declare set using `set()` . `set = ()` means you are creating a tuple with name set
myFile = open("WaP.txt")
s = set()
for line in myFile:
for character in line:
s.add(character)
l = list(s) # from set to list
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python 3.x"
}
|
Update Foundation For Email 2 to v2.1?
How do I update an existing Foundation For Email 2 project to v2.1?
In the article about this new version nothing's mentioned about how to actually update an existing project.
|
Edit your package.json file to
“author”: “ZURB [email protected]”,
“license”: “MIT”,
“dependencies”: {
“foundation-emails”: “2.1.0”
},
Afterwards in terminal cd into your project folder and run: `npm update`.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "zurb foundation, zurb ink"
}
|
Solving system of four equations in four unknowns
I have four equations in four unknowns, namely, $w_1,w_2,x_1,x_2$.
$$w_1+w_2=2 \tag{1}$$ $$w_1x_1+w_2x_2=0 \tag{2}$$ $$w_1x_1^2+w_2x_2^2=2/3 \tag{3}$$ $$w_1x_1^3+w_2x_2^3=0 \tag{4}$$
How can I solve the system of linear equations?
* * *
### My attempt:
from Equation $(1)$, $$w_2=2-w_1\ldots(5)$$
from Equation $(2)$, $$w_1x_1+(2-w_1)x_2=0$$ $$\Rightarrow w_1x_1+2x_2-w_1x_2=0$$
|
From your second eqution you get:
$$w_1x_1=-w_2x_2=:c \tag{2}$$
Pluging this into the equation (3) and (4) you get:
\begin{align*} (x_1-x_2)\cdot c&= 2/3 \tag{3}\\\ (x_1+x_2)(x_1-x_2)\cdot c=(x_1^2-x_2^2)\cdot c&= 0 \tag{4} \end{align*}
From this we deduce $(x_1+x_2)=0$ and hence $x_1= -x_2$. Insert this again into (2) we get $w_1=w_2$ and from (1) we get $w_1=1=w_2$ and from (3) $x_1= \pm \sqrt{1/3}=-x_2$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "polynomials, systems of equations"
}
|
Spring boot on Azure produces internal server error
I want to deploy my jar on microsoft azure but it shows me an internal server error. the jar works on my pc fine, i added the following web.config file to my wwwroot:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar ";%HOME%\site\wwwroot\myjar.jar";">
</httpPlatform>
</system.webServer>
</configuration>
Unfortunately it does not work... I want to deploy it on a webApp in azure
|
It was a non-well formated xml file... now it works:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar %HOME%\site\wwwroot\myjar.jar" >
</httpPlatform>
</system.webServer>
</configuration>
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "spring, azure, spring boot"
}
|
How to get filename of a opened file?
I have this simple script that I'm working on. I must admit, I'm totally new to PERL and kinda stuck with this stupid problem.
open(IN, "<def/t.html") or die();
while(<IN>) {
chomp;
if($_ =~ m/FF0000/) {
print "\n".$_."\n";
}
}
So... I opened the t.html and found the given string in the file. Output was ok, but I need also filename of a file in which string was found, to be printed. I really don't know how to return this, and I need it right after the `$_`. Thanks for the help in advance.
|
That is a strange idea, but you can if you want:
$ cat 1.pl
#somewhere in the code
open(F, "f.txt");
my $f = fileno(F);
#here you want to find the filename
open(FILENAME, "ls -l /proc/$$/fd/$f|");
my @fn = split(/\s+/, <FILENAME>);
print $fn[$#fn],"\n";
$ perl 1.pl
/home/ic/f.txt
Here you know only the filedescriptor and find the filename using it.
You can also write it much shorter with `readlink`:
open(F, "f.txt");
my $f = fileno(F);
#here you want to find the filename
print readlink("/proc/$$/fd/$f"), "\n";
I must note that the file can be already deleted (but it exists still if it is open).
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "perl"
}
|
How to check if user inputs are double in C?
Normally I would use something like this:
double value;
if (scanf("%lf", &value) == 1)
printf("It's float: %f\n", value);
else
printf("It's NOT float ... \n");
But this time I need to read two numbers at once
scanf("%lf %lf", &x, &y);
How do I check that?
|
As @SRhm mentioned in the comment section, you simply can use:
scanf("%lf %lf", &x, &y) == 2
to get two numbers from the user input. A quote from scanf - C++ Reference explain the return value of the function:
> On success, the function returns the number of items of the argument list successfully filled.
scanf will return an **integer** representing the number of variables successfully read from the user input.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -2,
"tags": "c"
}
|
Encoding with nsstring
i am developing an iOS application with uses `UIWebView` and `Javascript`. i have a `javascript` function like this :
function(){
....
escape(text);
.....
return text;
}
and in my UIWebView :
NSString *myString = [webView stringByEvaluatingJavascript@"function()"];
this function return to me a string encoded with the javascript function espace, how i can decode this string with objective C ? thanks for your answers
|
To encode a NSString with percent escapes use **stringByAddingPercentEscapesUsingEncoding** e.g..
NSString * escapedString = [unescapedString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
To decode an already escaped NSString use **stringByReplacingPercentEscapesUsingEncoding** e.g..
NSString * unescapedString = [escapedString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
See Documentation for NSString
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "javascript, objective c, ios"
}
|
dictionary with multiple values per key python
I have one dataframe -
ID T Q1 P Q2
10 xy 1 pq 2
20 yz 1 rs 1
20 ab 1 tu 2
30 cd 2 cu 2
30 xy 1 mu 1
30 bb 1 bc 1
Now I need a dictionary with Id as key and rest of the column values as a list to be the dictionary's value
**output** :
{10:['xy',1,'pq',2]}
{20:['ab',1,'tu',2]}
{30:['bb',1,'bc',1]}
**Expected result** :
{10:[['xy',1,'pq',2]]}
{20:[['yz',1,'rs',1],['ab',1,'tu',2]]}
{30:[['cd',2,'cu',2],['xy',1,'mu',1],['bb',1,'bc',1]]}
|
Try:
x = (
df.groupby("ID")
.apply(lambda x: x.iloc[:, 1:].agg(list).values.tolist())
.to_dict()
)
print(x)
Prints:
{10: [['xy', 1, 'pq', 2]],
20: [['yz', 1, 'rs', 1], ['ab', 1, 'tu', 2]],
30: [['cd', 2, 'cu', 2], ['xy', 1, 'mu', 1], ['bb', 1, 'bc', 1]]}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "python, dictionary, nested lists"
}
|
CSS same style for a:link a:visited a:hover a:active, really have to write it all out 4 times
Ho ho,
When working with CSS. If the CSS style is the same for a:link a:visited a:hover a:active does one really have to write it out for times. Working with a custom link.
.DT_compare a:link {
font-family:"Lucida Grande", Arial, sans-serif;
font-size:11px;
line-height:14px;
font-weight:normal;
font-style:normal;
color:#EEE;
text-align:center;
}
Any shortcuts?
Marvellous
|
Just forget the pseudo-classes, and select only `a`:
.DT_compare a {
font-family:"Lucida Grande", Arial, sans-serif;
font-size:11px;
line-height:14px;
font-weight:normal;
font-style:normal;
color:#EEE;
text-align:center;
}
This isn't a very specific selector though; if necessary you can find some other way to increase it so it overrules your `a:hover` and `a:active` selectors, or go with whoughton's answer instead and just specify all four of them.
Then again, if your main hyperlink styles apply to `a:hover` and `a:active` without anything before them, as long as you place your `.DT_compare a` rule beneath them it should work fine.
|
stackexchange-stackoverflow
|
{
"answer_score": 16,
"question_score": 14,
"tags": "css, css selectors"
}
|
How to set a nillable attribute for SOAP::Lite object in Perl?
I'm receiving the following error:
Exception: Error code: , messge: com.sun.istack.XMLStreamException2: org.xml.sax.SAXParseException: cvc-elt.3.1: Attribute ' must not appear on element 'v1:get_list', because the {nillable} property of 'v1:get_list' is false. at ./soap.pl line 42.
This is my Perl code:
my $client = SOAP::Lite
->on_fault( \&faultHandler )
->uri('
->proxy('
# Execute
$client->get_list();
How do I change/add the nillable attribute and how ?
|
_How do I change/add the nillable attribute and how ?_
You use SOAP::Data to create argument for get_list, or for call
Switch to SOAP::Simple , it has better WSDL support `cpan BERLE/SOAP-Simple-0.00_03.tar.gz`
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "perl, soap"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.