INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Get multiline substring using regexp
How can I get part of the text using regex?
Text:
#first#Cat Dog
Fox
#second#Table Window
#third#Apple Orange
;
So I need to get only
#first#Cat Dog
Fox
I tried:
#first#.*
But it works only for single line strings
|
Seems you're looking for a _**tempered greedy token**_ :
^#(?P<key>[^#]+)#(?P<values>(?:(?!^#)[\s\S])+)
See **a demo on regex101.com**.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "regex, robotframework"
}
|
Double counting in combinatorial formulae.
I've just started learning combinatorics, and have the following problem in reasoning.
One of the formulae for ${n \choose k}$ is: $${n \choose k} =\frac{n!}{(n-k)!k!}= \frac{n \ \times \ (n-1) \ \times \ (n-2) \ \times \ ... \ \times \ (n-k+1)}{k \ \times \ (k-1) \ \times \ (k-2) \ \times \ ...\ \times \ 1}$$
My understanding is that we need the denominator to avoid the problem of counting multiple times. For example, this would help avoiding counting the sets {1,2,3,4} and {2,1,4,3} twice, if we want to count the number of 4-elements subsets of n elements.
My problem lies in analyzing other combinatorial situations, where I often don't know if I need to do something similar to the above. Am I correct to assume that every time we actually want all $k!$ permutations to be counted (i.e. we don't mind and actually need both {1,2,3,4} and {2,1,4,3} in the example above to be counted), then we don't have to worry about double counting?
|
You are right. When you want to arrange $ k $ from total $ n $ elements and order is counted, there are $$ A_n^k=\frac{n!}{(n-k)!}={n\choose k}\cdot k! $$
ways to do this! You can take it as first choosing $ k $ elements without considering the order, then you permute them in all possible ways.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 0,
"tags": "combinatorics"
}
|
On an isomorphism between quotient spaces
Let $X$ and $Y$ be Banach spaces. Let $M$ be a closed subspace of $X$ and let $N$ be a closed subspace of $Y$.
Suppose that the map $T:X \longrightarrow Y$ is an isometric isomorphism and suppose that the restriction map $T|_M:M \longrightarrow N$ also is an isometric isomorphism.
Is it true that the quotient spaces $X/M$ and $Y/N$ are isometrically isomorphic, too? My intuition says that the answer is affirmative. In this case, what would be the relevant isometry between $X/M$ and $Y/N$?
|
Let $y \in Y$, then $\|[y]]| = \inf_{n \in N} \|y+n\|$. Since $y = Tx$ for some $x\in X$ and $n = Tm$ for some $m \in M$, we see that $\|[y]]| = \inf_{m \in M} \|Tx + Tm\| = \inf_{m \in M} \|T(x+m)\| = \inf_{m \in M} \|x+m\| = \|[x]\|$.
In particular, the map $[T][x] = [Tx]$ is an isometric isomorphism.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 1,
"tags": "functional analysis"
}
|
How to make a shrink-to-fit container with max-height and scrollbars in the content area?
I am trying to achieve something like a regular windows' window with a title and a scrollable content area. The `.frame` shrinks to fit its variable size content and is limited only by `max-width`/`max-height`:
<div class="frame">
<div class="title">title</div>
<div class="content scrollable">content of variable width/height</div>
</div>
So, basically, no outer `width`/`height` are set, the `.frame` `width`/`height` is limited just by `max-width`, `max-height`, other than that the `.frame` shrinks to fit its content. The result will look like just a regular windows window with a titlebar and variable `width`/`height` content, which should scroll if the frame's `height`/`width` exceeds some max values.
How can it be done in CSS?
|
div.frame
{
max-width: 400px;
max-height: 200px;
overflow: auto;
}
Fiddle
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "html, css, scroll, containers"
}
|
PayPal Payment Button - Does it make e-commerce application less reputable?
This is meant to be a subjective question on whether or not the PayPal Payment Button is considered a "hobby"-level feature in an otherwise professional e-commerce web application.
Personally, I tend to cringe a little when I go to buy something and see a PayPal button in place of an in-house shopping cart. On the other hand, I'm sure my data is a lot safer with PayPal than with a lot of self-hosted services.
Is this a legitimate UI reputability concern, or am I an e-commerce developer snob? Would you worry about this in your applications?
|
A lot of large Internet stores offer PayPal as an option. I pay my cell phone bill with PayPal. PayPal is well trusted and main stream. I don't think it is a "hobby-level" option at all. I'm sure many users would appreciate the extra payment option.
Where you _might_ possibly run into a reputability concern is **if you _only_ offer PayPal** as an option. That might raise a red flag in a lot of users' eyes because it has such a low barrier for entry; contrast that to a merchant account where you have to have a _real_ business to take payments by credit card.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "user interface, e commerce"
}
|
UDP packets not working for scapy?
I made a simple program that tries to send a UDP packet to my ncat server
here is the code:
from scapy.all import *
sr1(IP(dst="127.0.0.1")/UDP(dport=8080)/"TAG1")
but I get nothing from my ncat server, can someone please tell me what I am doing wrong?
|
when developing a network related project, i suggest you install capturing software like tcpdump or wireshark. It hepls you to see what is in the network.
To get all packets to 127.0.0.1 using tcpdump, you may use following command:
tcpdump -i eth0 "dst 127.0.0.1 and dst port 8080"
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "python, scapy"
}
|
Removing different words form a document using R console
I have managed to retrieve a text file but i want to remove different words. I have gone to read.table and have no clue how to use it to help me remove certain words. I have got 300 words and these are some of them. How can remove all these words using the R console? I have two files, one is sk.text which is a whole document and the other one is bash.txt that has got just words, so i want to remove all the words in sk.text that match the words given in bash.text.
with
within
without
work
worked
working
works
would
|
A simple way would be to use
gsub(paste0('\\b',
YOURVECTOROFWORDSTOREMOVE,
'\\b', collapse = '|'),'',YOURSTRING)
which replaces every occurence of the words in the vector surrounded by either end/beginning characters or whitespace with a single space.
but you might want to look at the tm package and work with a corpus object if you have many files like this. there you can remove the words you like simply with
tm_map(YOURCORPUS, removeWords, YOURVECTOROFWORDSTOREMOVE)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -5,
"tags": "r, information retrieval"
}
|
Ergodic theory in mathematics and physics
How is the theory of ergodic measure-preserving transformations related to ergodicity in the physical sense (which I understood as, very very roughly speaking, that a physical system is called ergodic if "averaging" over "states" of the physical system equals the "average" over time)?
I am sorry maybe the question is a bit unspecific for now, but I guess it's still of interest also for others who are about to dive into the subject.
|
They couldn't be related more closely: they're exactly the transformations for which the physical average equals the time average almost everywhere.
Specifically, they observe Birkhoff's ergodic theorem, that $\int_X fd\mu=\lim_{n\rightarrow \infty} \frac{1}{n}\sum_{k=0}^{n-1}f(T^kx), \mu$-almost everywhere, for any integrable $f$. A nice special case is if $f$ is the characteristic function of some subspace of $A$, in which case this says that the sequence $T^kx$ gets into $A$ proportionally often to the measure of $A$ in $X$ for just about every $x$.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 8,
"tags": "dynamical systems, ergodic theory, mathematical physics"
}
|
Is there a text editor that will automatically determine whether to indent with spaces or tabs?
It's very easy to set a text editor to use spaces or tab characters with each press of the tab key. However, I'm working with a grip of Python code maintained by a large team of developers in my company, and some use spaces and some use tabs. I cannot simply make them all conform with each other, because 1) it would break git blame, 2) it would muddle git diff, and 3) it would inevitably break the build the next time another editor hits their tab key in one of the files.
Instead, I'd like a text editor that automatically determines whether a file is indented by spaces or tabs and then conforms to the existing layout. Does anybody know if something like this exists?
|
Sublime Text does this.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 5,
"tags": "python, editor, tabs, indentation, spaces"
}
|
Find closest to the number inside array
I have below array
const floorPerDayMilestones = [25, 50, 75, 100, 125, 150, 175, 200]
From the frontEnd user enters any number say it is
const number = 136
I need to find closest to the number but the lesser one. So the output should be `125`
Even if the number is `149` the output should be `125`
How can I do this. I tried many way but could get the answer.
Thanks!!!
|
If it's sorted in ascending order like in the question this should work.
const floorPerDayMilestones = [25, 50, 75, 100, 125, 150, 175, 200];
const number = 136;
function findClosest(arr, num) {
for (let i = 0; i < arr.length; ++i) {
if (arr[i] > num) {
return arr[i - 1];
}
}
}
console.log(findClosest(floorPerDayMilestones,number));
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "javascript, arrays, lodash"
}
|
Algorithm to approximate roots using blackbox root counting function
I am looking for an algorithm to do the following.
**Given** :
* An interval $[a,b]$.
* A black box function $n(x)$ which returns the number of roots (zeros) of a function that lie to the left of $x$. That is, for some function $f(y)$, $n(x)$ returns a count of all $y$ such that $f(y)=0$ and $y<x$.
**Find** : Approximations to _all_ of the roots of the function in $[a,b]$ using few invocations of $n(x)$.
It would be nice if there was a tunable parameter to trade off accuracy of approximations and the number of invocations. Also, it is sufficient to indicate a cluster of nearby roots without resolving all of them.
**Quick edit** : I know about algorithms like bisection, which work for single roots. I'm wondering if wanting all the roots at once might save on function invocations.
|
An obvious algorithm is to look at $n(a)$ and $n(b)$. If the difference is positive then go ahead as the interval is "in play".
Look at $n\left(\frac{a+b}{2}\right)$. If this is equal to either $n(a)$ and $n(b)$ then half the interval is no longer in play; otherwise both halves are in play.
Continue subdividing the subintervals which are in play until your appoximations are close enough.
|
stackexchange-math
|
{
"answer_score": 6,
"question_score": 1,
"tags": "algorithms, numerical methods, roots"
}
|
What factors influence whether a lens and camera combination front or back focus?
I know that sometimes a lens/body combo needs to be micro-adjusted to attain ideal focusing behavior, and that this is usually because of sample variation, but which parts of the lens and/or body are actually the primary causes of front/back focus?
|
It can be any number of different things. It all comes down to the tolerences that consumer cameras are built to.
Typical suspects would include:
* Lens Element locations
* Flange-to-film distance
* Sensor location
* Focus sensor
It is all about the location of the focal plane as outlined here: What is back-focusing?
|
stackexchange-photo
|
{
"answer_score": 3,
"question_score": 4,
"tags": "autofocus, focus, focus adjust, back focus, front focus"
}
|
How to run PHP files on aws s3 bucket?
I have developed my website on aws platform using aws s3 buckets.How do I run php files on my domain?
|
S3 doesn't run any sort of CGI script (PHP, Perl, Ruby, etc). Think of it as a static html and image repository.
If you want to host your PHP application on AWS, consider using AWS Beanstalk. It will launch an environment (server, IP, etc) where you can deploy and run your PHP application easily.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "amazon rds"
}
|
Save parameter from link on page as var in javascript
I apologize for the lack of code on this one. I am totally lost on a starting point.
On a website there is a link such as the following:
`<a href="/mywebsite?accountId=00T122233ABCEFG123&otherInforHere=blablablablabla" target="_blank">This Is My Link</a>`
I am trying to get the accountId of **00T122233ABCEFG123** and use it as a variable. The link that appears above does not have an id, so there is no way to target it other than to find "accountId" on the page, as it only appears in the page once. Any help is greatly appreciated.
|
You could use a selector to target the element based on the `href` attribute, and then extract the value through the URL api
const link = document.querySelector('a[href*="accountId"]');
const href = new URL(link.href);
const id = href.searchParams.get('accountId');
console.log(id);
<a href="/mywebsite?accountId=00T122233ABCEFG123&otherInforHere=blablablablabla" target="_blank">This Is My Link</a>
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -4,
"tags": "javascript"
}
|
Search for string and get count in vi editor
I want to search for a string and find the number of occurrences in a file using the vi editor.
|
:g/xxxx/d
This will delete all the lines with pattern, and report how many deleted. Undo to get them back after.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 118,
"tags": "search, count, vi"
}
|
Installing PostGIS on Windows
I want to create an application platform based on PostGIS data. I read the documentation where I saw the prerequisite to install GEOS, GDAL and Proj4. The main problem is I am using windows platform.
Can anybody refer me where I can get full documentation on how to install PostGIS, GDAL, GEOS, Proj4 on Windows with all their libraries?
|
You don't have to worry about any of those prerequisites when installing PostGIS on Windows. You just need to install the Postgresql installer for your platform. You can then launch the Application Stack Builder to install PostGIS.
!enter image description here
!enter image description here
You can find more detailed installation instructions at the Boston GIS web site.
|
stackexchange-gis
|
{
"answer_score": 29,
"question_score": 20,
"tags": "postgis, installation, windows"
}
|
What is considered a "normal" quantity of outliers
I have a few questions. If you would be so kind to help.
so i am wondering, because this is pretty subjective (imo). **What would you consider a "normal" percentage of outliers in your data set?**
Lets say for example i have a data set of 10 million records and i perform a cluster analysis.
I am asking because i want to be sure that the cluster analysis i do actually does its' job. Would it be sensible to say that if you have an **x** amount of outliers or **x** percentage of them in your data, then my cluster analysis is not really accurate and i should either increase clusters count or change the method?
And if yes. How do you determine that?
Or at the very least examine the data again and rethink my strategy?
Regards,
Emil
|
It depends on your distribution and the model behind it, and also on your definition of an outlier. If you expect a normal distribution of your data points, for example, then you can define an outlier as any point that is outside the $3 \sigma$ interval, which should encompass 99.7% of your data points. In this case, you'd expect that around 0.3% of your data points would be outliers. If it's significantly more, then you should probably look for an error in your data acquisition method. (Side note, if your number of data points is small, you should consider using Student's t-distribution instead of a normal distribution.)
So you need an expected distribution, then you need to define an interval in which you expect a certain percentage of your data based on that distribution, and then you can define anything outside that interval as an outlier.
It's important to note, however, that being an "outlier" does not really mean anything. It always depends on the context.
|
stackexchange-stats
|
{
"answer_score": 0,
"question_score": 0,
"tags": "clustering, outliers"
}
|
How many years before Yakov did Rochel die?
The torah teaches us that when Binyomin was born to Yakov, his wife Rochel died. How old was Yakov Avinu when Rochel died and how many years was that before his petira?
|
Yaakov was 99 when Rachel died. He outlived her by 48 years.
The Talmud (Megilah 17a) says that Yaakov was away from his father for 36 years. The first 14 were at the Yeshiva of Ever, 20 were spent at Lavan's house, and the last two were spent along the way home (at Sukkos and Beis-El), after which Rachel died. Since Yosef was born six years before Yaakov left Lavan, Yosef was 8 years old when Rachel died.
Yosef was 30 when he stood before Pharaoh, and nine years later (seven of plenty and two of famine), Yaakov came to Egypt and was 130 years old. Yaakov died (or not) at the age of 147, seventeen years later, when Yosef was 56.
Thus, Yaakov outlived Rachel by 56 - 8 = 48 years.
|
stackexchange-judaism
|
{
"answer_score": 9,
"question_score": 3,
"tags": "death, avot patriarch fathers, age, rachel imenu"
}
|
How can I override FOSUserBundle autorization in Symfony 2
I'm using FOSUserBundle and i'm looking for the best way to add some autorization logic.
The routes i want to securize always starts with the same pattern :
/admin/{id}/
The ID refers to an entity "Site". The User class has a ManyToOne relation with this entity.
So, i want to check each time if the route called is corresponding to the "Site" stored in my user instance. I checked the documentation to find the best way : creating different roles, using ACL, check manually in each controlers... I don't want to check in each function called but i don't find a easier method, so i'm looking for help.
|
I finally found another solution. I'm not sure if it's the best way but it works.
All my controllers extend an abstract controller with a function __call that check if the session user's website is corresponding to the one passed by the param converter. I change all my controller method vibilility to "protected", and it seems to be good.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php, symfony, fosuserbundle"
}
|
Detect if javascript has stopped
If I use javascript to do important stuff on the client, how do I warn the user if the javascript engine stops due to a uncaught javascript error?
I am interested in replacing the error handling with my own so I can catch any errors that might occur.
|
You can intercept errors in many ways. Here is one, based on the very little information you gave in your question
window.onerror
window.onerror=function(error,URL,line) {
alert("An error "+ error +" occurred.");
}
> Error message (string).
>
> Url where error was raised (string).
>
> Line number where error was raised (number).
other ways are to wrap "dangerous code" in a try/catch construct
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": -3,
"tags": "javascript"
}
|
Getting type/size of `time_t` using ctypes
I'm accessing a C struct which contains some `time_t` fields using python ctypes module.
Given its non completely portable nature, I cannot define these fields statically as of `c_int` or `c_long` type.
How can I define them to make my code portable?
Example C struct definition:
#import <sys/types.h>
#import <time.h>
typedef struct my_struct {
time_t timestap;
uint16_t code;
};
Respective python ctypes structure:
from ctypes import *
c_time = ? # What do I have to put here?
class MyStruct(Structure):
_fields_ = [
('timestamp', c_time),
('code', c_int16),
]
|
Your best bet is by introspecting the system your script runs on and making a best bet on which integral type to use. Something like,
if sys.platform == 'win32':
time_t = ctypes.c_uint64
# ...
The bottom line is that `time_t` is not defined in the standard. It's up to the OS and compiler. So your definition of `time_t` in your Python script depends on the DLL/so you are interacting with.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 13,
"tags": "python, c, struct, ctypes"
}
|
How Do You Get the Name For A Specific Value In A Powershell Hash Table?
If I have a hash table like..
$theHash = @{"dog"="mean"; "cat"="nice";"bird"="annoying"}
I can get the key for a value by doing:
$theHash."dog"
How do I do the reverse? I want to put in something like, "mean" and get "dog" as the output? So if I only know "mean", how do I get dog from that?
|
$theHash.keys | Where-Object {$theHash["$_"] -eq 'mean'}
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 8,
"tags": "powershell, powershell 2.0, powershell 3.0"
}
|
Can i use mvc.net validation attributes inside kendo templates?
I'm using mvc html textbox helper inside kendo template. I get incorrect validation attribute value for regexp validation. For example "^([a-zA-Z0-9\s-]){0,}$" becomes "^([a-zA-Z0-9s-]){0,}$" - symbol "\" missing. When i'm trying to escape symbols on the server side it becomes valid on the client side and unvalid on the server but i need valid regexp on both. How i can fix this problem. I need to use mvc helper because it retrieves validation attributes from model metadata.
|
Indeed the slashes within kendo template are used to escaped special symbols. In your case I would suggest you to escape the slahes with extra shales.
Here is what I tried on my side:
<form id="myForm" action="/" method="post">
<div id="result">
</div>
<input type="submit" value="Go" />
</form>
<script id="foo" type="text/kendo">
templatE:
@Html.TextBoxFor(m=>m.Name)
</script>
<script type="text/javascript">
var html = $('#foo').html().replace(/\\/g, '\\\\');
html = html.replace(/#/g, /\#/);
var template = kendo.template(html);
$('#result').html(template({}));
$('#myForm').kendoValidator();
</script>
Where the model is decorated with the following attribute:
[RegularExpression(@"^([a-zA-Z0-9\s\-]){0,}$")]
public string Name { get; set; }
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "kendo ui"
}
|
List running Jupyter notebooks and tokens
How do you check the login tokens for all running jupyter notebook instances?
Example: you have a notebook running in `tmux` or `screen` permanently, and login in remotely through `ssh`. Sometimes, particularly if you're logging in after a long time, the token is requested again in order to access the notebook session. How do you get hold of the token without having to kill and restart the notebook session with a new token?
|
**UPDATE**
You can now just run `jupyter notebook list` in the terminal to get the running jupyter sessions with tokens.
 otherwise the sessions will list without the associated tokens. Eg: The above reference screenshot is from the conda environment.
**Old answer:**
Run ipython and enter the following:
> ipython
[1] : system("jupyter" "notebook" "list")
Out[1]:
['Currently running servers:',' :: /u/user/dir']
If the notebook is running on a remote server, you will have to login in to that server first before running ipython.
|
stackexchange-stackoverflow
|
{
"answer_score": 162,
"question_score": 105,
"tags": "python, ssh, jupyter, tmux, gnu screen"
}
|
iPhone - How may I work with Monday as first day of week
I'm working with many dates. For an international work, I'd like to force (and be able to let the user decide) which is the first day of week.
But, once this is setted (let's say Minday as first day of week), I'm searching the best way to work in my code. I see that EKSunday is 1 and EKMonday is 2.
How can I convert dynamicaly Sunday to 7 and Monday to 1 ? Am I obliged to convert each return value from different method calls (when working with components for example with the weekDay return value) ? Is there any way to foce this once for all and don't have to deal with conversion ?
|
Why not use the existing enumeration for coding purposes and use the first-day-of-the-week preference just to display? That way, you won't have to rebuild any existing functionality.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "iphone, internationalization, nsdate, dayofweek"
}
|
Professional Python Frameworks for Google App Engine, in 2012?
I am a C# (windows apps) developer, so getting started with Python on GAE, I am at a bit of a loss as to what frameworks (or API's, etc) to use for "professional site development"
For example I see: Backbone, web2py, django, Enyo, Kendo, Meteor, Node.js etc etc.
Some of these seem to be full web app frameworks, some javascript frameworks, some javascript UI frameworks... some (like Node.js) from my research do not seem to work on GAE.
so my question: **Could a professional Python dev please give me a suggestion for framework(s) a small (5 person) dev team could pursue for rich "web 2.0" GAE/Python site development?**
Thank you so much, and sorry for being unspecific, just without industry experience, it is very difficult to objectively evaluate the best choice.
|
In web development, client-side (javascript) frameworks are mostly separate from server-side (python) frameworks, so "a Python framework ... for rich "web 2.0" development" does not make much sense - any of Python web frameworks can serve as a backend for your "web 2.0" application.
So, basically, you find a Python framework which suits your needs and works with GAE, then you find a JS framework which suits your needs and possibly has an integration layer with your Python framework, although the latter is not really important.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "python, google app engine"
}
|
How to create and execute a batch file in vbscript?
I tried to do it this way:
Dim objFSO, outFile, wshShell
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set outFile = objFSO.CreateTextFile("paint.bat", True)
outFile.WriteLine "taskkill /f /im mspaint.exe"
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run "paint.bat", 0, false
that was to work but of an error saying "The file is already being used by another process"
|
The file is already being used by your own `cscript` or `wscript` process. You should use `outFile.Close` (and maybe moreover `Set outFile = Nothing`) before `run`.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "batch file, vbscript"
}
|
Aptana "Missing semicolon" warning
Last week I updated Aptana studio to last version (Aptana Studio 3, build: 3.4.2.201308081805). And now shows me warnings everywhere for missing semicolons in my JS files. I know these are optional in JS, and almost useless in some cases like this, which gives me a "missing semicolon" warning:
var LogLevels = {
debug : 4,
info : 3,
warning : 2,
error : 1,
none : 0
}
So, my question is: is there a method to remove just this warning, and just for Javascript in Aptana?
|
I would recommend always using semicolons as good practice as Kevin has said in his comment, but to answer your question.
I do not know of a way to ignore semicolon errors but you can disable javascript validation by going to:
**Window > Preferences > Aptana Studio > Validation**
Then untick Javascript Syntax Validator
|
stackexchange-stackoverflow
|
{
"answer_score": 13,
"question_score": 6,
"tags": "javascript, aptana, aptana3"
}
|
Inner tent - Vango F10 Xenon UL 2
Some time ago I bought Vango F10 Xenon UL 2 tent. Had no chance to use it yet as I had to cancel the trip I was planning on using it on. Now I'm planning something new, but as it's going to be in some warmer areas with no rain I was thinking about using just the inner tent and pitch it without flysheet.
* Is it possible to pitch just the inner part of this tent?
* Does it makes sense? I guess it would protect me from insects, etc, but what would be other advantages of using just the inner tent?
|
This tent is a tunnel tent with the poles inserted into sleeves in the exterior flysheet and the inner tent suspended from inside the flysheet. This means that there is no practical way of pitching the inner tent alone without the flysheet.
You could use the flysheet alone without the inner tent to save weight.
|
stackexchange-outdoors
|
{
"answer_score": 3,
"question_score": 2,
"tags": "camping, tents"
}
|
Rename key of typescript object type
I have this:
type Two = {
one: number,
two: string,
three: boolean
}
I want it to create a type that would look like this:
type RenamedTwo = {
one: number,
two: string,
four: boolean // difference
}
Tried to create it this way:
type Rename<T, K extends keyof T, N> = Pick<T, Exclude<keyof T, K>> & { [N]: T[K] }
In an attempt to use this way:
type Renamed = Rename<Two, 'three', 'four'>
But TSlint marks `[N]` as error and gives this error message:
> [ts] A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. [ts] 'N' only refers to a type, but is being used as a value here.
|
You need to use a mapped type for the renamed property as well:
type Two = {
one: number,
two: string,
three: boolean
}
type Rename<T, K extends keyof T, N extends string> = Pick<T, Exclude<keyof T, K>> & { [P in N]: T[K] }
type Renamed = Rename<Two, 'three', 'four'>
Note that this will not work as expected if you provide more properties:
type Renamed = Rename<Two, 'two' |'three' , 'four' | 'five'> // will be Pick<Two, "one"> & {
// four: string | boolean;
// five: string | boolean;
// }
|
stackexchange-stackoverflow
|
{
"answer_score": 19,
"question_score": 16,
"tags": "typescript"
}
|
Are there any independently verifiable auth token mechanisms?
I'm looking at building a set of services that require an auth system but ideally I'd want them to be able validate these tokens without hitting a central auth service to check for every request.
Are there any known ways of doing this, better than something like a signed expiry-stamped permission enumeration?
|
JWT should suit you well, but it is actually a singed (or also encrypted if you need), expire-stamped list of data.
Keep in mind that there is no way to revoke (logout) such stateless tokens, what, depending on situation, might be a non-issue or a complicated problem to solve.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "authentication, permissions, token"
}
|
Fast way to build a hash set, single or multiple thread?
i want to know which why is faster to build a hashset.
my process like this:
1, DB access (single thread) , get a **large** list of IDs.
2,
Plan A
foreach( var oneID in IDs)
{
myHashSet.add(oneID);
}
Plan B
Parallel.ForEach(IDs,myPallOpt,(oneID)=>
{
myHashSet.add(oneID);
});
So which is faster Plan A or B?
Thanks
|
`HashSet<T>` is not thread safe, so the second option (using `Parallel.ForEach`) will likely cause bugs. It should definitely be avoided.
The best option is likely to just build the hashset directly from the results:
var myHashSet = new HashSet<int>(IDs);
Note that this only works if the `HashSet` is only intended to contain the items from this collection. If you're adding to an existing `HashSet<T>`, a `foreach` (your first option) is likely the best option.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "c#, multithreading, hash, hashset"
}
|
Typolink across domain using SSL behind proxy
There are two page trees in my TYPO3 and I link between them. Both websites use an SSL/TLS encryption for the frontend delivery and thus should only generate relative links (if on the same domain) or link to my second domain (which it does, but only using http and not https).
Now the reason for this seems clear: I've never told TYPO3 to only generate https links. The question is: how would I do that in the first place?
I've come accross the possibility to work with `config.absRelPrefix` but this doesn't work when linking across domains.
|
Apparently, `config.typolinkCheckRootline = 1` as well as any combination of `config.absRelPrefix` and `config.baseUrl` won't help it, if TYPO3 get's the wrong HTTP host and only get's the host via `HTTP_X_FORWARDED_HOST` env var.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "ssl, typo3, cross domain, typolink"
}
|
how to display a number on text view which was stored in variable
i want to display a number assigned to variable on text view ... how to show number on text view
|
myTextView.text = [NSString stringWithFormat:@"%d", yourNumberVariable]
You should adjust "%d" to whatever the type of the variable is.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "iphone, uitextview"
}
|
'Incomplete' where clause still runs
I accidentally built the following sql but it still runs. The query returns all records from a mysql database. Where would this type of query be used?
SELECT student_2.Name
, student_2.Student_ID
FROM student student_2
WHERE student_2.Student_ID
The query I wanted to build is this one:
SELECT student_2.Name
, student_2.Student_ID
FROM student student_2
WHERE student_2.Student_ID = ?
? being some integer.
|
MySQL treats _boolean_ as a valid type. In general, booleans are converted to integers, with `0` for false and `1` for true. In fact, `0` is false, and any non-`NULL` value other than `0` is true.
What your condition is really saying is:
where student_2.Student_ID <> 0
That means that any non-0, non-`NULL` value will match.
This is sometimes used with functions that return `0` for a non-match. So, sometimes you will find:
where find_in_set(id, @ids)
rather than:
where find_in_set(id, @ids) > 0
Note that this is a MySQL extension to standard SQL, so most other databases would not support this syntax.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 0,
"tags": "mysql, sql"
}
|
Temporary ASP.NET Files - duplicate file problem
I get an error when ever I replace a user control, or dll on th website. The solution is to stop iis and delete the contents of the folder, obviously not ideal to stop the site.
I read that this might be caused by class names being reused, as in when you make a copy of a control and add it to the solution.
Is it typical for this folder to be used, how can I avoid the site crashing whenever I make a change
Running on IIS7.0, ASP.NET 3.5
|
I get this problem if I update DLLs and don't clear out the BIN folder, because of the way my code is setup. For example, if I am using version 3.0.1 of a DLL and I add version 3.5.0 of that DLL, it causes conflicts.
As far as a solution, I would agree with the first answer though, which is to have a dev server and a live one, and publish up, although it may not be ideal for your situation.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "asp.net, iis, .net 3.5, web applications"
}
|
Set language of PasswordResetForm in Django?
I am manually resetting passwords but wonder how to set the language to the user's language instead of my own. I see there are many extra context fields but which one needs to be set?
for user in qs:
reset_form = PasswordResetForm({'email': user.email})
# reset_form.language?
assert reset_form.is_valid()
reset_form.save(request=request)
I have added a field `CustomUser.language` which would be available in `user.language` above.
_(While phrasing my question and looking for possibilities I found a working solution.)_
|
I came to the following solution, by setting the current language (session-wise) temporarily to the user's language:
from django.utils import translation
temp_language = translation.get_language_from_request(request)
for user in qs:
translation.activate(user.language)
request.LANGUAGE_CODE = translation.get_language()
reset_form = PasswordResetForm({'email': user.email})
assert reset_form.is_valid()
reset_form.save(request=request)
#
translation.deactivate()
translation.activate(temp_language)
request.LANGUAGE_CODE = translation.get_language()
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, django, django i18n"
}
|
How can i force the user to click the notification
Is there any way to make the user not able to cancel a notification? Only in one case if he taps it? If so, how?
My notification flags are here:
notificationIntent.setFlags(
Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(
context, 0, notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
|
replace
notification.flags |= Notification.FLAG_AUTO_CANCEL;
by
notification.flags = Notification.FLAG_ONGOING_EVENT;
after it'll be "ongoing" you'll need to handle click on it and use NotificationManager.cancel()) to remove it.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java, android, notifications, push notification"
}
|
Caliburn.Micro: Views and Bootstrapper in different Projects
I am playing around with Caliburn.Micro an have a small problem. I like to have one project for the application starter, containing the bootstrapping, configuration files and so on. The UI of the application is then organized in an own project. This works fine with Prism but it seems to me that caliburn does not like it if the UI and bootstrapper are separated. Is this correct or do I miss some thing?
edit: I reference the bootstrapper in the app.xaml. The bootstrapper looks currently just like this:
public class AppBootstrapper : Bootstrapper<MainViewModel>
{
}
The ViewModel is in another project and the application window shows "Can not find view for view model..." when I start the application. This does not happen if ViewModel and View are in the same project like the bootstrapper.
|
Override `SelectAssemblies` in the bootstrapper.
Turning logging on can be helpful, CM will tell you the name variations of a view or view model it's trying to locate:
if (Debugger.IsAttached)
LogManager.GetLog = type => new DebugLogger(type);
more info: Is it possible to Create different pojects for Views, ViewModels and Models in a single solution
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 5,
"tags": "wpf, caliburn.micro, bootstrapping"
}
|
Wireless notification when session start in Kubuntu
When kde is charging appears a notifications this one disappears and appears again when my desktop is shown. It says I am connected to a wireless net but this did not happen until I updated the system. This is annoying because the notification doesn't disappears by itself i must click it for that. I tried searching in notifications preferences but I cant find it. Does anyone know how to fix this?
* * *
!Snapshot
|
I believe this can be changed through System Settings -> Application and System Notifications -> Event Source: Notifies About Network Errors -> Active connection state changed. There, uncheck the "Show message in a popup".
Hope this helps. It is truly annoying that the notification doesn't disappear by itself, it would be quite harmless if it did.
|
stackexchange-askubuntu
|
{
"answer_score": 0,
"question_score": 0,
"tags": "kubuntu, kde, notification"
}
|
Free jquery based scheduler to use in enterprise projects
I've been struggling to find a component like fullcalendar / dhtmlxScheduler/ jqwidgets to use in a saas application with free license, any tips? My client thinks that the fullcalendar(Scheduler) $480 license price is a bit high and need it to be free.
|
Essential Schedule for JavaScript is an option if your client qualifies for the community license.
.
Note: I work for Syncfusion.
|
stackexchange-softwarerecs
|
{
"answer_score": 1,
"question_score": 1,
"tags": "gratis, open source, jquery, scheduling, saas"
}
|
Simplifying $\frac{\cosh(4n\theta)-1}{\sinh((2n+1)\theta)+\sinh((2n-1)\theta)}$
I've come across this expression as part of a very separate problem I've been working on: $$\frac{\cosh(4n\theta)-1}{\sinh((2n+1)\theta)+\sinh((2n-1)\theta)}$$ and noticed that whenever one sets $\theta: \sinh(\theta)\in \Bbb N$, the expression always comes out an integer. This leads me to believe there is a nice(-ish?) simplification for this, but I've had no luck finding it thus far.
I know the denominator can be rewritten as $2\sinh(2n\theta)\cosh(\theta)$ but I couldn't see this getting anywhere.
|
$\cosh 2x + 1 = \frac {e^{2x} + e^{-2x} - 2}{2} = \frac {(e^{x} - e^{-x})^2}{2} = 2\sinh^2 x$
The numerator can be rewritten as $2\sinh^2 2n\theta$
As for the denominator
$\cosh a \sinh b = \frac 14 (e^{a}+e^{-a})(e^{b}-e^{-b}) = \frac 14(e^{a+b}-e^{a-b}+e^{b-a}-e^{-(a+b)}) = \frac 12(\sinh(a+b)-\sinh(a-b)) = 2(\sinh(a+b)+\sinh(b-a)$
$a+b = 2n\theta+\theta\\\ -a+b = 2n\theta - \theta\\\ a = \theta\\\ b = 2n\theta$
$\sin(2n\theta +1) + \sin(2n\theta - 1) = 2\cosh \theta\sinh 2n\theta$
$\frac {2\sinh^2 2n\theta}{2(\cosh\theta\sinh 2n\theta)} = \frac {\sinh 2n\theta}{\cosh\theta}$
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "hyperbolic functions"
}
|
Get font name of .ttf file
Lets say there is a .ttf (True Type Font) file. You can install it on windows with a click. The real name of the font is not the text that is before the .tff (lets say SuperFont.ttf => so the name is not "SuperFont" - it could be, but mostly not). I would like to read the .tff (somehow?) and get the name (without installing the font) of the font. Any ideas?
|
You'll need to add the font to a private collection (`PrivateFontCollection`), then request the `FontFamily` instance and get its `Name` property.
Like this:
PrivateFontCollection fontCol = new PrivateFontCollection();
fontCol.AddFontFile(@"PATH TO FONT");
Console.WriteLine(fontCol.Families[0].Name);
You'll need the namespaces:
using System.Drawing;
using System.Drawing.Text;
MSDN: PrivateFontCollection, FontFamily
|
stackexchange-stackoverflow
|
{
"answer_score": 26,
"question_score": 13,
"tags": "c#, .net, fonts"
}
|
how Google or Facebook keep me login in different web sites
How in different google services like Gmail, youtube pages connected to my account and integrated them.
|
Here you find all the details about Google's login system: <
> Google APIs use OAuth 2.0 for both authentication and authorization. This document describes Google's underlying OAuth 2.0 implementation for authentication, which aligns with the OpenID Connect specification.
and
> Note: If you provide a “sign-in with Google” feature, we recommend using Google+ Sign-In. Google+ Sign-In is built on the OAuth 2.0 and OpenID Connect protocols. It supports over-the-air installs, social features, and a sign-in widget on top of standardized OpenID Connect sign-in flows. Google+ Sign-In works for all users with a Google account, whether or not they have upgraded to Google+.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "authentication, oauth, authorization, integrated"
}
|
Django ordering using filtered foreignkey
I have the following setup
class ModelA(Model):
field = CharField()
order = IntegerField()
class Meta:
ordering: ['order']
class UserOrder(Model):
modela = ForeignKey(ModelA)
user = ForeignKey(User)
order = IntegerField()
class Meta:
unique_together = ['modela', 'user']
I'd like to order ModelA by the custom order stored in UserOrder. I can do this in SQL a follows:
SELECT * FROM modela a
LEFT JOIN userorder uo ON a.id = uo.modela_id
WHERE uo.user_id = 1
ORDER BY uo.order ASC, a.order ASC;
This will order by a custom order first, and the default order second.
I currently filter the queryset, and order it after the DB call, but I was hoping there was a way to order it right out of the DB in a single call using the Django ORM.
|
I sum up:
ModelA.objects.filter(userorder__user__id=1).order_by('userorder__order', 'order')
and Querysets in django are lazy, it means, as Daniel wrote, you can write your ORM how you want and at the end, it will be a single db call once the queryset is evaluated.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, sql, django"
}
|
Limit Django UpdateView to author
I've got a UpdateView in Django that I need to restrict to only the author. I having trouble grabbing the Author off of the request.
class MyPermissionMixin(LoginRequiredMixin, UserPassesTestMixin):
def dispatch(self, request, *args, **kwargs):
user_test_result = self.get_test_func()()
if request.user != ????.user: #How do I grab the user('Author')??
return self.handle_no_permission()
return super().dispatch(request, *args, **kwargs)
|
Get Autor instance user through `self.get_object()`
class MyPermissionMixin(object):
def dispatch(self, request, *args, **kwargs):
if request.user != self.get_object().author:
return HttpResponseForbidden()
return super().dispatch(request, *args, **kwargs)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "django, django views"
}
|
Compiling all LESS files in the solution into a single file
I have lots of .less files in my solution, one per page.
I want to add a build step that quickly runs through my solution and puts all the files ending in .less into one massive .less file.
I've not found anything that specifically does this via google. I don't want to compile to CSS, at least not at this point.
Is there a tool out there that will do this? Or should I write one myself?
|
you can run a powershell script in a postbuildevent:
ls d:\temp\ -r -i *.less| gc | sc -enc UTF8 d:\temp\allless.less
* `d:\temp\` is your root solution folder
* `d:\temp\allless.less` the resulting file
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "visual studio, less"
}
|
What is a well balanced party setup for Wizardry 8?
It is a while since I played Wizardry 8 and I actually forgot a lot about the game. So while trying to do a good party, I had a lot of problems at the start, especially with ranged enemies.
**How do you set up your party so it is well balanced against each close combat and ranged enemies?**
|
Ah, Wizardry 8. Such a lovely (and occasionally annoying) game. The question is a bit ambiguous since a well composed party is somewhat up toyou and what you like. But my most successful playthough I think I went with
* Fighter - Lizardman
* Lord - Dracon
* Samurai - Felpurr
* Gadgeteer - Hobbit
* Priest - Rawulf
* Mage - Faerie
Pretty standard with heavy fighters in the front and ranged in tha back. One thing you should note is that if you go with gadgeteer or bard you should go female. There is a necklace that regenerates stamina and it can only be worn by females. Also there are quite a few items that can be worn by only a certain race and class combo. Such as the Cane of Corpus which only a faerie ninja can wield.
In the end, it's really up to you. But you can't go wrong with the old standard RPG party - heavy fighters, ranged a healer and offensive casters.
|
stackexchange-gaming
|
{
"answer_score": 3,
"question_score": 4,
"tags": "wizardry 8"
}
|
What is Bitcoin's "genesis hash"?
From Lightning Network documentation:
> Used in several of the BOLT documents to denote the genesis hash of a target blockchain. This allows nodes to create and reference channels on several blockchains. Nodes are to ignore any messages that reference a chain_hash that are unknown to them. Unlike bitcoin-cli, the hash is not reversed but is used directly.
>
> For the main chain Bitcoin blockchain, the chain_hash value MUST be (encoded in hex): 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000.
However this wiki entry about Bitcoin's genesis block has
> GetHash() = 0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
Indeed, inputting the latter value into blockchain.info yields Block 0, while the former value cannot be found on blockchain.info.
Why does the value `6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000` appear in Lightning Network as "Bitcoin's genesis hash"?
|
They're exactly the same number; one is written in little endian notation and the other is big endian. Notice that the bytes (two-hex-digit pairs) are exactly reversed from one to the other.
Block explorers like blockchain.info usually expect big-endian for block hashes. The proof-of-work requirement means that the _most_ significant bits have to be zero, so big endian makes it easier to see this.
|
stackexchange-bitcoin
|
{
"answer_score": 8,
"question_score": 2,
"tags": "lightning network, hash, genesis block, endianness"
}
|
logging app name along with other information of an api call in wso2 api manager
In http access log section of api manager documentation has been explained how to create a custom log for each http request to api gateway. it sounds like there is no way to log app name alongside with other information of a request. Can someone explain to me how can I log app name too?
|
You can add a custom sequence as follows.
<?xml version="1.0" encoding="UTF-8"?><sequence xmlns=" name="mockapi">
<header name="backend-key-xyz" scope="transport" expression="get-property('api.ut.application.name')"/>
</sequence>
Keys can be found here - <
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "logging, wso2 api manager"
}
|
How to prove $\mathrm{E}(e^{tX}) \le \exp(t^2\mathrm{Var}(X))$ where $|X|\le 1$ and $\mathrm{E}(X)=0$?
Let $X$ be a random variable with $|X|\le1$ and $\mathrm{E}(X)=0$. Then for any $-1\le t\le1$, prove that $$\mathrm{E}(e^{tX}) \le \exp(t^2\mathrm{Var}(X)).$$
Maybe it is about Jensen inequality but I only get $\mathrm{E}(e^{tX}) \ge e^{t\mathrm{E}(X)} = 1$. And I used Taylor expansion but doesn't work.
|
Applying Taylor expansion we have $$e^{tx} = 1+tx+\frac12t^2x^2+\sum_{i=3}^\infty\frac{t^ix^i}{i!}$$ $$\exp(t^2E(X^2)) = 1+t^2E(X^2)+\sum_{i=2}^\infty \frac{t^{2i}E^{i}(X^2)}{i!}$$ Since $|t|\leq 1$ and $|x|\leq 1$, we know that $t^kx^k \leq t^2x^2$ for $k\geq 2$, therefore\begin{align*} e^{tx} &\leq 1+tx+\frac12 t^2x^2 + \sum_{i=3}^\infty\frac{t^2x^2}{i!}\\\ &\leq 1+tx+\frac12t^2x^2+t^2x^2\sum_{i=3}^\infty \frac{1}{3^{i-2}}\\\ &= 1+tx+t^2x^2 \end{align*} Thus $$E(e^{tX}) \leq 1+tE(X)+t^2E(X^2) = 1+t^2E(X^2)\leq \exp(t^2E(X^2)) = \exp(t^2Var(X))$$
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 10,
"tags": "probability theory, inequality, expected value"
}
|
When do we flip the inequality?
Suppose $a>b$. What properties must a function $f(x)$ have in order for $f(a)>f(b)$ to be a true? What properties must $g(x)$ have so that $g(a)<g(b)$? Does $f(x)$ have to be monotone increasing and $g(x)$ monotone decreasing?
|
In the first case: $f$ must be strictly decreasing or, if $f$ is differentiable, it is sufficient (but not necessary) that $f'<0$. In the second case, $g$ must be strictly increasing, or $g'>0$.
Note that $g(x)=x^3$ is strictly increasing, even though $g'(0)=0$. A complete answer for a differentiable function $g$ is: $g$ is strictly increasing if $g'\geq0$ everywhere, and the set $\\{x:g'(x)=0\\}$ contains no intervals.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 2,
"tags": "algebra precalculus, inequality"
}
|
How to get all of the IP addresses in a string into a bash array
I have the following string:
redis. 600 IN A 172.16.0.3 redis. 600 IN A 172.16.0.4 redis. 600 IN A 172.16.0.5 redis. 600 IN A 172.16.0.6 redis. 600 IN A 172.16.0.7
The string is obtained from the following command:
dig redis A | grep redis | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
The string is printed out on each line when the command is run, but I save the output to a variable so it's all one line. I want to get all of the IP addresses into a bash array. What's the best way for me to do this?
**Edit:** This post is not a duplicate because the focus of this was how to get the IP addresses, not how to read them into the array.
|
I ended up being able to do it by using awk:
IPAddresses=($(dig redis A | grep redis | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | awk '{print $5}'))
The IPAddresses array has all of the IP addresses in it, and can be printed out by executing `echo "${IPAddresses[@]}"`
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "linux, bash, parsing, ip address"
}
|
listview reusable component - architecture - android
i have a complex view which contains 4 list views arranged as per the requirement. i have been been able to implement and get it working. but this is a sole activity and data needs to supplied internally (within the activity). i want to define a way where in, this complex view is like a reusable component which is called by other activities that provide data for all 4 list views and then the view shows up in the screen.
could somebody please guide me as to how do i go about achieving this functionality.
|
You should define your listview structure in a layout file of its own. Then you can use whats called inflation, which lets you "inject" seperate layout files into your main layout in run-time. Take a look at:
<
Take note at the introductory notes. Android is already inflating an XML resource, namely the layout file you´ve defined in setContentView(), you can grab the current instance of the inflater and use it as you see fit, saving greatly on memory as opposed to instantiating it yourself.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "android, android listview, code reuse"
}
|
8 ball pools, foul rules when only 8 ball is on the table?
What happens if I've only 8 ball remaining, my opponent has his category object balls remaining. I called a pocket for 8 ball but didn't pocket it and it still remains on the table. Will my opponent get a ball in hand foul and can put cue ball anywhere on the table ?
|
No, your opponent can't put cue ball anywhere.
The rules says:
> The shooter fails to strike one of their own object balls (or the 8 ball, if all of said object balls are already pocketed) with the cue ball, before other balls (if any) are contacted by the cue ball.
If these fouls are made, the ball can be placed anywhere on the table to prevent a player from making a purposeful foul to disadvantage the other player. So, the only way your opponent has is if you do not hit the 8 ball.
|
stackexchange-sports
|
{
"answer_score": 1,
"question_score": 1,
"tags": "rules, pool"
}
|
How to change the color of a pixel in an image
I read a single pixel out of an image using the following code:
private void CheckArea(Point where)
{
Bitmap test = (Bitmap)PanelToBitmap(panel2);
var pixel = test.GetPixel(where.X, where.Y);
}
I want to change the color of this pixel. First I tried to convert it into an image but that doesn't work. Then I tried to change the ARGB-values, but they are write-protected.
How can I change the color of a pixel in an image given a `Point`?
|
you can use :
test.SetPixel(where.X, where.Y, Color.FromArgb(0x78FF0000));
msdn
Color is an immutable structure, so you can't change its values.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "c#, colors"
}
|
Format Kivy popup to eliminate popup background
we're using an image as a popup in our kivy app but can't seem to get the popup's background to fit the size of the image. The resulting popup has the image with a dark gray border around the left side, top, and right side of the image. Can someone help us eliminate the popup's background so that only the image and the semi-transparent filter are visible?
Main.py code:
popup = Popup(title="",
content=Image(source='img/popup'),
auto_dismiss=True,
size_hint=(None, None),
size=(400, 146),
separator_height=0
)
Thanks
|
If you don't have a title, maybe a simple ModalView would better fit your purposes.
Either way, the background is controlled by the `background` and `background_color` properties. To get rid of it entirely, it's probably simplest to set `popup.background_color=(0, 0, 0, 0)` (i.e. transparent).
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "python, kivy"
}
|
Python Selenium Index nested Elements
I have 5
<ul class="rental-facilities">
and multiple `<li class="feature">` within each `<ul class="rental-facilities">`
I would like to index the 3rd rental-facilities class and 1st feature.text class
Ideally 1 line code.
Tried this but doesn't work:
rental = browser.find_elements_by_xpath("//ul[@class='rental-facilities']")[3]
feature = rental.find_elements_by_xpath("//li[@class='feature']")[1].text
Thank you.
|
feature = rental.find_elements_by_xpath(".//li[@class='feature']")[1].text
When xpathing you need a . when referencing from another element instead of driver.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "python, selenium, selenium webdriver, web scraping"
}
|
Linux tr to convert vertical text to horizontal
I've been reading about < and wondering if `tr` alone can be used to convert vertical text to horizontal.
user@linux:~$ seq 3
1
2
3
user@linux:~$
I've tried the following solution, it works but not perfect.
user@linux:~$ seq 3 | tr -d '\n'
123user@linux:~$
user@linux:~$
Would it be possible to used `tr` alone to produce output like this?
**Desired Output**
user@linux:~$ seq 3 | tr command here
123
user@linux:~$
|
Choose whatever works for you.
$ seq 3 | paste -s -d ''
123
$ seq 3 | tr -d '\n';echo
123
$ seq 3 | awk 1 ORS='';echo
123
|
stackexchange-unix
|
{
"answer_score": 7,
"question_score": 3,
"tags": "linux, tr"
}
|
How do I make several things in a ASP.NET event
I have a hidden field
<asp:HiddenField ID="selectedRecievedValue" ClientIDMode="Static" runat="server" />
I then have a TextBox with a onfocus event
<asp:TextBox runat="server" Text='<%# Eval("value") %>' CssClass="rowSpildValue"
onfocus='<%# Eval("data_id", "document.getElementById(\"selectedDataID\").value =
\"{0}\"; document.getElementById(\"selectedFieldID\").value = \"rowSpildValue\";") %>'
OnTextChanged="SpildChanged" AutoPostBack="true" ID="rowSpildValue" />
This already runs some code, but how would I add another line of code that would set my
HiddenField = Eval("deliveredValue")
|
This will work:
<asp:TextBox runat="server" Text='<%# Eval("value") %>' CssClass="rowSpildValue"
onfocus='<%# Eval(
"data_id",
"document.getElementById(\"selectedDataID\").value = \"{0}\";" +
"document.getElementById(\"selectedFieldID\").value = \"rowSpildValue\";") +
Eval(
"deliveredValue",
"document.getElementById(\"selectedRecievedValue\").value=\"{0}\"") %>'
OnTextChanged="SpildChanged" AutoPostBack="true" ID="rowSpildValue" />
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, asp.net"
}
|
Get all the user's name or total number of user in particular area in Google map
I have a list of user's and their details stored in db with latitudes and longitudes. I need to make query,
When any single user want's to display how many user's available in nearest 200m from his position in Google map.
Plz tell me how's its possible to get all the user's name or total number of user in particular area.
|
I use this query to get the radius from lat long.
SELECT
*,
( 6371 * acos( cos( radians({$lat}) ) * cos( radians( `lat` ) ) * cos( radians( `lng` ) - radians({$lng}) ) + sin( radians({$lat}) ) * sin( radians( `lat` ) ) ) ) AS distance
FROM `positions`
HAVING distance <= {$radius}
ORDER BY distance ASC
6371 is the earth radius im km.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "php, android, json"
}
|
Dell laptop hangs on bootup
I've got a Dell 1535 Studio laptop. It's hanging on boot up. It's just at the dell load up screen at the VERY start of boot up. Sometimes it doesn't even display the bootup screen and when it does it normally spouts out something like the following error:
`Memory write/read failure at 00560644 read 563956b9 expecting 56b956b9
To resolve this issue try to reseat the memory`
I've tried reseating the memory, anyone have any other ideas?
|
It definitely sounds like a memory issue.
Does your laptop have multiple memory chips installed? If so, try leaving only 1 chip installed to see if you can identify the bad memory chip.
If you only have 1 chip installed, see if you can borrow a compatible memory chip from a friend or your local computer repair shop (may need to do that one in store) to see if replacing the memory resolves the issue.
|
stackexchange-superuser
|
{
"answer_score": 1,
"question_score": 0,
"tags": "laptop, boot, memory, dell studio"
}
|
(Fundamental) difference of Seebeck effect for metals and semiconductors
In which way is the Seebeck effect different for semiconductors from metals and why is it greater? What is the difference in the underlying physical principle?
My knowledge so far is: Bring two materials in touch, doesn't matter which, their electrochemical potentials will align but the electrical potentials will differ which causes the generating voltage. I don't see how semiconductors are different here as it seems to be a very general principle.
|
I think the answer has to do with the relation between the Seebeck coefficient and the electrical conductivity's dependence on energy, known as the Mott Formula (<
In short, the model that leads to the formula yields to a Seebeck coefficient that is proportional to -T for metals, with a very small factor (proportional to $T/T_F$ where the Fermi temperature is much bigger than the absolute temperature) and so yields low values.
However for semiconductors, one has to check the band structures according to the doping level and again how the electrical conductivity depends on the energy. It turns out that the prefactors in the different Mott formulae are not as small as in the case of a metal, apparently because transport does not occur near the Fermi level in this case.
|
stackexchange-physics
|
{
"answer_score": 1,
"question_score": 3,
"tags": "thermodynamics, semiconductor physics, metals, thermoelectricity"
}
|
Error running Sql Assembly
I have a .net assembly build in to sql. It works on all other sql servers, except on one system I get this error.
A .NET Framework error occurred during execution of user-defined routine or aggregate "GetCustomerData":
System.IO.FileLoadException: The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
System.IO.FileLoadException:
at System.Diagnostics.TraceSource.Initialize()
at System.Net.Logging.InitializeLogging()
at System.Net.Logging.get_On()
at System.Net.WebClient.DownloadString(Uri address)
at System.Net.WebClient.DownloadString(String address)
at CustFromPhone.BaseFunctionClass.GetCustInfo(SqlString PhoneNo)
|
You simply have wrong manifest data for your .NET binaries
> An assembly manifest contains all the metadata needed to specify the assembly's version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes. <
This is why its corrected when you rebuild it.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": ".net, sql server 2008, assemblies"
}
|
"market://details?id=" + appPackageName opens the app not the playstore page
i asked a question on how should i open the playstore page using an app link on my app. i got an answer to use "market://details?id=" \+ appPackageName to open the play store app but instead of opening the playstore page its re opening my app. whats the fix?
enter code here
protected void Updateclick(View view) {
String appPackageName="io.kodular.samithuaz.smartQ";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
}
|
Try this.You need to specify proper store URI for the different stores. take reference link
protected void Updateclick(View view) {
final String appPackageName = getPackageName();
try {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse(" + appPackageName)));
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java, android"
}
|
ClearCase single stream UCM project: When are changes visible in a snapshot view?
Consider a single stream UCM project in ClearCase.
Each developer works in her own snapshot view on the integration stream of the project.
According to the ClearCase documentation when a developer completes an activity, the changes made by the activity become visible to the rest of the developers.
When developer `A` completes an activity `P`, are the changes of `P` immediately visible to developer `B` and `C`?
Or do `B` and `C` have to refresh their snapshot view in order to actually see the changes?
|
For a snapshot view (UCM or not), you always have to "`cleartool update`" your view in order to see the changes committed by your colleagues.
Note: the notion of "completing an activity" might suggest that you are actually using ClearCase with ClearQuest (which will check-in all checked out files associated with an activity, when the related ClearQuest work item is "completed").
This is valid for single-stream UCM projects as well as multi-streams: every time you have several _snapshot_ views on a single stream, you need an update to see your colleagues' commits.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "clearcase, clearcase ucm"
}
|
amp-access type server: when will this be available?
documentation says
_The "server" option is under design discussion and these docs will be updated when it is ready._
Question: is there a timing known for this? Can it already be used?
We want to use AMP for paywalled content.
type="client" is not an option (not safe enough) => type="server" solves this
I understand we could already implement it on our side:
\- when ip is from google range: serving full document
\- when ip is not: excluding/including the appropriate parts
but if I understand it correctly we should not go into production with this yet? We should wait until it is ready and Google AMP Cache supports it, right?
|
Currently there's an experimental approach implemented, publisher that want to use it should contact google group amphtml-discuss (whitelisting of publisher is needed)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "amp html, accelerated mobile page"
}
|
AS3 - References to argument, is that bad?
I read a question on stackoverflow (couldn't find it now) about how variables in a method can be only accessed in that method, but the code still works with the answer being an analogy of a hotel room. In AS3, I believe everything that's not primitive gets passed as a reference. So, the following code would be the same as that question and isn't guaranteed to work?
public class Testy {
private var foo:Array;
public function Testy(input:Array) {
// Allow the whole class to access it
foo = input;
}
public function traceFoo(){
trace(foo);
}
}
Now, foo would be a reference to the input argument in the class' constructor. Is this safe code/good practice? Thanks!
|
Yes this is safe/good code practice as long as you don't want to manipulate the original Array. If you want to manipulate the original array, allow public access to the array by making it a public var or using a public getter/setter.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "actionscript 3, reference, arguments"
}
|
$\frac 12 + \frac 34 +\frac 56 +\cdots$ up to $n$ terms is equal to?
OK,I need to sum summation of this
> $\dfrac 12 + \dfrac 34 +\dfrac 56 +\cdots$ up to $n$ terms $=?$
I came up till here…
$$\sum_{k=1}^{k=n}\dfrac{2k-1}{2k}=?$$
$$\sum_{k=1}^{k=n} 1 - \dfrac{1}{2k}=?$$
But from here I couldn't complete,please help.
|
You want : $$ \sum_{i=1}^n \frac{2i-1}{2i} = \sum_{i=1}^n \left(1 - \frac{1}{2i}\right) = n -\frac12 \sum_{i=1}^n \frac1i $$ However the harmonic sum doesn't have a closed form. You have however several bounds on it. A simple one is : $$ \ln(n+1) \leq \sum_{i=1}^n \frac1i \leq \ln(n) + 1 $$ You can therefore bound your sum by : $$ n - \frac12(\ln(n)+1) \leq \sum_{i=1}^n \frac{2i-1}{2i} \leq n-\frac12\ln(n+1) $$
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "sequences and series, summation"
}
|
Need help for mysql query
In my MySQL table I have a column named `member_id`. That column stores values like this:
1,2,3,4,5
I need to check that by using
SELECT *
FROM member
WHERE 5 IN member_id
It's not working well. Please help me write a SQL query that will find the appropriate results.
|
Use this query:
SELECT *
FROM mytable
WHERE FIND_IN_SET(5, member_id)
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 0,
"tags": "mysql"
}
|
angularjs ng-repeat not working in firebase
how to access items in firebase using angularjs I got how many rows in firebase but not the values
**my code**
<ul class="next-days" >
<li ng-repeat="item in val">
{item.name}
<a href="#43">
<p class="next-days-date"><span class="day">{item.text}</span> <span class="scnd-font-color">{item.price}</span></p>
<p class="next-days-temperature">{item.quan}</p>
</a>
</li>
</ul>
**and my app.js**
var ref = new Firebase("
$scope.val = $firebaseArray(ref);
plunker demo
|
You are just missing a second `{` and `}`, so this works:
<ul class="next-days" >
<li ng-repeat="item in val">
{{item.name}}
<a href="#43">
<p class="next-days-date"><span class="day">{{item.text}</span> <span class="scnd-font-color">{{item.price}}</span></p>
<p class="next-days-temperature">{{item.quan}}</p>
</a>
</li>
</ul>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "angularjs, firebase, angularjs ng repeat"
}
|
There is no option to Add Existing Project
To add a project when i right click to my solution there is no option to
`add -> Existing Project`.
**What should i do to find it?**
!enter image description here
|
Use the File menu to add a project to solution.
File -> Add -> Existing Project
It looks like some of the default VS settings decide to hide the solution item from the Solution Explorer.
You can show it from `Tools -> Options -> Project And Solutions` and checking the checkbox called "Always Show Solution"
(from here)
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 4,
"tags": "c#, visual studio"
}
|
iPhone app crashes when passing data in prepareForSegue:sender
I've been trying to pass data from one tableViewController to another, but as soon as I assign a value to a property in my second tableViewController the app crashes, giving me the message "...unrecognized selector sent to instance 0x715c340...". Here is the code I have used:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:@"displayWordlist"]){
DisplayWordlist *dwl = (DisplayWordlist *)[segue destinationViewController];
dwl.apa = @"hej";
}
}
As soon as the program reaches 'dwl.apa = @"hej";' it crashes. I have both made a property of apa and synthesized it.
|
Make sure you have set the class of this view controller to DisplayWordlist _in the Storyboard_. If you don't, dwl will be assumed to be an instance of UIViewController despite the cast.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "ios, iphone, segue"
}
|
Filter columns contains all substring
i am trying to select all crispy chicken sandwich in datasets, i have tried using this regex but it still got some grilled chicken sandwich. Here is the code
> data_sandwich_crispy = data[data['Item'].str.contains(r'^(?=.*crispy)(?=.*sandwich)(?=.*chicken)', regex=True)]
and here is the look of datasets
any revision, or link to answer is really appreciated. i'm really sorry if there was a mistake, thanks you for all your help!
|
If you meant collecting all rows containing `crispy chicken sandwhich` only, then have a look at this alternative solution below. This will return rows only when all three words (crispy, chicken and classic) are present :
data_sandwich_crispy = df[df['item'].str.contains(r'^(?=.*?\bcrispy\b)(?=.*?\bchicken\b)(?=.*?\bclassic\b).*$',regex=True)]
I created a simple dataframe as shown below:
item id
premium crispy chicken classic sandwhich 10
premium grilled chicken classic sandwhich 15
premium club chicken classic sandwhich 14
running the command given above gives the following output:
item id
premium crispy chicken classic sandwhich 10
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, pandas, contains"
}
|
Do piezoelectric materials produce a current flow or just an electric field?
I was watching a video < about piezoelectric materials.
They mentioned that "a current can flow when a pressure is applied to the material".
I have a problem with this expression. I'm not sure if my confusion is in its place.
I know that when a stress is applied on a piezoelectric material, it will generate an electric field due to the dislocation of the electric charges/ creation of electric dipoles.
But that doesn't mean that a current should flow from the material, because if a current flows, that means the material has lost electrons, therefore has lost some mass.
And in case it was true that the electrons were leaving the material instead of just emitting their electric field while still being connected with the materials molecules, then I think what they mentioned about connecting the material to a circuit and measuring the current flow will make sense.
|
The quartz or other Piezoelectric materials do not work under constant compression, they work under the varying pressure or vibration of the crystal. So they don't lose electrons. They produce an alternating electrical field.
If you apply constant pressure they just go through a very short time of polarization then stop producing the electrical field. But if you apply vibration the electrical field can create a small AC current.
The small voltage is then amplified.
. The magnitude of a complex number $z$ is $|z|$, which is real. Now $z \bar z = |z|^2$, so multiplying by the complex conjugate gives the square of its _magnitude_ , not the square of the complex number itself.
For example, $i^2 = -1$ but $|i|^2 = 1$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "complex numbers, quantum mechanics, square numbers"
}
|
Trig identity manipulation question
I'm working on manipulating trig identities and using Wolfram Alpha to check the identity still holds.
I'm going from this:
$$\frac{1-\cos x}{1+\cos x} = \frac{1}{tan^2x}-\frac{2}{\tan x \sin x} + \frac{1}{\sin^2 x}$$
which WA verifies is an identity to this:
$$\frac{1+\cos x}{1-\cos x} = tan^2x-\frac{\tan x \sin x}{2} + \sin^2 x$$
which WA seems to think is only true for certain values of x.
Based on my workings out on paper, I think I'm safe in flipping both sides. Wonder if someone might weigh in on this to help me out please?
|
The reciprocal of a sum is not equal to the sum of the reciprocals. If $\frac1a=\frac1b+\frac1c, a=\frac{bc}{b+c}$, not $b+c$
Your right side is equal to $(\csc x-\cot x)^2$. If you really want to flip both sides, you'll get
$$\frac{1+\cos x}{1-\cos x}=\frac1{(\csc x-\cot x)^2}=\frac{(\csc x+\cot x)^2}{(\csc^2x-\cot^2x)^2}=$$ $$(\csc x+\cot x)^2=\frac1{\tan^2x}+\frac2{\tan x\sin x}+\frac1{\sin^2x}$$
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 1,
"tags": "algebra precalculus, trigonometry"
}
|
Wrong number format after filter
One of my Wordpress plugin output a price, I want to alter this price with the integrated filter. Here is the source:
$price_str = apply_filters( 'price_format', number_format($price,0,'', '.') );
Add I have added this filter:
function change_price( $price ) {
$price = $price * 2;
return $price;
}
add_filter( 'price_format', 'change_price', 10, 1 );
If the price was 45.000 (Forty Five Thousand) it not becomes 90 (Ninety), I want it to be 90.000.
Why is this?
|
The problem is that PHP takes "45.000" to mean "45", as the dot is the decimal delimiter, while your price uses it to indicate thousands (which some countries to, and they'll use the comma to separate decimals).
function change_price( $price ) {
$price = str_replace(".", "", $price);
$price = $price * 2;
return number_format($price,0, '', '.');
}
add_filter( 'price_format', 'change_price', 10, 1 );
Will work in that case, first removing the thousand seperator, doing the calculation and adding it again in the same format it was originally.
Be aware that if you do have prices that are not integers (think 45000.99), this will round the price to the nearest integer because number_format's third parameter is empty. You can't do a lot about this, since it already occurs in the original function that is applying the filter.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "wordpress, filter, number formatting"
}
|
Cloud Endpoints Portal requires GCP / IAM permissions, otherwise the user gets No APIs are available that you have permission to view
I have Cloud Endpoints Framework implemented in my App Engine project, and I'd like to migrate from the deprecated API Explorer to the new Endpoints Portal.
The thing is, unlike the old API Explorer, the Endpoints Portal is not accessible to everybody. When a user that has no access to the GCP project tries to access the portal, he gets:
> No APIs are available that you have permission to view
 AppleWebKit/534.24 (KHTML, like Gecko) Ubuntu/10.10 Chromium/11.0.696.65 Chrome/11.0.696.65 Safari/534.24"
This hangs for 10 secs on:
`Resolving www.sportsdirect.com... 86.17.5.250`
We're running on Linux.
To confuse things further browsers on the same machine fetch the same page immediately.
Any clues?
|
This is because wget and lynx aren't caching the DNS results, and your browsers may even have IPv6 disabled.
The DNS for `www.sportsdirect.com` is broken, and times out on AAAA records.
You can use the `-4` or `--inet4-only` option to wget to force IPv4 only.
$ time host -t A www.sportsdirect.com
www.sportsdirect.com is an alias for sd.gwcorp.sports-world.com.
sd.gwcorp.sports-world.com has address 86.17.5.250
real 0m0.009s
user 0m0.000s
sys 0m0.000s
$ time host -t AAAA www.sportsdirect.com
;; connection timed out; no servers could be reached
real 0m14.008s
user 0m0.000s
sys 0m0.000s
|
stackexchange-serverfault
|
{
"answer_score": 5,
"question_score": 2,
"tags": "domain name system, http"
}
|
Debian Stretch: Mosquitto Unit mosquitto.service is masked
I'm trying to set up mosquitto under RPi - Debian Stretch.
sudo service mosquitto giving me following returncode:
Failed to start mosquitto.service: Unit mosquitto.service is masked.
sudo service mosquitto status:
mosquitto.service
Loaded: masked (/dev/null; bad)
Active: inactive (dead)
Can somebody give me a hint how to fix it?
Thank you!
|
Fix it with
sudo systemctl unmask mosquitto service
sudo service mosquitto stop
sudo service mosquitto start
Its running now! – Andreas
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "raspberry pi3, mosquitto, debian stretch"
}
|
Go to page section after redirect
I wanted to provide feature where non-logged in users can click on "Rate" button, which will lead them to login and after login they come back to the page. Upto this, it is working fine.
But I want user's to go to particular section of page, `div with id = "id1"`.
How can I achieve this?
\-- Many thanks for your time.
This is what I have tried:
$destination = drupal_get_destination();
$options = array( 'query' => $destination,'fragment'=>'div_id');
print l('Review', 'content/login', $options);
|
This works for me...
$destination = drupal_get_destination();
$destination['destination'] .= '#div_id';
$options = array( 'query' => $destination);
print l('Review', 'content/login', $options);
|
stackexchange-drupal
|
{
"answer_score": 2,
"question_score": 1,
"tags": "7, users, redirection"
}
|
MySQL restoring database functions using frm, myd and myi files
MySQL had an error updating and caused my database to stop working correctly. I had to reinstall mysql during this process I was looking up how to restore my database after reinstalling. I was able to restore the database with all the tables and data inside them using the instructions in the following post:
Restoring database from physical files
But I noticed the functions weren't restored with the rest of the database. Anyhow I was wondering if someone could give me a hand with this?
I am running mysql on an nginx server. All help is appreciated. Thanks!
|
The stored functions and stored procedures for all databases are stored in the `proc` table inside the `mysql` schema.
You'd need to restore the proc.FRM, proc.MYD, etc. files, inside the mysql directory, preferrably with the server stopped, since your reinstalled server already has those -- presumably empty.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "mysql, database, nginx, database restore"
}
|
Flutter Sliver AppBar leading color
This is a Sliver AppBar.
` since (I believe) that the Sliver AppBar has the nice property of adapting the lead icon depending on context.
|
wrap the SliverAppBar widget with Theme widget, and change primaryIconTheme color in ThemeData. Here's the code:
Theme(
data: ThemeData(
primaryIconTheme: IconThemeData(color: Colors.red)),
child: SliverAppBar(),
),
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "flutter, appbar, flutter sliver, sliverappbar, flutter sliverappbar"
}
|
How to format linux mpstat output in multiple lines
I have a small script where I appended the output of linux mpstat to a log file.
#/bin/bash
CPU_USAGE=$(mpstat)
echo $CPU_USAGE >> temp.log
The problem is that the output of mpstat on the terminal is formatted properly in 3 lines like so
.
2. Ability to evaluate whether or not a company's products will be demanded.
3. Detecting trends (e. g. if electric cars are selling like crazy, and in every of them is a battery, it may be a good idea to buy shares of companies, who a) manufacture batteries or b) supply them with raw materials).
If I wanted to learn these skills really thoroughly, how could I do this? What kind of teaching vehicles could you recommend?
|
As foundational material, read "The Intelligent Investor" by Benjamin Graham. It will help prepare you to digest and critically evaluate other investing advice as you form your strategy.
|
stackexchange-money
|
{
"answer_score": 1,
"question_score": 5,
"tags": "financial literacy, starting out investing"
}
|
Email Marketing: sending ID in email
This is a 'best practice' question:
Should we be sending a Salesforce GUID in an email? We have a button in an email to ask them for consent (to a thing). That button links to a VF Page or a Marketing cloud page (we can go either way). In either case the query string will contain the ID of the lead.
My contention is that a user could change the URL and [...klyAAE ] isn't very different to [...klYAAE] and maybe that is a record.
I get some emails from Salesforce / SFMC users and I see urls such as: <
So - What am I missing?
|
Best practice if you were to go via the Marketing Cloud Pages track would b
1. Pass on the subscriberkey or any identifier using the CloudPages Ampscript function
2. On the cloud page, use the RequestParameter function to parse the identifier
If you have integrated right, then your leadid would also be your subscriber key.
|
stackexchange-salesforce
|
{
"answer_score": 2,
"question_score": 0,
"tags": "marketing cloud, email, bestpractice, id"
}
|
C# - Windows Mobile - Bluetooth Pairing
I've been given the task of building a Windows Mobile app for our company that quickly pairs a device by scanning it's bar code. I can discover the device, and talk to it, but I am stuck as far as pairing.
In C# / Windows Mobile 6, how do I pair a device? I don't really need to talk to the device within the app, I need to pair it so other applications can use it.
Is there an API I need to do this? I've seen things saying I need to register a pass key, etc? I can't seem to find any documentation on the actual pairing process, just connecting to it. (Just connecting to it, doesn't actually pair it.)
|
You can use my library 32feet.NET. Use method `BluetoothSecurity.PairRequest` See e.g. Bluetooth Security (That should work regardless of whether the device has Microsoft's own Bluetooth stack installed or the device has Widcomm/Broadcom or SSO Bluetopia).
The process of 'pairing' should also enable the services at the same time. If not we probably have other APIs for that too. Which services are used? SerialPort, others?
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, bluetooth, windows mobile 6"
}
|
How to hint type inference when using static imports?
I am using junit with hamcrest in my unit tests and I came across a generics problem:
assertThat(collection, empty());
I am aware of type inference not being available this way and that one of the solutions is to give a type hint, but how should I type hint when using static imports?
|
While type inference is not as powerful as we would like, in this case, it's really the API that's at fault. It unnecessarily restricts itself for no good reason. The is-empty matcher works on any collection, not just on collections of a specific `E`.
Suppose the API is designed this way
public class IsEmptyCollection implements Matcher<Collection<?>>
{
public static Matcher<Collection<?>> empty()
{
return new IsEmptyCollection();
}
}
then `assertThat(list, empty())` works as expected.
You can try to convince the author to change the API. Meanwhile you can have a wrapper
@SuppressWarnings("unchecked")
public static Matcher<Collection<?>> my_empty()
{
return (Matcher<Collection<?>>)IsEmptyCollection.empty();
}
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 5,
"tags": "java, generics, type inference, hamcrest"
}
|
No availavility in Advanced Shopping SabreSonic Soap Api
am getting this response whith the Advanced Shopping api, its my first time consuming SabreSonic apis and i need some help. The request parameters are fine.
Is there any difference between SabreSonic Soap apis and sabre soap apis?
Thanks!!!
No Availability
|
Thanks everyone, the problem was a missing tag `<TPA_Extensions> <IntelliSellTransaction> <ServiceTag Name="XXX"/> </IntelliSellTransaction> </TPA_Extensions>`
XXX = Carrier code
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": ".net, soap, sabre"
}
|
Can I still receive broadcast receiver intent after I force stopped my app on android?
A simple question. Does it happens that I still receive the registered broadcast receivers after I force stopped the application?
|
if your receivers are registered in AndroidManifest then yes, your app will still receive it. On the other hand, if you are registering via code (in service/activity), then the app won't receive it
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 16,
"tags": "android, broadcastreceiver"
}
|
Where does Internet Explorer "save" downloaded files that are merely "opened"?
My mom downloaded a Word document from an e-mail attachment by clicking on "Open" in the Internet Explorer 7 dialog, instead of "Save". She proceeded to make a lot of changes, after which she saved the document and closed Word, thinking she just updated the e-mail attachment.
Today she found out that that is not actually what happens and asked me to retrieve the file she made all the changes to. It seems most likely to me that if it still exists, it must be in some (probably temporary) directory that IE downloads these files to. But I can't find it. Does anyone know where these files get (temporarily) stored?
My mom is using Windows XP, Internet Explorer 7 and Word 2007 if that helps. Thanks!
|
I think it should be in: C:\Documents and Settings\USER_NAME\Temporary Internet Files\IE_VERSION then one of the bunch of random names, but I'm on Windows 7 so I can't verify that.
EDIT: The easiest way would be you go to Word and pick the Office Button go over Open and to the right, pick it there then just pick Save As. It'll show in it's current directory, and you can just save it somewhere else then and there.
|
stackexchange-superuser
|
{
"answer_score": 7,
"question_score": 6,
"tags": "windows xp, microsoft word, internet explorer"
}
|
how to elegantly .join() a string and a list?
I needed to join two strings:
In [1]: a = "hello"
In [2]: b = "world"
In [4]: ' '.join((a, b))
Out[4]: 'hello world'
Now that `b = ["nice", "world"]`, is there something more elegant than
In [7]: ' '.join((a, ' '.join(b)))
Out[7]: 'hello nice world'
to join all the elements (the string and the elements of the list) into a space delimited string?
|
In [3]: ' '.join([a]+b)
Out[3]: 'hello nice world'
Or, if you are worried about the cost of creating an intermediate list, or if `b` isn't really a list at all, but some iterator:
In [9]: ' '.join(itertools.chain([a],b))
Out[9]: 'hello nice world'
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "python, string, list"
}
|
Search log in magento
Does anyone know if there is some kind log or something build in to magento, where i can find the number of products that text written to the search has retrieved and when it occurred in the front end (the text with time stamp fits too). **I need to know the past queries not the future ones.** _I am the beginner in magento._
|
In your Magento Backend under `Reports -> Search Terms` you get a list of all the searches that were made and the amount of results the search gives.
It does not log exactly when each term was searched for, but it updates the amount of searches made for each term. So you can see how ofter a particular term was searched for and how many results were given out.
There you can also redirect a customer to a specific category or attribute filter for specific searches.
In the DB table catalogsearch_query you can also see when exactly the last search was made for a specific term.
Also, I'm not sure how you could possibly find any future search terms before they were made! =)
|
stackexchange-magento
|
{
"answer_score": 2,
"question_score": 0,
"tags": "products, search, log"
}
|
C - using sprintf
Below is a fairly simple C program to open a text file (input.txt), read the first four lines, commit them to an array, and print the first item in the array (i.e. the first item in the text file)
The problem is, it prints nothing. There are no compile errors and the program just exits without any output. Where am I going wrong?
#include <stdio.h>
int main()
{
FILE * custom_calib = fopen("input.txt", "r");
float custom_calib_contents[4];
int i;
for(i = 0; i < 4; i++)
{
fscanf(custom_calib, "%f", &custom_calib_contents[i]);
}
double X_scale = custom_calib_contents[0];
double X_intercept = custom_calib_contents[1];
double Y_scale = custom_calib_contents[2];
double Y_intercept = custom_calib_contents[3];
char word [80];
sprintf(word, "%f", X_scale);
return 0;
}
|
Your code does not check for error conditions, which is always important. (How do you know the file was opened correctly otherwise?)
The real issue, though, is that you used `sprintf` instead of `printf` to output the string. `sprintf` will put your output into a C-string (that's what the `s` means). `printf` will print the output to the screen.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "c, printf"
}
|
Vsts (formerly Visual Studio Online) copy project
Is it possible to copy all the elements (source code, work items, ...) from a Vsts project to another one?
|
There is OpsHub Visual Studio Online Migration Utility that can migrate source code, work items ….
On the other hand, there are move work items (select some work items > Right click > Move) to another team project, move git repositories between team projects, move items in TFVC features.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "tfs, azure devops"
}
|
How can I answer interview questions about developing in a team when I've always been a lone developer?
In an interview, I was asked about about my experiences in developing in team settings. However, I've been self taught and have only worked on projects on my own. How would you go about answering this question? I just brought up school clubs and how I was able to play well with others, but this isn't really developer related.
|
You should always be open and honest with those that are interviewing you. Seasoned interviewers can smell smoke from a mile away.
This type of question gives you a peek inside the organization. In this case they are telling you to expect a team environment and now is the time to discuss a few points; first, do you desire to work in a team environment; second, can you work in a team environment; lastly, what have you learned from previous team experiences.
Telling them that you haven't been exposed to an environment that works in teams isn't a deal breaker and should lead to a discussion that relates to non-professional team experiences you have had, much like you told them about.
I, as others have pointed out, would say that you answered the question perfectly.
|
stackexchange-softwareengineering
|
{
"answer_score": 12,
"question_score": 8,
"tags": "interview, teamwork"
}
|
How to shutdown graphical interface on Ubuntu 17.04?
I've tried the classic `sudo /etc/init.d/gdm stop` but got a command not found error message.
I also tried the newer `sudo service lightdm stop` but then I stuck on a CLI where I cannot input anything...
|
This is usually because you didn't activate the terminal interface before shutting down the x server. Try pressing `Ctrl``Alt``F1` to enter it or modifying the `/etc/default/grub` `GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"` => `GRUB_CMDLINE_LINUX_DEFAULT="text"` before `sudo update-grub` and `reboot`. Also, try `sudo systemctl stop lightdm` if `sudo service lightdm stop` doesn't work.
|
stackexchange-askubuntu
|
{
"answer_score": 1,
"question_score": 1,
"tags": "graphics, gui, 17.04"
}
|
JQuery val returning undefined
So I'm calling the following function:
function updateOutput(a){
var n = $('#selector').val();
$('#hueslide').val(a[n].hue);
$('#huetext').val(a[n].hue);
}
And I'm getting an error: "Cannot read property 'hue' of undefined."
However, when I use console.log(n), it's returning a value. And when I manually insert the same value in a[n], I get the expected result. I'm guessing this is an asynchronous issue, but the same code was working in an earlier version and I'm not sure how to fix it.
Specifically, when trying to debug updateOutput using console.log, I get the following:
console.log(n); //returns 0
console.log(a); //returns an array of objects
console.log(a[0]); //returns first object in array
console.log(a(n)); // returns undefined
|
Okay, I figured it out. Turns out the value of `0` in `n` I was passing a `string`. So adding `n = parseInt(n);` resolved the issue.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "javascript, jquery, asynchronous, undefined"
}
|
Proof by induction for a recursive sequence (closed form formula given)
I was given the following:
A sequence is defined recursively by a0 = 0, and, for n>=1, an = 5an-1 \+ 1. Use induction to prove the closed form formula for an is an = (5n \- 1) / 4.
So far for my proof, all I have is this:
an+1 = 5an \+ 1
=5 ((5n - 1) / 4) + 1
What do I do next? I've forgotten what I'm even trying to prove.
|
base case: $a_1=\frac{5^1-1}{4}=\frac{5-1}{4}=\frac{4}{4}=1$
Assume $a_n=\frac{5^n-1}{4}$
then $a_{n+1}=5a_n+1=5\frac{5^n-1}{4}+1=\frac{5^{n+1}-5}{4}+1=\frac{5^{n+1}-5+4}{4}=\frac{5^{n+1}-1}{4}$ as was desired.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 1,
"tags": "discrete mathematics"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.