INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Do most rookies make a fortune in a bear market by short selling and put options?
A friend warned me not to be over confident in my rookie years buying stocks. He said during a bull market, it is very easy for everyone to look like a winner. Can the reverse be said for rookies that attempt short selling and using put options during a bear market? That is, most rookies can make a fortune short selling and using put options during a bear market?
* * *
EDIT
Or put another way, on average does the ease of success rookies experience investing in a bull market translate equally as well to the ease of success rookies experience using short selling and put option tactics in a bear market? | Your friend's advice is good advice. You should never be over confident in the financial markets regardless of your investment/trading skills and experience.
Yes, you can make a lot of money in a bear market via put buying and/or the shorting stocks and ETFs. But rookies are not likely to do so - unless they get lucky - because they lack the risk management skills to manage the trades. | stackexchange-money | {
"answer_score": 8,
"question_score": 1,
"tags": "shorting securities, put options"
} |
$log_1(x)$ existance
I was looking at the equation $2^x=29$ and I saw that it was the same thing as asking $2=\sqrt[x]{29}$ So $$ 1^x=27$$ but is also $$1=\sqrt[x]{27}$$ I also saw that $\sqrt[x]{27}$ goes to 1 as gets bigger. Which can be expressed as $log_1(27)=lim_{x \to \infty} \sqrt[x]{27}$So does that mean that $log_1(x)$ could exist? | $\sqrt[x]{27}=27^{1/x}$
And
$\lim_{x\to\infty} \frac{1}{x}=0$
So
$\lim_{x\to\infty} 27^{1/x} = 1$
Therefore:
$\nexists x\in \mathbb{R}$ s.t. $\sqrt[x]{27} =1$
Note this follows for any positive real $\gt 1.$ | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "soft question, logarithms"
} |
Awk regex for operators
I want to count and sum number of matches in a file with my awk regex.
The file `file` contains:
Gra pes
gra ndma
straw berry
blue Berry
banana
peanut
school
I need to make a regex for pattern matching, but I am unsure of how to implement **AND/OR** in regex, despite them having same precedence.
I have tried:
awk 'tolower($1) ~ /(gra|straw) (pes|berry)|banana|peanut/ {sum+=1} END {print sum+0}' file
So it should be either `(gra pes, gra berry, straw pes, straw berry) OR banana, peanut` and returns 4, since there are 4 matches.
I'm assuming my syntax went wrong with the **OR** banana|peanut, but I am not sure how to fix it.
Any ideas on what went wrong? thank you | Your regexp is fine. Your problem is that you're matching it on `tolower($1)` which is the _first field_ (blank separated with the default value of `FS`) converted to lowercase.
So for instance, on the first line (`Gra pes`), it would match the regexp against `gra` and fail.
For the whole record, you want `$0`:
awk 'tolower($0) ~ /regexp/ ...'
Also note that regexps are not anchored by default so, it will match on `peanutbutter` for instance as `peanut` is found within. If you want the input record to be matched as a whole by the regexp, you'd need:
awk 'tolower($0) ~ /^(foo|bar)$/'
Which matches on _the beginning of the subject_ (`^`) followed by either `foo` or `bar` followed by _the end of the subject_ (`$`). Note that the parenthesis are important there. `^foo|bar$` would be either `^foo` (`foo` at the start) or `bar$` (`bar` at the end), so would match on `fooX` or `Ybar` for instance. | stackexchange-unix | {
"answer_score": 6,
"question_score": 3,
"tags": "awk, pattern matching"
} |
What is this leafy weed, and how do I get rid of it without harming my vegetable garden?
I bought a house last winter. It has a good size garden in the back which I wanted to plant up. A few weeks ago I went out and dug out a bunch of the weeds pictured below. I dug as deep as possible to get as much of the roots as I could.
The weather started turning cold again, so I waited to plant. The garden is now full of this weed again. What is it and what can I use to kill it? I don't want to affect the growth of the vegetables I hope to plant in the next week or so.
If it helps, I am in Ohio.
_Click on pictures for full size._

translator.translate('Hello') | > From Googletrans 2.3.0 documentation
>
> **Note on library usage**
>
> * Due to limitations of the web version of google translate, this API **does not guarantee that the library would work properly at all times**. (so please use this library if you don’t care about stability.)
> * If you want to use a stable API, I highly recommend you to use Google’s official translate API.
> * If you get HTTP 5xx error or errors like #6, it’s probably because Google has banned your client IP address.
> | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "python, json"
} |
Is there a way to define output folder per file with Dotfuscator?
This is a part of my Obfuscation XML file:
<inputassembly refid="1d9224f1-30bd-49dc-8e3a-30753XY2ed4d">
<option>honoroas</option>
<option>stripoa</option>
<option>library</option>
<option>transformxaml</option>
<file dir="${buildfolder}" name="My.precious.dll" />
</inputassembly>
Is there a way to also define an output folder? Right now, all dlls go to the same output folder. | I don't think there is a solution in Dotfuscator Community, except to wrap the build in your own script that moves the files around. In Dotfuscator Professional, you can configure a post-build event for each module, and that event could copy or move it. There are some additional properties that are defined for post-build events, that might be useful.
Full disclosure: I work for PreEmptive Solutions, who makes Dotfuscator. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "dotfuscator"
} |
How do I remove content between X and Y using preg_replace?
What would the regular expression be for removing any content between a quote, and the directory "uploads/"?
Using a regexpression generator, I get this: (?<=\=")[^]+?(?=uploads/)
$block_data = preg_replace('/(?<=\=")[^]+?(?=uploads/)/g','',$block_data);
But seems to be removing everything :( | You should escape the "/" in "uploads/" and `g` isn't a valid modifier, plus `[^]` is invalid, I guess you wanted `.` instead.
Here is your regex :
/(?<=\=").+?(?=uploads\/)/
The test on ideone | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "php, regex, replace, preg replace"
} |
Is a Gaussian "steepest" at 1-sigma?
If I take the 2nd derivative of a Gaussian $e^{-\frac{x^2}{2\sigma^2}}$ and set it equal to $0$, the inflection point is $x=\pm \sigma$. Is $1$-$\sigma$ the point at which the Gaussian curve is "steepest"? | You wish to find the extrema of the derivative of $f(x)=\exp\left(-\frac{x^2}{2\sigma^2}\right)$ -- those are the points with 'steepest' slope, at least locally. For a differentiable function $g$ on an open interval, its extrema satisfy $g'=0$. Hence, you should calculate the zeroes of
$$\frac{d}{dx}f'(x)=\frac{d}{dx}\left[\exp\left(-\frac{x^2}{2\sigma^2}\right)\cdot\frac{-x}{\sigma^2}\right]=\exp\left(-\frac{x^2}{2\sigma^2}\right)\cdot{\left(\frac{-x}{\sigma^2}\right)}^2-\frac1{\sigma^2}\cdot\exp\left(-\frac{x^2}{2\sigma^2}\right)\\\ =\exp\left(-\frac{x^2}{2\sigma^2}\right)\cdot\left({\left(\frac{-x}{\sigma^2}\right)}^2-\frac1{\sigma^2}\right)$$
Hence, we have $\frac{d}{dx}f'(x)=0\iff {\left(\frac{-x}{\sigma^2}\right)}^2-\frac1{\sigma^2}=0\iff x^2=\sigma^2\iff x\pm\sigma$.
Well, of course we found the same values of $x$! The solutions to $(f')'=0$ are the solutions to $f''=0$. So the 'steepest' points of $f$ are a subset of the zeroes of $f''$. | stackexchange-math | {
"answer_score": 3,
"question_score": 4,
"tags": "calculus, derivatives"
} |
How can I support offline_access scope for an MS Identity app against public MSA?
The MS Identity website for MSA apps (< interface doesn't support adding the `offline_access` scope. How can I do this for my app?
Error: AADSTS70011: The provided value for the input parameter 'scope' is not valid. The scope User.Read,offline_access is not valid. | Based on the error you encountered:
> The provided value for the input parameter 'scope' is not valid. The scope User.Read,offline_access is not valid.
Your error is based on the request you constructed rather than the app config in the portal. The problem here is the scopes should be separated by a single white space (%20 in web encoding). In the error, it seems you have separated scopes with a comma. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "azure active directory"
} |
where is my cls button in Open activities in Lightning
I can able to see "cls" button in classic.
Please find the screen shot here:

Locate the changelist that you submitted, e.g. via P4V's _Submitted_ tab, right-click and choose _Back Out..._.
It's best if the files you're trying to resurrect (re-add) don't already exist on your filesystem, otherwise Perforce will refuse to overwrite them. (Which may be what the error message is telling you; I'm not sure.) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 3,
"tags": "perforce, p4v"
} |
Set a variable in the app_controller and use it in a CakePHP layout
I need to set a variable in the app_controller of CakePHP and then use it in my default layout file.
Is there a way to set this variable? | I think what he meant was, that he doesn't know where to set a variable since he's not in a specific function inside a controller. To have a variable (or anything else really) available everywhere, you have to put it in your AppController like this:
function beforeFilter()
{
$this->set('whatever', $whatever);
}
More on those callback functions here. | stackexchange-stackoverflow | {
"answer_score": 11,
"question_score": 6,
"tags": "cakephp, controller"
} |
WP8 IMobileServiceTable - Detecting End of Asynchronous Call
My app makes a simple call the an Azure Webservice database and I want to copy the returned rows into a new list.
private IMobileServiceTable<dbEntry> entryTable = App.MobileService.GetTable<dbEntry>();
private MobileServiceCollectionView<dbEntry> currentEntries;
currentEntries = (entryTable.Where(ev => ev.event_date.Month == dateToShow.Month)
.ToCollectionView());
foreach (dbEntry ev in currentEntries)
{
//insert ev into another List
}
The problem is that the "where" call to the DB is asynchronous, so by the time the loop is reached there are no elements in `currentEntries` yet.
How can I detect that the call has completed before executing the loop? Is there an event handler for this?
Thank you. | It sounds like you found this solution already but I'll post it for anyone else that comes across this.
Unless you directly want to bind a UI element to the results of the operation, I suggest you do not use the ToCollectionView method. Instead, do the following:
private IMobileServiceTable<dbEntry> entryTable = App.MobileService.GetTable<dbEntry>();
private List<dbEntry> currentEntries;
currentEntries = await entryTable.Where(ev => ev.event_date.Month == dateToShow.Month)
.ToListAsync();
foreach (dbEntry ev in currentEntries)
{
//insert ev into another List
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "azure, windows phone 8, azure mobile services, asynchronous"
} |
Copying My account/Login/Register button outside header
My client is looking for a way to have a Sign up/Login button outside the header menu area. For instance this website - < . The "sign up with email" forwards to a login form which is the same as woocommerce login form. If i do this with a simple button - even after registration or login, the button will show the original text (ex. "login/register"), but the My account/Login/Register will show the user login name (ex. "customer name1"). All in all i want to copy the exact button in the main body of my website. I know this is simple for you, but i am really struggling here. Thank you in advance! | You can try `wp_loginout()` function which will display Login or Logout text (based on whether the user is logged in or not) in an anchor tag. And, then you can apply CSS styling to make the anchor tag to appear like a button. Hope this logic helps you.
See here for reference. | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "wp login form"
} |
We write but not on paper
> We write, but not on paper
>
> We draw, but not with ink
>
> We make things work
>
> But not in this realm
>
> We work in the webs
Hint I:
> Look between the webs | I believe this is about
> The internet/computers
And
> The 'we' are programmers
* * *
We write, but not on paper
> Programmers write code using a keyboard
We draw, but not with ink
> They can draw on tablets using fingers
We make things work
But not in this realm
> They can make programs, websites and the internet work, which are all online
We work in the webs
> World wide 'WEB' | stackexchange-puzzling | {
"answer_score": 6,
"question_score": 4,
"tags": "riddle"
} |
Test result chart/graph from release in tfs 2017
I tried to show test result from automation test on dashboard but I wasn't able to do it. In release I have environment which is responsible for running automation tests, I can see test results in release details and in tests runs. In test runs there are a lot of charts that I want to pin to dashboard, unfortunately there is no option in test run. I tried also creating test chart widget etc. directly from dashboard but they are only working with tests running with build. Is there way to pin test result from release environment to tfs dashboard? I am using tfs 2017 | Unfortunately the feature is not supported.
For now, we can only Add a release summary chart to dashboard, then you can naviagte to the specific release from the summary chart to see the test results.
Please see Add charts to a dashboard to check which chart/graph are available to be added to a dashboard. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "tfs, release, test results"
} |
SQL database design advice
I have a `product` table:
ProdId(PK)
Prod1
Prod2
Prod3
Prod4
and `Certification` table:
Certification(PK):
Cert1
Cert2
Cert3
How do I Model the following relation (pseudo table):
ProdwithCertId(PK) ProdwithCert
ProdwithCert1 "Prod1 with Cert1"
ProdwithCert2 "Prod1 with Cert1, Cert2"
ProdwithCert3 "Prod1 with Cert1, Cert2, Cert3"
ProdwithCert4 "Prod2 with Cert1, Cert2"
ProdwithCert5 "Prod2 with Cert1, Cert2, Cert3"
Cannot have duplicates, e.g. in above table, `ProdwithCert6 - "Prod2 with Cert1, Cert2, Cert3"` is not allowed | This is the schema.
table product (id, name)
table certification (id, name)
table product_group (id, product_id)
table product_group_certification (id, product_group_id, certification_id)
Now, let's assume we took the `Prod2` in your example above, in this schema it looks like this.
**product**
1, Prod2
**certification**
1, Cert1
2, Cert2
3, Cert3
**product_group**
1, 1 // Prod2 with Cert1, Cert2
2, 1 // Prod2 with Cert1, Cert2, Cert3
**product_group_certification**
1, 1, 1
2, 1, 2
3, 2, 1
4, 2, 2
5, 2, 3 | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "sql, database design"
} |
If I use a pointer in a function to populate a list, do I have to delete that pointer at the end of the function in c++?
If I use a pointer in a function to populate a list, do I have to delete that pointer at the end of the function, or the list's destructor will do the work in c++?
For example:
void populateList() {
Human* human;
List<Human> myList;
for (int i = 0; i < 5; ++i) {
human = new Human();
myList.push_back(*human);
}
}
Should I delete the pointer at the end of the function, or it is not needed, because it is not a memory leak? | In this line:
myList.push_back(*human);
you are making a copy of the dynamically allocated object pointed at by the `human` pointer, so the `myList` destructor will only clean up that copy. You do need to manually free the dynamically allocated memory pointed at by `human`, to avoid leaking that memory.
However, in this case there seems to be no reason to dynamically allocate memory with `new` at all. You could just create a local `Human` and add that to `myList`. Then there are no issues with memory leaks since there is no dynamically allocation, and all the objects will be correctly cleaned up when they go out of scope. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 0,
"tags": "c++, pointers, memory"
} |
add-migration not generating anything
So I've tried running "add-migration AddBooking -verbose"
To this class:
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace HostelBookingSystem.Models
{
public class Booking
{
[Key]
public Int32 BookingId { get; set; }
public Int32 Duration { get; set; }
public Double Price { get; set; }
public BookingStatus Status { get; set; }
public virtual UserProfile UserProfile { get; set; }
public virtual Bunk Bunk { get; set; }
public virtual Room RoomPreference { get; set; }
}
}
However I'm receiving completely empty Up() and Down() methods.
The same thing happens when I remove the 3 public virtual attributes as well.
Can any explain why this is? | 1) The DBContext class needs to be set up
2) Include the property for the above class in the DBContext
public DbSet<Booking> Books { get; set; } | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "asp.net, entity framework 5, entity framework migrations"
} |
Sort post by custom field numeric value
I am trying the way to sort post from custom field numeric value.
Here is my query:
query_posts( 'cat=2684' );
how to tell to use the custom field "sort_number" value | To sort your posts by a numeric value in a custom field your query would look like this:
query_posts('cat=2684&meta_key=yourCFkey&orderby=meta_value_num'); | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "query posts"
} |
Applying for bachelors science program, should I include my high-school transcript or just post-secondary transcripts?
I have graduated from a 2 year Computer Systems Technology diploma program at BCIT, and am applying for general sciences at UBC, with the intention of moving forward to get a combined bachelors in Computer Science and Statistics. They advise submitting a high-school transcript, but it is not mandatory like my post-secondary transcripts are. My high-school transcript is not flattering. My grades from high-school were much worse than the grades I got in my time in the CST program at BCIT. In high school there were a few classes that I came extremely close to failing (Physics 12, Chemistry 12, and precalc 12), and only 1 class I actually excelled in (Advanced Placement Computer Science). Would it look worse on me to submit a bad transcript, or no transcript at all? | This is a no brainer. It's NOT REQUIRED and it DOESN'T LOOK GOOD. Skip the high school transcript and just give them the juco transcript. | stackexchange-academia | {
"answer_score": 0,
"question_score": -2,
"tags": "bachelor, transcript of records"
} |
Custom annotations for XML
I want to build a general package for annotations that can be used in XML. The concept is similar to defining custom annotations for Java, building a special package, in which the custom annotations are defined, and so that they can be used among different projects, just by importing the package.
Is there a way to achieve that for XML? Or it isn't needed, since every annotation is defined in an XML from its basis? So only knowing the structure of the annotation, that will be used in different XML files, and applying it per hand throughout is enough? | An annotation could be described as attribute of an element. In XML, you'd probably put "annotations" in their own XML namespace and use attributes in that namespace for annotating elements.
An example for doing so is RDFa, which is used to embed machine-readable, semantic data for example into HTML documents. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "java, xml, annotations"
} |
What are the advantages and disadvantages of wearing a trisuit?
I am looking into going into triathlons and I was wondering wearing a trisuit improves your performance in triathlon. | I would suspect the primary benefit is time saved in transition. Usually shirts are required in races, so after the swim you have to do something to cover up. (I suppose you could wear stuff under a wetsuit, but I do not use wetsuits).
If you do not have to change anything in transition it can help. Other than that, I suspect it is comfort. | stackexchange-sports | {
"answer_score": 4,
"question_score": 8,
"tags": "equipment, triathlon"
} |
Finding the total surface area of cuboid model using volume
I am stuck with a math question about application of differential calculus from my university math class.
> You are to design a cuboid model with a square base that has a volume of $12m^3$. In order to have a minimum total surface area for the cuboid, what are the values for the height of the cuboid and the length of a side in the square base?
So far, this is what I have done:
$$\text{Volume = }L.B.H = B^2.H$$ $$12 = B^2.H$$ $$H = \frac{12}{B^2}$$ $$\text{S.A. = } 2.B^2 + 4.B.H$$ $$= 2.B^2 + 4.B.(\frac{12}{B^2})$$ $$= 2.B^2 + \frac{48}{B}$$
I am stuck after this step. How should I go about to solve this question? I feel that there is not enough information to complete this question. | In order to find the minimum value of an expression, we take its derivative and equate it to zero. So continuing your solution, and taking the derivative of surface area, we get,
$$\frac{dB}{dy}=4B-\frac{48}{B^2}$$
Equating it to zero, we get
$$B=12^{\frac{1}{3}}$$
Substituting this in:
$$H = \frac{12}{B^2}$$
we get,
$$H=12^{\frac{1}{3}}$$
And $H=L$, so,
$$L=12^{\frac{1}{3}}$$
Finally $L=12^{\frac{1}{3}}, B=12^{\frac{1}{3}}$ and $H=12^{\frac{1}{3}}$ | stackexchange-math | {
"answer_score": -1,
"question_score": 2,
"tags": "calculus, differential geometry"
} |
Use datatables.net with javascript
So I have a few javascript arrays, ex. `array1 = [1,2,3]` and `array2 = [4,5,6]` and I want these arrays to represent the column data, not row data like it wants. How would I make the table to look like:
!This
I've been pulling my hair out all day, and I can't seem to find a solution......is this even supported? | Simply output the data how you need it.
var rows = '';
for (var i = 0; i < array.length; i++) { //assumes equal size arrays
rows += '<tr><td>'+array[i]+'</td><td>'+array2[i]+'</td></tr>';
//or however you do this
} | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 2,
"tags": "javascript, twitter bootstrap, multidimensional array, datatables"
} |
Destroy a model in loopback.io
How can I delete a model in strongloop's loopback.io?
I have seen somewhere command called `persistedModel.destroy()`
but when I exectute `slc persistedModel.destroy()`
I get command not found error. | Delete `/common/models/your-model.js` and `/common/models/your-model.json`, then delete the lines referencing your model in `/server/model-config.json`. | stackexchange-stackoverflow | {
"answer_score": 63,
"question_score": 32,
"tags": "loopbackjs, strongloop"
} |
Solving approach for a series
I am having a great trouble on finding the solution of this series.
> index 1 2 3 4 5 number 0 1 5 15 35
here say first index is an exception but what is the solution for that series to pick an index & get the number. Please add your Explanation of the solving approach. I would also like to have some extra example for solving approach of other this kind of series. | The approaches to solve a general series matching problem vary a lot, depending on the information you have about the series. You can start with reading up on time series.
For this series you can easily google it and find out they're related to the binomial coefficients like n!/(n-4)!/4! . Taking into account i, it will be something like (i+3)!/4!/(i-1)! | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "discrete mathematics, series"
} |
Z- Index not working on menu
I am trying to implement a z-index on a menu sub-item show that it appears to be on top to the footer but i cant seem to get it to work. And im have trouble especially on mobile devices for menu items lower on the screen.
How can i solve this. Here is a link to the site | try this
#ef-footer {
bottom: 0;
left: 0;
line-height: 1.1em;
right: 0;
/*z-index: 35;*/
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -2,
"tags": "html, css"
} |
VS 2010+ extension: add filters to project
I'm developing VS extension which must reconstruct specified directory's tree structure via Filters and add existing files from that directory to appropriate filters.
How can I add Filters and existing files to project via code? | I found the following solution:
using Microsoft.VisualStudio.VCProjectEngine;
using Microsoft.VisualStudio.Shell.Interop;
//...
EnvDTE.DTE dte = (EnvDTE.DTE)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SDTE));
VCProject prj = (VCProject)dte.Solution.Projects.Item(1).Object;
VCFilter filter = prj.AddFilter("Custom Filter");
filter.AddFile("D:\\path\\File.h");
prj.Save();
Also you need to add Reference to Microsoft.VisualStudio.VCProjectEngine. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "visual studio 2010, vs extensibility"
} |
Simulating <%#Bind(...) %>
ASP.Net:
In code-behind I can simulate `<%# Eval("Property")%>` with a call to `DataBinder.Eval(myObject,"Property");`
How do I simulate a call to `<%# Bind("Property")%>` ?
many thanks | `DataBinder.` **`GetPropertyValue(`**`myObject,"Property"` **`)`** | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "c#, asp.net, data binding"
} |
Get distances within polygons based on a line
Setup:
* Country regions are stored as Polygons in postgres/postgis (Region:id:region_poly)
* Cross-country routes are stored as Lines in a different table (Route:id:route_line)
Problem:
* Given a Line (route_line), how can I pull the length of the line in each polygon (region_poly) with a single query
Example:
* Given Polygon A, B, and C, and a line X that crosses all three of these polygons, I'd like to get something like: {"A": 10km, "B": "160km", "C": 16km}
I think I have to use the ST_Intersection with ST_Length, but I can't quite wrap my head around it. (I'm still new to the gis stuff) | you basically just need an intersection of the linestrings and polygons, get the length with st_length and use the sum function with a group by on the unique polygon name or id. I am not sure what your columns are exactly so I will give you a generic query that you should be able to plug and play
select sum(st_length(st_intersection(c.geom,l.geom))) as length_of_route,
c.region_id, c.other_column,l.other_column
from country_regions c join cross_country_routes l
on st_intersects(c.geom,l.geom)
group by region_id,c.other_column,l.other_column | stackexchange-gis | {
"answer_score": 2,
"question_score": 0,
"tags": "postgis, polygon"
} |
Best Process Monitor In Ruby
From experiences with process monitoring in Ruby, what do we recommend as the best process monitor. These are some of the features I'm interested in:
1. Efficient memory management without memory leaks
2. Monitor processes that are consuming a huge amount of RAM and automatically restart them
3. Optimum up time i.e automatically restart processes when they die off for some reason
4. Easy debugging i.e the process should still be able to log to a log file | I have used Eye gem now in one of our production apps and it's been running for the past 3 years. We haven't experienced any memory issues with it, although, we don't do heavy computational task with it.
Eye was inspired by God and Bluepill. So far, I haven't experienced any memory leaks with Eye. The eye process itself is super light weight. Uses just about few kilobytes of memory and less than 1% of CPU.
You also have various features with eye such as easy debugs, memory monitoring for processes, cpu monitoring, nested process configuration, mask matching etc.
Eye is awesome, I do recommend it. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "ruby, process monitoring"
} |
Can I change my PSN name?
I'm not all too proud of my PSN ID. Can I change it? | Sony will not allow you to change your PSN ID. This is to prevent players from griefing others and then changing their name to hide from any consequences.
> "We don't want to make it so that you can go in, grief a bunch of people in Far Cry, change your avatar, change your username, go into CoD and grief everybody over there. We want to stop that."
Source | stackexchange-gaming | {
"answer_score": 2,
"question_score": 1,
"tags": "ps4, psn"
} |
scp file to different user in the remote server from local
generally, i login to a server xyz.com using my login credentials([email protected]), my home = /home/user/myuserid/
after login, i do "su - someuser" to access the files.
i would like to copy a file from local machine to a directory in someuser eg: /abc/someuser/temp
for this, i am using scp somefile.txt [email protected]:/abc/someuser/temp/
it is asking my password for myuserid and then says.. /abc/someuser/temp/ permission denied
what command shall i use to copy a file to su in remote host? | You'll have to use someuser's credentials to do the scp
scp somefile.txt [email protected]:/abc/someuser/temp/
Alternatively you can give `myuserid` permission to `someuser`'s home directory. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 7,
"tags": "linux, scp, su"
} |
Append several one-dimentional arrays to a one-dimentional array with array_push
I want to add data from a numeric, one-dimensional array to an existing one-dimensional total array, like in <
My solution creates a two-dimentional array. Where is my logic error?
.
.
$arr_Total_WordText=array();
$i=0;
while ($row = $result->fetch_assoc()) {
$text = utf8_encode(trim($row["mod_Thema"]));
...
$arrWordText[$i]=$text; // add several row-Infos
$i++;
array_push($arr_Total_WordText,$arrWordText);
}
print_r($arr_Total_WordText);
[0] => Array
(
[0] => eins
[2] => zwei
)
[1] => Array
(
[0] => Drei
[1] => vier
[2] => fünf
)
[2] => Array
(
[0] => sechs
[1] => sieben
[3] => acht
[4] => neun
) | array_push adds an element(s) to the end of the array. since you are pushing an array onto your result, it will add it as an array instead of concatenating, which is the reason it is creating a 2D array.
You will need to use a technique that will concatenate/append the elements of the array to the result array.
One way you can do this by using the array_merge function like so:
$arr_Total_WordText = array_merge($arr_Total_WordText,$arrWordText);
Another way is to iterate the elements of the array `$arrWordText` one by one and append them to your result. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "php, array push"
} |
Using preg_match_all() to locate XML within a log in PHP
I have several log files that contain EPP requests and responses. I need to use preg_match_all to return an array of all the XML requests within the log, so I can then parse out the XML and validate it, however I'm not too familiar with regex. The XML should always begin with...
<?xml
...and end with...
</epp>
How would I form Regex to find everything contained between and including these identifiers. | You should use `s` flag in which `.` matches new lines as well, and a whole capture group:
preg_match_all("/(<\?xml.*?<\/epp>)/s", $content, $matches);
print_r($matches[1]); | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "php, xml, regex, epp"
} |
How to use the left and right arrow keys in the tclsh interactive shell?
Why can't I use the left and right arrow keys (actually, the same goes for the up and down keys as well) to move about the line I'm currently on in the `tclsh` interactive shell? If I try to press either one, I get a bunch of abracadabra instead of moving back and forth. This is not all that convenient when, for example, you make a typo, but you can't move the cursor back to change it. You have to use the backspace key to erase all the stuff that you've typed after the place where the typo is located thereby destroying all your work. Is it possible to fix this, quite frankly, buggy behaviour?
 and allows the use of GNU Readline
> features in Tcl programs.
>
Once you have installed the package, either from the Software Center or via the command line using `sudo apt-get install tcl-tclreadline`, you can enable it for interactive tcl shells by adding
if {$tcl_interactive} {
package require tclreadline
::tclreadline::Loop
}
to your `$HOME/.tclshrc` file as explained on the tclreadline project homepage. | stackexchange-askubuntu | {
"answer_score": 5,
"question_score": 1,
"tags": "tcl"
} |
Prove that this quotient space is normal
> Consider the topological space $(\mathbb{R}^2,\tau _E)$, where $\tau _E$ is the Euclidean topology, and the subset $A=\mathbb{R} \times \\{0\\} \subset \mathbb{R}^2$. Then, if $X=\mathbb{R}^2 /A$ (the quotient space obtained collapsing $A$ to a point, given by the equivalence relation $x \sim y \Leftrightarrow x=y$ or $x,y \in A$), prove that $X$ is normal and is not first countable.
I tried to follow the idea of treating the cases separately: if $C$ is a closed set of $X$, then we have by definition that $\pi ^{-1}(C)$ is closed in $\mathbb{R}^2$ ($\pi: \mathbb{R}^2 \rightarrow X$ is the quotient projection), so we can treat separately the cases in which $[A] \in C$ and $[A] \notin C$ (in the second case the equivalence relation is trivial) and use the separation of $(\mathbb{R}^2, \tau _E)$. For the first countable part the only thing that came to my mind was to search a set in $X$ that is sequentially closed but not closed. | It is easier to show that it is not first countable from definition, I think.
Assume that $N_1, N_2,\ldots$ is a countable neighbourhood basis of $A$ as a point of $X/A$. We will construct a neighbourhood $U$ of $A$ that doesn't contain any of $N_i$.
First take $M_i=\pi^{-1}(N_i)$. Now for any $n\in\mathbb{N}$ pick $x_n>0$ such that $(n,x_n)\in M_n$. Such $x_n$ exists since the last set is an open neighbourhood of $A$.
We construct $V$ by connecting $(n,x_n)$ points piecewise linearly and taking area under it. Then $U:=\pi(V)$ is an open neighborhood of $A$ but no $N_i$ is contained in it. Because otherwise that would mean that $M_i$ is contained in $V$ which fails for $(i,x_i)$ point. | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "general topology, quotient spaces, separation axioms"
} |
Don't get the output of value of "P"
<p>This example calls a function which performs a calculation and returns the result:</p>
<p id="demo"></p>
<script>
var x=3;
var y=5;
function myFunction(){
return x+y;
}
document.getElementById(demo).innerHTML = myFunction();
</script>
**Don't get the value of "P" getting a debugging error like "Uncaught TypeError: Cannot set property 'innerHTML' of null"** | var x=3;
var y=5;
function myFunction(){
return x+y;
}
var demo = document.getElementById("demo");
demo.innerHTML = myFunction();
<p>This example calls a function which performs a calculation and returns the result:</p>
<p id="demo"></p> | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "javascript, html"
} |
Unexpected behaviour of macros in C
How can both the following codes execute (The codes are same except the semicolon in second line)
This code is expected to execute and does so as well.
#include<stdio.h>
#define SWAP(a, b) int t; t=a, a=b, b=t //note here is no semi-colon at the end
int main()
{
int a=10, b=12;
SWAP(a, b);
printf("a = %d, b = %d\n", a, b);
return 0;
}
But the following is not expected to run as `SWAP(a, b)` will be replaced by `int t; t=a, a=b, b=t;;`.So two semi-colons should produce error!!!
#include<stdio.h>
#define SWAP(a, b) int t; t=a, a=b, b=t; //note the semi-colon here
int main()
{
int a=10, b=12;
SWAP(a, b);
printf("a = %d, b = %d\n", a, b);
return 0;
} | The stray semi-colon becomes a null statement which is perfectly legitimate in C.
You could prove this by adding a line with a dozen semi-colons to your code.
Separately, your macro would be better written as:
#define SWAP(a, b) do { int t = a; a = b; b = t; } while (0)
This works better if you try to do two different swaps in a single block of code. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 0,
"tags": "c, macros"
} |
Window Manager "Showing Desktop Mode"
when I execute `wmctrl -m` I get the following output
spv@matrix:(~)$ wmctrl -m
Name: Compiz
Class: N/A
PID: N/A
Window manager's "showing the desktop" mode: OFF
Why is my "showing the desktop" mode OFF, and what difference does it make if it is ON. | This is a mode where windows are hidden and just the desktop is shown - see the "_NET_SHOWING_DESKTOP" hint on the EWMH page at freedesktop.org: <
so, something you would typically want off. | stackexchange-askubuntu | {
"answer_score": 3,
"question_score": 2,
"tags": "window manager"
} |
Is there an history of my tickets/correspondence initiated from the "Contact Us" page?
I'd like to know if there is a log that I can access (within Stack Exchange, without looking in my mailbox) reporting my usage of the "Contact Us" form across the SE sites.
I believe that the content of any correspondence wouldn't be accessible – since personal or sensitive information can be exchanged through that channel – but are the metadata present somewhere? | No, there is no such public log. The contents of the form are fed directly into an internal ticketing system; you can also provide a different email address than the one you used to sign up.
Note that if you inspect the form, you see that a link to your profile is submitted as well; this is necessary when requesting accounting merges, but is also useful sometimes to provide context for the person handling the ticket.
(Disclaimer: I'm not a Stack Overflow employee; the information above comes from the knowledge I obtained through the years here.) | stackexchange-meta | {
"answer_score": 5,
"question_score": 3,
"tags": "support, contact"
} |
Wordpress - Customize Watson Assistant plugin
I'd like to customize my chat box (Watson Assistant Chat Bot) and include my own CSS. I know I can set some changes on the plugin panel but I'd like to do more. Is there a way to do it? | Your best bet is to leverage WordPress itself to customize the look and feel via CSS.
You can do so from the sidebar menu **Appearance -> Edit CSS**.
Alternatively, your theme might offer you an option to write custom CSS code (and there also free custom CSS plugins you could install). But unless you have a good reason not to, the suggestion above should work well for you. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "css, wordpress, artificial intelligence, ibm watson, watson assistant"
} |
What is a good data mining / BI / report tool for MySQL?
I am looking for a tool, service, or framework that would allow us to expose our database to management. I have looked, although briefly, at JasperSoft and Crystal Reports. They looked "OK".
We are not afraid of writing our own queries so long as we can save them somewhere for later use by the business crowd. Ideally, the interface would be web based and reports could be emailed in a professional format. | I've never tried it but I read great things about Pentaho. Take a look at it.
< | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -2,
"tags": "mysql, data mining, business intelligence"
} |
Low Pass Filter to Isolate DC component
I have a question based on low pass filtering. If I input a signal to this low pass filter, why does the output file have an AC (of very low frequency).
 = 2 + sin(2*pi*100Mhz*t)$$ According to the filter response, the $$ sin(100Mhz*t) $$ should be attenuated by a very large number, thus resulting in a coefficient << 0 and leaving the DC component of 2 left. The output however is $$ v_o = 2 + sin(2*pi*0.1t) $$
* * *
**Where does that AC signal come from?**
 shows the output for one frequency. | stackexchange-electronics | {
"answer_score": 3,
"question_score": 1,
"tags": "filter, fourier"
} |
Loading local XML in javascript
Simple html height problem, i basicaly just want to set the height of the 3 buttons to 25% of the body height, works fine for the width attribute, but not for some reason the heigth doesn't
div.mainMenuButton {
height:25%;
text-align:center;
width:100%;
background:green;
}
<body>
<div id="menuContainer">
<div id = "playButton" class = "mainMenuButton" onClick="loadGame()">
Play
</button>
</div>
<div id = "optionsButton" class = "mainMenuButton">
Options
</div>
<div id = "aboutButton" class = "mainMenuButton">
About
</div>
</div>
</body>
Thank you. | Here is the CSS:
**CSS**
.mainMenuButton {
height:25%;
text-align:center;
width:100%;
background:green;
}
#menuContainer {
height: 100%;
}
html,body {
margin:0;
padding:0;
height:100%;
}
And the HTML:
**HTML**
<div id="menuContainer">
<div id = "playButton" class = "mainMenuButton" onClick="loadGame()">
Play
</div>
<div id = "optionsButton" class = "mainMenuButton">
Options
</div>
<div id = "aboutButton" class = "mainMenuButton">
About
</div>
</div>
And the fiddle: < | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "html, css"
} |
Replace values in list of lists
Python 3. Windows 10.
I have a hierarchical list and I want to change their values with the values specified.
For example: I have hierarchical list
l = [[[0, 4], 1], [2, 3], 5]]
and I have a dictionary
{0: 'da-1.txt',
1: 'da-2.txt',
2: 'en-1.txt',
3: 'en-2.txt',
4: 'it-1.txt',
5: 'it-2.txt'}
I want to replace values of the list with the values of the dictionary correspondingly without breaking the list hierarchy structure.
Output should be like this:
l = [[['da-1.txt', 'it-1.txt'], 'da-2.txt'], ['en-1.txt', 'en-2.txt], 'it-2.txt'] | You could go over the list and for each element check if it's a list. If it isn't, replace it with the corresponding element of the dictionary if it exists. If it is, apply the same algorithm recursively:
def rec_replace(l, d):
for i in range(len(l)):
if isinstance(l[i], list):
rec_replace(l[i], d)
else :
l[i] = d.get(l[i], l[i])
**Note:**
This implementation is of an in-place replacement of the list's elements. Alternatively, a similar approach could be used to return a new list instead. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "python, python 3.x, replace"
} |
How can SO validate one accepted answer per question without a parentPostId column in the votes table?
I can't get my head around this, but the votes table in the data dump has no parentPostId column. Only a voteTypeId, a userId, and a postId. Fair enough, but without a parentPostId, how can you validate that a question does not have more than one accepted answer (in other words, a question post does not have more than one vote with a voteTypeId of 1)?
I can't see how you could validate that in the absence of a parentPostId, but I must be missing something! | It goes via the `Posts` table. Just lookup the `ParentId` of the post with ID `PostId` and then check if `AcceptedAnswerId` is set. | stackexchange-meta | {
"answer_score": 1,
"question_score": 1,
"tags": "support"
} |
Disable the SQL powershell prompt
I have just installed SQL Server 2014 Express Exition, and are now faced with a prompt whenever turning to a powershell.
The prompt looks like this: `SQLSERVER:\>`
How can I disable this behavior and get my good old powershell back? | You can't necessarily disable the fact that loading SQLPS drops you in the SQLServer provider. A workaround would be to push and pop your current location when loading the module:
#SQLPS drops you in SQLSERVER drive.
Push-Location
Import-Module SQLPS -DisableNameChecking
Pop-Location
I would definitely recommend this. While in the SQLServer provider, you get some wonky behavior (e.g. test-path \path\to\valid\share will fail).
Edit: Just noticed your comment - you could place the push and pop around the Get-Module -ListAvailable | Import-Module line for the same effect.
Cheers! | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "powershell, sql server express"
} |
Conditional probabilities summing to one
Let's assume that we have two Bernoulli random variables: $A$ (can be true or false) and $B$ (can be true or false), and further assume we have been given $P(A=\text{true}\mid B=\text{true})$ and $P(A=\text{true}\mid B=\text{false})$.
Is it possible to calculate $P(A=\text{false}\mid B=\text{true})$ and $P(A=\text{false}\mid B=\text{false})$ from this? I think what it must hold is that these four terms must sum to one, i.e. $$P(A=\text{true}\mid B=\text{true}) + P(A=\text{true}\mid B=\text{false}) \\\\+ P(A=\text{false}\mid B=\text{true}) + P(A=\text{false}\mid B=\text{false}) = 1.$$ | No it's incorrect. $$P(A=true|B=true)+P(A=false|B=true)$$ $$=\frac{P(A=true,B=true)}{P(B=true)}+\frac{P(A=false,B=true)}{P(B=true)}$$ $$=\frac{P(B=true)}{P(B=true)}=1$$ Similarly, $$P(A=true|B=false)+P(A=false|B=false)=1$$ Thus, yes you can calculate the variables required, but the equation you wrote was incorrect | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "probability, conditional probability"
} |
Photoshop: batch resizing for web
I would like to take a group of 65K images and downsample it so that it is around 10K. Can someone tell me what I need to know to do this? I am not as concerned right now about each file being the same filesize, but if anyone has recommendations for that I am all ears. It seems like color profile settings get in the way of uniformity.
I tried the `'save for web & devices'`, but it doesn't seem to work. I try:
1. add new action in actions panel / start recording on action
2. change default colorspace to monitor spec
3. save for web and devices - 800 height max, 50 - 100% quality
4. hit save and choose destination
5. batch- open images only with folder destination specified seems to override the default location
this only seems to work sometimes and i can't figure out why. i should also be able to use
EDIT: FWIW, I am on Mac ONLY.
Thanks for any help,
jml | I haven't done any batch processing in Photoshop in a while, so I can't comment. What I want to share is that if for some reason you aren't able to do what you need via batch processing, Photoshop can also be scripted via AppleScript, VBScript, and Javascript.
Here's an article about Photoshop scripting. Here's Adobe's current documentation. If you need older docs, you'll need to google for them. | stackexchange-superuser | {
"answer_score": 1,
"question_score": 0,
"tags": "adobe photoshop"
} |
jquery and script speed?
Quick question, I have some scripts that only need to be run on some pages and some only on a certain page, would it be best to include the script at the bottom of the actual page with script tags or do something like in my js inlcude;
var pageURL = window.location.href;
if (pageURL == ' {
// run code
}
Which would be better and faster? | The best is to include the script only on pages that need it. Also in terms of maintenance your script is more independant from the pages that are using it. Putting those ifs in your script makes it tightly coupled to the structure of your site and if you decide to rename some page it will no longer work. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 2,
"tags": "javascript, jquery"
} |
How to add static method to built in class in JavaScript
I'd like to create a tryParse() static method for Date class. How can I do that?
Date.prototype.tryParse = function (value, result) {
// ... Code ...
};
This adds an instance method, not a static class method. Any idea? | First: you really, really shouldn't. To avoid collisions and incompatibilities, it's really much, to keep that sort of method in a namespace specific to your project:
var myUtils = {};
myUtils.tryParseDate = function(…) {…}
BUT! If you really, really, want to:
Date.tryParse = function(…) {…} | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 6,
"tags": "javascript, prototype, prototypal inheritance"
} |
Maximum factorial that is formed by three digits?
Number of digits that are present in the maximum number that is formed using three digits? Maximum factorial that is formed by three digits?
This was a question asked on a site. I am not able to understand is there any thing tricky i am not getting?
i have tried 3 and 720 but it is incorrect | The maximum factorial which can be formed using 3 digits is 999!. The answer can be easily obtained from wolfram alpha. Number of digits in 999!.
999!=Answer | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -3,
"tags": "math, logic"
} |
What do these multiple/concatenated method calls mean?
I understand how to create a class, instantiate it, as well as access properties and methods, but `$myobject->function()` is about as complicated as it gets for me for now.
What is this structure?
`$myobject->function()->something`. I am repeatedly seeing this more and more, especially as I start wrapping my head around PDO queries. For example:
$query->function1($arg)
->function2($arg)
->function3($arg);
What's happening here? is it simply chaining one call of multiple methods in the class, or are those sub-functions of `function1()`? What would the class definition look like? | `$myobject->function()` is returning an object, `->something` would access a field on that object.
Basically, the main concept in this programming method is that an object contains data and methods (or "functions") to interact with the contained data. These containers can be conveniently passed around. PHP is giving you some shorthand so you don't have to assign everything to a variable.
Returning objects is a way to layer functionality, so your PDO object, which has a query method, may return a row object. The row object has its own set of methods (e.g. for getting column values), so you can then invoke those methods.
So:
$pdo->queryOneRow(...)->getValue(<some column>)
Is really just shorthand for:
$result = $pdo->queryOneRow(...);
$result->getValue(<some column>) | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "php, oop"
} |
Casting in visual basic?
I want to check multiple controls state in one method, in C# this would be accomplished like so:
if (((CheckBox)sender).Checked == true)
{
// Do something...
}
else
{
// Do something else...
}
So how can I accomplish this in VB? | C#:
(CheckBox)sender
VB:
CType(sender, CheckBox) | stackexchange-stackoverflow | {
"answer_score": 19,
"question_score": 12,
"tags": "vb.net, casting"
} |
Writing to a file in assembler
I'm tasked with creating a program that would write some string to a file. So far, I came up with this:
org 100h
mov dx, text
mov bx, filename
mov cx, 5
mov ah, 40h
int 21h
mov ax, 4c00h
int 21h
text db "Adam$"
filename db "name.txt",0
but it doesn't do anything. I'm using nasm and dosbox. | You have to create the file first (or open it if it already exists), then write the string, and finally close the file. Next code is MASM and made with EMU8086, I post it because it may help you to understand how to do it, interrupts are the same, as well as parameters, so the algorithm :
.stack 100h
.data
text db "Adam$"
filename db "name.txt",0
handler dw ?
.code
;INITIALIZE DATA SEGMENT.
mov ax,@data
mov ds,ax
;CREATE FILE.
mov ah, 3ch
mov cx, 0
mov dx, offset filename
int 21h
;PRESERVE FILE HANDLER RETURNED.
mov handler, ax
;WRITE STRING.
mov ah, 40h
mov bx, handler
mov cx, 5 ;STRING LENGTH.
mov dx, offset text
int 21h
;CLOSE FILE (OR DATA WILL BE LOST).
mov ah, 3eh
mov bx, handler
int 21h
;FINISH THE PROGRAM.
mov ax,4c00h
int 21h | stackexchange-stackoverflow | {
"answer_score": 11,
"question_score": 6,
"tags": "assembly, nasm, dosbox"
} |
Change DateFormatString to show 11:59:59 as opposed to 12:00:00
This is a very simple issue, although I don't know how to best solve it. I have to 2 fields:
<asp:BoundField DataField="AUCTIONBEGINS" HeaderText="Auction Begins" DataFormatString="{0:d}" HtmlEncode="False" >
<asp:BoundField DataField="AUCTIONENDS" HeaderText="Auction Ends" DataFormatString="{0:d}" HtmlEncode="False" >
My problem is that the values you assign to these two fields get written to an Oracle database but I want them to be written in the following manner:
for AUCTIONBEGINS ---> 1/1/2013 12:00:00 AM for AUCTIONENDS ---> 1/10/2013 11:59:59 PM
Is there an easy way to hardcode this into the DataFormatString? Or should I do it on the server side before writing to the database?
EDIT* Sorry for not being too clear. Both fields get saved with the 12:00:00 AM timestamp at the end, I want to implicitly add the 11:59:59 PM on the AUCTIONENDS DataField | You could simply add -1 seconds to the date:
auctionEnd = auctionEnd.AddSeconds(-1);
This will turn, for example, 1/10/2013 12:00:00 AM into 1/9/2013 11:59:59 PM. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "c#, asp.net, .net, oracle"
} |
html button to big/css not changing the size
I am making a game in javascipt, html and css. I just started, and one of the major challenges of the game is going to be making invisible buttons under text to make the text appear clickable. Here is my code:
<button type="button" style=visibility:hidden;font-family:monospace;font-size:12px></button>
<script type="text/javascript">
</script>
<p class="p1" style=position:absolute;top:0px;left:0px;font-size:55px;font-family:monospace>
HI
</p>
The button makes a blank space but it is not in the correct spot and shows up as 55 pixels big. Please help | Seems to me you should do something like this. You don't have to worry about the location of the button.
<style type="text/css">
.p1 {
position:absolute;
top:0px;
left:0px;
font-size:55px;
font-family:monospace
}
.nolink {
text-decoration:none;
color:#000
}
</style>
<script>
function doSomething() {
alert("say hi");
}
</script>
<p class="p1">
HI, this <a class='nolink' href="javascript:void();" onclick="doSomething();return false;">text</a> is clickable
</p>
fiddle: <
updated answer. isolated css | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, html"
} |
Разметка панели Grid
Подскажите, можно ли при создании Grid в разметке XAML указать сразу нужное количество строк и столбцов (при условии, что они будут равного размера), а не делать для каждых строки и столбца RowDefinition и ColumnDefinition? | Если известно, что все столбцы и строки равного размера, то можно вместо элемента Grid использовать элемент UniformGrid.
<UniformGrid Columns="3" Rows="3" /> | stackexchange-ru_stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "wpf, c#"
} |
SUMIF with ARRAYFORMULA, Argument must be range error
I'm trying to do a modified version of this formula (copied from here).
=ARRAYFORMULA(SUMIF(ROW(D1:D10), "<=" & ROW(D1:D10), D1:D10))
But when I changed it to
=ARRAYFORMULA(SUMIF(ROW(D1:D10), "<=" & ROW(D1:D10), IF(D1:D10 <= 50, D1:D10 * 2, D1:D10)))
It gave me a bunch of N/A "Argument must be a range" error.
I know I could use a helper column for the IF part, but is it possible to do this without one?
Column D | Expected output
---|---
17 | 34
63 | 97
78 | 175
25 | 225 | use:
=INDEX(IF(D1:D="",,MMULT(TRANSPOSE((ROW(D1:D)<=TRANSPOSE(ROW(D1:D)))*
IF(D1:D<50, D1:D*2, D1:D)), SIGN(D1:D)))
;
class MySanitize extends Sanitize {
public static function html(...) {
...
}
}
You'll have to switch to use `MySanitize` instead of `Sanitize`, but that shouldn't be a big problem. A text find/replace can take care of it if you're using it a lot already. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "cakephp, cakephp 1.3, sanitize, html entities"
} |
How can I keep my business income separate from personal
My student loan payment is based on my income. If my income goes up, my payment increases.
I am starting a business in addition to my regular income. I was planning on creating an LLC because of the reduced organization requirements vs a C-corp. However, if I understand correctly, the LLC's income is counted as my personal income for tax purposes. Is that correct? That is what I'm trying to avoid, since that will increase my student loan payment. Or does it only count as my personal taxes if I do some sort of distribution?
Is there a type of business entity I can look into that has lower paperwork and records requirements like the LLC but doesn't pass the income to my personal income? | A C-Corp is taxed as a separate entity. So if you start a C-Corp and it has $50k in profit, it will pay corporate income tax on that profit while your personal income tax return will show none of that $50k as income. However, you also won't be able to use that money for personal expenses. If you pay yourself from the company via salary or dividend that would be counted as income on your personal tax return.
Currently owners of pass-through entities (sole proprietorship, partnership, s-corp) can benefit from a 20% pass-through deduction, this makes pass-through income very attractive. If you have other good reasons to start a C-Corp (like planning on taking on investors) then it might be worth considering, if not it's almost certainly not worth the cost/hassle. View your additional income and therefore increased student loan payments as a benefit, you'll be out of debt sooner. | stackexchange-money | {
"answer_score": 5,
"question_score": -1,
"tags": "united states, small business"
} |
Why are there kids above 6 and in school
In _Kindergarten Cop_ (1990), why are there kids above 6 learning inside a normal school? Are they special, or is something off? For example, the bad guy is searching a kindergarten for his kid, while stating his age is 6. | It's not uncommon for a 6 year old to be attending kindergarten, especially near the end of the school year. Most children turn 6 during the course of school year.
In most states a child must be the age of 5 by August 31st or September 1st to enroll in kindergarten. A typical school year ends in late May or early June, if a child entered kindergarten at the age of 5 and was born before May they would leave kindergarten at the age of 6. | stackexchange-movies | {
"answer_score": 9,
"question_score": 6,
"tags": "realism, kindergarten cop"
} |
Различие между Intent и PendingIntent
Кто нибудь может внятно обьяснить, что это за сущность - PendingIntent?
В каких случаях применять? И в чем ее отличие от обычного Intent? | Вся разница заключается в правах доступа к твоему приложению.
PendingIntent - обертка, которая позволяет стороннему приложению выполнять определенный код (твоего приложения) с правами которые определены для твоего же приложения.
Если в стороннее приложение передать простой Intent то он будет выполняться с правами которые имеет само приложения.
Советую взглянуть на примеры взаимодействия с другими приложениями (будильник, календарь и тд). Вот нашел небольшой - < | stackexchange-ru_stackoverflow | {
"answer_score": 11,
"question_score": 12,
"tags": "android, android intent"
} |
callback action from e.force:editRecord
I'm migrating some functionality from classic to lightning and need to replace javascript button which will redirect to standard edit page.
I'm using Quick Action for that calling component which does some pre-validation and then it calls `e.force:editRecord`.
After save is successfully performed I need to refresh record on current page as it is related and some values have been changed. Page is completely standard except for that Quick Action.
Is there a way to handle that save success as callback or any other reasonable workaround? I'm considering to create component that will show `lightningEditForm` instead of `e.force:editRecord`. It is shame that SF doesn't provide functionality to handle such situations or even handle it on its own. | So, solution for this issue was to implement custom component, which was using `lightning:recordEditForm` and use `onsuccess` to call this block.
$A.get("e.force:refreshView").fire();
setTimeout(function() {
var response = event.getParams().response;
var navService = component.find("navService");
var pageReference = {
type: 'standard__recordPage',
attributes: {
actionName: 'view',
recordId: response.id
}
};
navService.navigate(pageReference, true);
}, 250);
It will reload record and redirect to target record. Timeout is there bcs without it navigation event run first and refreshView after that, which was causing redirect back to original record page. | stackexchange-salesforce | {
"answer_score": 0,
"question_score": 0,
"tags": "lightning, refresh, lightning quickaction"
} |
How long do objects stored in Rails' sessions persist?
If I do `session[:greeting] = "Hi!"` in one controller action, for how long will I be able to refer to `session[:greeting]` in other controller actions?
Until the user closes his browser?
Until a certain amount of time passes?
Also, how can I configure this value? | Until the user closes her browser. That's the definition of a session.
To configure something longer, you will need to use one of:
* cookies. These can be marked to stay for any period of time (or until the user closes the browser)
* have the user log in
Often there's a combination of these, where the user is given a "remember me" token as a cookie, so that they don't have to log in every time they restart the browser. | stackexchange-stackoverflow | {
"answer_score": 18,
"question_score": 14,
"tags": "ruby on rails, session"
} |
Has anyone implemented the TestFlight SDK in a Flash Builder or Flash Professional project?
Has anyone managed to get this to work with a FB or Flash Pro Project? I am looking to use the enhanced features of TestFlight for an iPad app.
The TestFlight Software Development Kit (SDK) is a library that can be added to any iOS app for tracking analytics in beta/ internal testing and can also be used with apps in production (available in the App Store).
< | The easiest way is to use the NativeExtension: a wrapper around the SDK. Check this link and make sure you dot eh step described in the last comment:
<
I'm using this to distribute builds of 2 Flash Builder apps to a team. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "flash, sdk, flash builder, testflight"
} |
How to access control instances from map instance in Mapbox
I need a way to access a registered control instance from Mapbox map instance.
For example, say I register a hypothetical Mapbox control:
const control = new IControl(); // Where IControl is the hypothetical mapbox control
map.addControl(control);
How do I access this `control` instance in some other places in my codebase where I only have access to the map instance??
For context; I need to perform some map actions depending on some values only the control instance is aware of.
Thanks. | There is no standard way to do this. But there is nothing preventing you from doing:
map.addControl(control);
map._myControl = control;
and later accessing it with `map._myControl`;. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 4,
"tags": "javascript, mapbox, mapbox gl js, react map gl, mapbox gl draw"
} |
Unable to access S3 static website using https
I have followed all the steps from < but my website still cannot be accessed using https.
1. My certificate was issued to the domain admin.studentqr.com successfully as displayed here 
try using the solution given in <
which basically make sure you add your domain/subdomain to Cloudfront Alternate Domain Names and Check Http and Https in the Cloudfront config | stackexchange-serverfault | {
"answer_score": 0,
"question_score": 1,
"tags": "ssl, https, amazon s3, amazon cloudfront"
} |
Can we pass wrapper to future method?
Can we pass wrapper to future method? Even if wrapper class having only primitive datatype arguments. | I would also recommend using Queueable, since it's more modern approach and provides more flexibility.
You can pass wrapper, but for that, you'll need to serialize/deserialize that parameter.
// method
public void method(String wrapper) {
WrapperClass value = (WrapperClass) JSON.deserialize(wrapper, WrapperClass.class);
// implementation
}
// call
method(JSON.serialize(wrapper)); | stackexchange-salesforce | {
"answer_score": 7,
"question_score": 3,
"tags": "salesforcedx, salesforce to salesforce"
} |
why are noSQL databases more scalable than SQL?
Recently I read a lot about noSQL DBMSs. I understand CAP theorem, ACID rules, BASE rules and the basic theory. But didn't find any resources on why is noSQL scalable more easily than RDBMS (e.g. in case of a system that requires lots of DB servers)?
I guess that keeping constraints and foreign keys cost resources and when a DBMS is distributed, it is a lot more complicated. But I expect there's a lot more than this.
Can someone please explain how noSQL/SQL affects scalability? | noSQL databases give up a massive amount of functionality that a SQL database gives you by it's very nature.
Things like automatic enforcement of referential integrity, transactions, etc. These are all things that are very handy to have for some problems, and which require some interesting techniques to scale outside of a single server (think about what happens if you need to lock two tables for an atomic transaction, and they are on different servers!).
noSQL databases don't have all that. If you need that stuff, you need to do it yourself, but if you DON'T need it (and there are a lot of applications that don't), then boy howdy are you in luck. The DB doesn't have to do all of these complex operations and locking across much of the dataset, so it's really easy to partition the thing across many servers/disks/whatever and have it work really fast. | stackexchange-softwareengineering | {
"answer_score": 116,
"question_score": 158,
"tags": "sql, nosql, scalability"
} |
Applescript - Check if list of URL's contains any of these words from list
I have two lists. List A contains URL's and List B contains Words. I need to return every URL that contains any of the words (Filtering).
I have managed to check if true/false but not to return the URL's containing any of the words.
set theURLs to {"www.audi.com", "www.vw.com", "www.suzuki.com"} as text
set KeywordFilter to {"dodge", "audi", "chevy"}
set doesContain to containsItems from KeywordFilter against theURLs
on containsItems from qList against theText
set pageURLs to {}
repeat with anItem in qList
if theText contains anItem then return true
end repeat
return false
end containsItems
Do i need another loop to return the matching URL's in a String?
Thanks everyone for the kind help. | Coercing a list to text
set theURLs to {"www.audi.com", "www.vw.com", "www.suzuki.com"} as text
is a bad idea, the result is – depending on `text item delimiters` – `"www.audi.comwww.vw.comwww.suzuki.com"`
* * *
To compare _two_ lists you need _two_ loops
set theURLs to {"www.audi.com", "www.vw.com", "www.suzuki.com"}
set KeywordFilter to {"dodge", "audi", "chevy"}
set foundURLs to containsItems from KeywordFilter against theURLs
on containsItems from qList against theText
set pageURLs to {}
repeat with aText in theText
repeat with anItem in qList
if aText contains anItem then set end of pageURLs to contents of anItem
end repeat
end repeat
return pageURLs
end containsItems | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "web scraping, applescript"
} |
What to use instead of getSupportActionBar() in Library 22?
There is a line in my code, that marked as yellow:
getSupportActionBar().setDisplayShowHomeEnabled(true);
After installing _appcompat-v7:22.1_ it shows a hint:
> "Method invocation may produce java.lang.nullpointerexception".
What should be used instead of `getSupportActionBar()`? | getSupportActionBar().setDisplayShowHomeEnabled(true);
Should say
if (getSupportActionBar() != null)
{
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
getSupportActionBar() can return null so you the hint is telling you about this. | stackexchange-stackoverflow | {
"answer_score": 13,
"question_score": 4,
"tags": "android, toolbar, appcompatactivity"
} |
How to load a script based on a class found within the HTML
How can I use JavaScript or jQuery to load/link a script based on an HTML class found on the page?
I downloaded a script that places a class in the HTML when desktop/mobile/tablet is detected and would like to load a js file based on one of those for desktop users.
<html lang="en" class="desktop">
<html lang="en" class="tablet">
<html lang="en" class="mobile">
So what I want is to link/load a js file when the "desktop" class is assigned
if .desktop , then load ......../thisfile.js
Sorry for being clueless on this, I did a search and couldn't find an answer I understood how to implement. | One method is this
if ($('html').is('.desktop')){
$.getScript('url_of_js_file.js');
}
// You could also use .hasClass('desktop')
But to avoid an if/else jungle if you call your JS files `desktop.js`, `tablet.js`, etc you could do this.
var htmlclass=$('html').prop('class');
$.getScript(htmlclass + '.js'); | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "javascript, jquery"
} |
Deny access to a PHP file (Nginx)
I want Nginx to deny access to a specific PHP file, let's call it `donotexposeme.php`, but it doesn't seem to work, the PHP script is run as usual. Here is what I have in the config file:
location / {
root /var/www/public_html;
index index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/public_html$fastcgi_script_name;
include fastcgi_params;
}
location /donotexposeme.php {
deny all;
}
Of course, I do `sudo service nginx reload` (or `restart`) each time I edit the config. | The order in which nginx determines which location matches can be found here:
<
Using either of these will be matched before any other regular expression:
location = /donotexposeme.php
Or
location ^~ /donotexposeme\.php
The first is an exact match whereas the latter is a regular expression prefix match. | stackexchange-stackoverflow | {
"answer_score": 14,
"question_score": 6,
"tags": "php, linux, ubuntu, nginx, webserver"
} |
Can I submit a paper to two or more journals at the same time?
Assume I am submitting my paper to Journal X, which rejected the paper. After making modifications I am going to submit the paper to Journal X again. At the same time can I also submit the paper to another Journal Y (which has a lower impact factor than Journal X). As the Journal X has rejected it the first time, I think it may be rejected again. So I want to publish my work anyhow in a journal. | ## No.
You must not submit to more than one journal at a time. Most journals explicitly forbid this in their policies. The reason is that people agree to spend a significant amount of time reviewing your paper essentially as a favour and their effort is completely wasted if you then say, "Thanks but my paper was accepted somewhere else."
You must decide now whether to resubmit to the same journal or to try for a less prestigious one. Since you're asking the question, I assume you're a student: discuss this with your advisor! That's what they're there for. | stackexchange-academia | {
"answer_score": 3,
"question_score": 5,
"tags": "journals, paper submission"
} |
Find in html where element attribute contains string selenium
I am scraping a website that has a bit of html in this format.
</p></div><div class="content "><ul class="office-list"><li><a href="javascript:void(0)" class="_office atlanta" data-slug="atlanta" data-title="Atlanta" data-address="Twilio Atlanta<br />950 East Paces Ferry Road NE, 18th Floor<br />Atlanta, GA 30326<br />"
I have tried using some python code which is:
items = driver.find_elements_by_xpath("//*[contains(@class, 'address')]")
for item in items:
addresses.append(item.text)
However in this case, its not the class which contains `'address'`, it is `data-address`. How can I search any element attribute which contains `'address'`? | You can do it with `name()` function
items = driver.find_elements_by_xpath("//@*[contains(name(),'address')]/..")
The text you are looking for is in the attribute. Since you know only part of the name you need to use JavaScript to get it
value = driver.execute_script(
'for (index = 0; index < arguments[0].attributes.length; ++index) {
if (arguments[0].attributes[index].name.includes("address")) {
return arguments[0].attributes[index].value;
}
}', element) | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "python, html, selenium, beautifulsoup"
} |
Is there any way to change $\int\limits_0^c {f\left( x \right){e^{ - ax}}dx} \to \int\limits_0^\infty {f\left( u \right){e^{ - au}}du}$?
Is there any way to make a change of variable such that ?
$\int\limits_0^c {f\left( x \right){e^{ - ax}}dx} \to \int\limits_0^\infty {f\left( u \right){e^{ - au}}du}$
Thank you very much ! | $$\int_0^{\infty} f(u) e^{-au} du = \int_0^{c} f(u) e^{-au} du \ + \int_c^{\infty} f(u)e^{-au} du$$
What you want is only possible, hence, when $$\int_c^{\infty} f(u) e^{-au} du =0$$ | stackexchange-math | {
"answer_score": 3,
"question_score": 0,
"tags": "integration, change of variable"
} |
Regex to filter data in BigQuery
I have a field in a table, with data like the following:
a) Health and Medicines
b) {'name': 'Health and Medicines', 'url': '
I need to clean this data, and let only values like "Health and Medicines" I'm trying to do this with REGEX_EXTRACT in BigQuery, but I still cannot make it work.
So far I have the following regex:
(?:{'name': ')(.*)(?:')(?:, 'url': )(?:.)*(?:})
But works only when data has the tags {'name':...
How can I clean this data?
Thanks! | You can use JSON_EXTRACT_SCALAR since you have JSON data. When the field does not contain JSON data, then use REGEX_EXTRACT. See approach below:
NOTE: Modify regex to capture your other use cases.
with sample_data as (
select 'Health and Medicines' as test_field
union all select "{'name': 'Health and Medicines', 'url': ' as test_field
)
select
test_field,
ifnull(JSON_EXTRACT_SCALAR(test_field,'$.name'), regexp_extract(test_field, r'\w+\s\w+\s\w+')) as extracted_value
from sample_data
See approach below:
.vlaue = sheet1.cells(x,1).vlaue + sheet1.cells(x,2).vlaue
next x
but it there a more efficient way by using ranges or something where it can be carried out as a single step?
Cheers | A quick way is to enter from the immediate window:
[a1:a500]=[a1:a500+b1:b500]
The square brackets are a shortcut for the `Evaluate` function | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "excel, range, rows"
} |
iPad - How do I load the first cell from the RootView automatically into the DetailView upon launch?
The title pretty much asks it all. I've been coming back and trying to implement this every few days, but I cant seem to get it to work. I'd assume the code to set the detailItem from launch goes in the viewDidLoad, but at this point I am clueless.
Any help is greatly appreciated.
\--Tyler | You can use the `selectRowAtIndexPath` delegate:
[tblMyTable selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:0];
Of course, replace `[NSIndexPath indexPathForRow:0 inSection:0]` with the section / row that you want to automatically set.
You can either put this in your `viewDidLoad` or `viewWillAppear:` delegate.
Also, make sure that you define your `tblMyTable` _(or whatever you have named your table)_ in your header, hooked it up through Interface Builder _(if your using a custom XIB)_ , and use `@synthesize` in your **.m**
And the `didSelectRowAtIndex:` should be called when you use that method, so as long as your detailItem code is in `didSelectRowAtIndex`, you should be good. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "ipad, ios, uitableview, rootview"
} |
Use of "To" in a sentence?
This might be a very basic question. I saw following sentence in a dictionary. Emphasis mine.
> "defense portfolio could be the carrot **to dangle** before him"
I could not justify the use of "To" before dangle. I think the correct sentence should be
> "defense portfolio could be the carrot **dangling** before him"
Could you please explain which sentence should be the correct one? and why? | You have run across an infinitive of purpose. The sentence
> The defence portfolio could be the carrot **to dangle before him**.
means the the position is to be considered as a possible incentive (i.e., that would be the purpose of offering the position). The sentence
> The defence portfolio could be the carrot **dangling before him**.
means that it's possible that an incentive is being offered and it's the position mentioned. | stackexchange-english | {
"answer_score": 1,
"question_score": -1,
"tags": "grammar"
} |
Cost sensitive analysis in scikit-learn
Is there a scikit-learn method/class analogous to the **MetaCost** algorithm implemented in Weka or other utilities to perform const sensitive analysis ? | No, there isn't. Some classifiers offer `class_weight` and `sample_weight` parameters, but those are just optimized implementations over oversampling and undersampling, not MetaCost. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 6,
"tags": "scikit learn"
} |
Changing the default home page (non programatically) wiki SP 2007
I am brand new to SP. I have been charged with creating a site for our group. I posted a question last Friday regarding my default home page, where the view generated always has a grey bar on the bottom with a 'custom column' showing. In other words, I have my home page, and an ugly grey bar on the bottom that says "Knowledge Area'. Every page that is created within this library has this bar. That is fine by me for the other pages, but so ugly on the home.
So then I got the idea to create a new library, and reproduce the home page there, and just modify the welcome page settings to that page.
Unfortunately, when I follow siteactions > site settings, under Look and Feel there is no link to 'Welcome Page' (as I had read on the internets).
How the heck can I modify the home page path? I have no access to SP designer, or any other way to reach any code (near as I can tell).
Thank you for your time. | I think you need the publishing features enabled to see the link to welcome page from site settings. Are you using SharePoint Foundation or Server? | stackexchange-sharepoint | {
"answer_score": 2,
"question_score": 3,
"tags": "wiki"
} |
SNMP error with port already in use
I have created a SNMP agent simulator application which use the port number 161 for the simulated devices. sometimes it occurs the port alredy in use exception. how can i know if the 161 port is busy or not? | By using **netstat** command.
Specifically,
> netstat -s [PORT_NO]
For example,
> netstat -s 161
1. <
2. < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 3,
"tags": "java, port, snmp"
} |
LINQ to get sub-array
I have a `byte[]` and I want to extract a portion of the array and convert it to a string. I want to use LINQ and to do it in one line. This was the best I could find, but it fails me.
String id = new String(payload.Skip(60).Take(92-60+1).ToString());
to extract payload[60] to payload[92] and convert it to a string. Is there a better way? And I'm getting some errors with this syntax still.. | No linq is necessary. ASCIIEncoding.GetString
var str = Encoding.ASCII.GetString(payload, 60, 92-60+1); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "c#, linq, substring"
} |
How can I get a list of users and last login dates from a Cisco ACS running v5.2?
I'm trying to get a list of the users that have logged into a Cisco ACS, and the date of their last login. Ideally, I'd like it to include the identity store that was the source of the authentication info for the login (AD, RADIUS, etc.) I've looked in the ACS GUI, including monitoring and reports, but I mainly find things referencing monitoring the device's status itself, or broad trends. The one section that lists user information does it for one user at a time (not practical for a large pool of users). I've looked online but so far all I can find is someone telling how to do it in version 4, nothing for 5.2. Cisco's own documents don't seem to mention it either. As a side note, upgrading the software version is not an option at this time. | According to the Cisco TAC representative who handled my case, there is no way to get a list of users that includes their last login date, with the possible exception of looking up each user individually. I'm not sure I believe this answer, as it seems like such a basic query that I'd be very surprised if they didn't include any way to get the answer, but that is the word from Cisco themselves.
I am going to persist in trying to find a way to get that list, and if I succeed, I will update this answer. | stackexchange-networkengineering | {
"answer_score": 3,
"question_score": 1,
"tags": "cisco, aaa, logging"
} |
How to see all computers connected to a network
I am in a LAN and there are 3 Ubuntu, 2 Kubuntu, 2 Windows XP and 2 Windows 7. What commands or tools are available to see what PCs are connected to the LAN that it shows the name of the PC and the IP. Similar to tools like Angry IP that show all PCs in a LAN.
Note that I do not know the IPs or names of the computers connected to the LAN. So the tool or command should look for them to. | Taken from Finding All Hosts On the LAN From Linux/Windows Workstation
for ip in $(seq 1 254); do ping -c 1 192.168.1.$ip>/dev/null;
[ $? -eq 0 ] && echo "192.168.1.$ip UP" || : ;
done
But for a great tool, Nmap. Great for mapping networks. | stackexchange-askubuntu | {
"answer_score": 54,
"question_score": 88,
"tags": "networking, lan"
} |
How to test and adjust a website for iphone?
I developed this website
It looks fine on most browsers and OSes on PCs. It even looks nice on my HTC with Opera Mobile. Unfortunately I keep getting reports about how it displays on iphones. I don't have an iphone so here are my questions:
1. Is there an easy way to reliably check (emulate) my website on iphone (I tried sites like this but what this site does it opens iframe in safari trying to emulate ihopne native screen size, but the problem is somewhere else...)?
2. Any quick tips on obvious mistakes I made?
Thanks for help | I partially found the answer. As it turned out most mobile browsers (including safari for iphone and default browser in samsung galaxy) don't support
{ background: transparent;}
So I need to provide fallback colour as described here: < | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "iphone, mobile safari, web deployment"
} |
How can i find how many sandbox connect with a production org?
I want to know how many sandbox is connected with my org and what type of sandboxes they are?? | In Setup, enter Sandboxes in the Quick Find box, then select Sandboxes. Sandboxes displays the available sandboxes that you purchased and a list of your sandboxes in use. | stackexchange-salesforce | {
"answer_score": 0,
"question_score": 0,
"tags": "apex"
} |
Covering food while cooling
Is it a good or a bad idea to cover food that is cooling? For example I have bolognese cooling in a tupperware container but don't know whether I should cover it and refrigerate or leave uncovered out for a while? | There are two factors to consider, both related to the evaporation of water from the cooling dish:
* Evaporative cooling: if the water vapor can leave the container, the food will cool faster, but may dry out slightly
* Condensation: if the water vapor cannot leave the container, it will condense on the lid, and possibly drip back down onto the food
Modern refrigerators are very powerful, so if a little water dripping back is not a problem (which it would not be for a bolognese for example), go ahead and cover the item and place in refrigerator.
On the other hand, if water dripping back onto the dish would mar the surface (of a pumpkin pie, for example), you will want to cool it without a cover until it is no longer steaming. | stackexchange-cooking | {
"answer_score": 7,
"question_score": 4,
"tags": "food safety"
} |
Maximum and minimum value of Determinant of $3 \times 3$ Matrix with entries $\pm 1$
Find Maximum value of Determinant of $3 \times 3$ Matrix with entries $\pm 1$
My try:
I considered a matrix as :
$$A=\begin{bmatrix} 1 &-1 &-1 \\\ -1 &1 &-1 \\\ -1&-1 &1 \end{bmatrix}$$
we have $$Det(A)=-4$$ and maximum is $4$, but how can we show that these are max and min values?
I also tried as follows:
By definition Determinant of a matrix is dot product of elements of any row with corresponding Cofactors
hence
$$Det(A)=a_{11}C_{11}+a_{12}C_{12}+a_{13}C_{13}$$
By cauchy Scwartz Inequality we have
$$a_{11}C_{11}+a_{12}C_{12}+a_{13}C_{13} \le \left(\sqrt{a_{11}^2+a_{12}^2+a_{13}^2}\right)\left(\sqrt{C_{11}^2+C_{12}^2+C_{13}^2}\right)$$
any way to proceed here? | Let's assume the matrix is $$\textbf A=\begin{bmatrix}(-1)^a & (-1)^b & (-1)^c \\\ (-1)^d & (-1)^e & (-1)^f \\\ (-1)^g & (-1)^h & (-1)^i\end{bmatrix}$$ and thus $$\det(\textbf A)=(-1)^{a+e+i}+(-1)^{b+f+g}+(-1)^{c+d+h}-(-1)^{a+h+f}-(-1)^{b+d+i}-(-1)^{c+e+g}$$ From this we can see that $\det(\textbf A)$ is always even because switching 1 of (+1) with (-1) will change the sum by 2. Now as you have shown that $\det(\textbf A)=4$ is possible, we need to check for the possibility of 6. When the determinant is 6, we want, $$\begin{matrix}\textbf{even} &\textbf{odd} \\\ a+e+i & a+h+f\\\ b+f+g & b+d+i\\\ c+d+h & c+e+g\end{matrix}$$ But now left side says that sum of a,b,c,d,e,f,g,h and i must be even and the right part says that it must be odd. Contradiction! $\longrightarrow \longleftarrow$ | stackexchange-math | {
"answer_score": 3,
"question_score": 3,
"tags": "linear algebra, matrices, algebra precalculus, determinant"
} |
Rails has_many overridden by an included module
I have a model that looks like this, the #friends method overrides the association-generated method #friends:
class User < ActiveRecord::Base
has_many :friends
def friends
puts 'hi'
end
end
But when I refactor my code to look like this, the association-generated method #friends, doesn't get overridden by the included friends module:
module User
module Friends
def friends
puts 'hi'
end
end
end
require 'user/friends'
class User < ActiveRecord::Base
has_many :friends
include User::Friends
end
Why doesn't the associated-generated #friends get overridden by the included User::Friends#friends method? | Ruby's method lookup starts in the current class, if it doesn't find a match, it then looks in included modules and superclasses (IIRC, it looks in metaclasses, then modules, then superclasses, then superclasses metaclasses, etc). So when you define the method in the class, you are overriding, but when you define the method in the module, it doesn't get looked up.
In order to override the method, you should `undef :friends`, or `alias :old_friends :friends` (so that the original method is still available) inside of your module. It would probably work best to do it inside of the module's `self.included` method | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "ruby on rails, ruby, include"
} |
Is there a shortcut for repeat the second proximate command in bash?
We all know that `!!` can repeat the last command you do in bash.
But sometimes we need to do some operation like
$ python test.py
$ vim test.py
$ python test.py # here is where I need to repeat the second proximate bash command
I can use up-arrow key to do that, but that requires me to move my right hand away to an uncomfortable position. So I'm wondering if there is a command which like `!!` would work? | You can use `!-2`:
$ echo foo
foo
$ echo bar
bar
$ !-2
echo foo
foo
That may not help with your right-hand situation.
You can also use `!string` history searching for this sort of case:
$ python test.py
$ vim test.py
$ !py
python test.py # Printed, then run
This may be more convenient to use. It will run:
> the most recent command preceding the current position in the history list starting with _string_.
Even just `!p` would work. You can use `!?string` to search the whole command line, rather than just the start. | stackexchange-unix | {
"answer_score": 5,
"question_score": 8,
"tags": "bash, command line, command history"
} |
Confuse about definition of dense set
Assume (M,d) is a metric space , A is a subset of M
"A is dense in M " means $\forall$ x$\in$ M ,we always can find points of A to approach x
My question is
Since we are using the concept of "approach" to define the dense set,why not use A'= M as the definition of "A is dense in M", instead use cl(A) = M as its definition?
PS: A'= the derived set of A and cl(A) is the closure of A | The difference is in what happens at isolated points.
Consider for example a discrete metric space like $M=\mathbb{Z}$. If we take $A$ to be $\mathbb{Z}$ itself, should we not say that $\mathbb{Z}$ is dense in $\mathbb{Z}$? After all, it is possible to "approach" all the points in $\mathbb{Z}$ (extremely well!) by points of $\mathbb{Z}$, namely themselves. (You can "approach" 0 by the sequence $(0,0,0,0,0,\dots)$.
But according to your proposed definition, $\mathbb{Z}$ would not be dense in $\mathbb{Z}$, since the derived set of $\mathbb{Z}$ is empty.
So your definition is not equivalent to the usual definition of "dense". One could argue about which definition better deserves the name of "dense", but the majority has already spoken and is not going to change their minds now. | stackexchange-math | {
"answer_score": 3,
"question_score": 1,
"tags": "general topology"
} |
What is a "functional drink" 机能饮料?
I spotted this at the supermarket on in Beijing.

**Question** : What is a "functional drink" ?
The translation seems close to correct:
* = "function"
* = "drink"
My best guess is that it's a drink suitable for a "function", e.g., a wedding banquet. But I don't think has that meaning (it'd be = "activity"). | More commonly known as , these kinds of "fad" drinks are sold to convey a kind of health benefit, commonly advertised as increasing organ (heart, pancreas, eyes, ...) function. Think herbal or vitamin drinks. | stackexchange-chinese | {
"answer_score": 6,
"question_score": 3,
"tags": "translation"
} |
How does Ubuntu handle looking at a Windows Raid?
If I install Ubuntu on hard drive A and mount (via nautilus) hard drive B that has Windows 7 installed on it with a RAID1, could Ubuntu even remotely screw up the RAID Controller? Or would it look at it like a normal single hard drive not in RAID?
I believe the RAID 1 is FakeRAID since I don't have a hardware raid controller card.
I can't afford to risk losing the RAID1 setup so I'm just double checking. ^^
-Thanks | From the looks of it, I can't tell if you've used up your Fake RAID volumes free space. If you haven't then you could add an additional partition in the Ubuntu installer which does support fakeraid. If Ubuntu is already up the just:
sudo apt-get install -y dmraid
sudo reboot
and the fake raid volume should be present in `/dev/mapper` | stackexchange-askubuntu | {
"answer_score": 0,
"question_score": 2,
"tags": "nautilus, windows 7, raid, dmraid"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.