INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
I'm using Kali Linux the command I typed was
sudo systemctl restart systemd-resolved.gz
and all i get is
System has not been booted with systemd as init system (PID 1).
Can't operate.
Failed to connect to bus: Host is down
I'm a noob but I am familiar with Kali Linux tho little bit
|
im am using a windows subsystem kali linux fyi i just deleted it and reinstall it
|
stackexchange-unix
|
{
"answer_score": -1,
"question_score": 1,
"tags": "systemd, kali linux"
}
|
AHK debugging: How to know current line number being executed
I have a AHK script which I need to debug. I basically want to see which line number is being currently executed in the script (which piece of code).
Is there a way to do that? Or anything close to that for debugging? I am using this AHK script to automate some windows explorer related task. But sometimes it gets stuck in between and I have no idea where the script gets stuck. If I knew the current line number being executed, it would be great. Using Msgbox after each line is not possible and very inefficient.
Could someone please help me with this?
Also, I am new to AHK scripting so I would be grateful if you could explain with a short example if possible.
Thanks Sunny
|
To list recent lines, you can show it programmatically by adding the command ListLines to your code.
OR right-click the AutoHotkey icon, select `Open`, and select `Lines most recently executed` in the `View` menu.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "debugging, scripting, autohotkey"
}
|
Does this simulate the specified time-series?
This is mostly a question of whether I am coding this correctly. I need to create the following time series in order to answer questions about it: Simulate an AR(2) process with μ= 2,φ1= 1.2, and φ2=−0.6 having error terms that are normally distributed white noise with mean 0 and variance 9. In order to generate this process, use the random number generation seed 2172 and a sample size of n= 200.
The homework questions ask me things about this process and are easy, but I want to make sure my code is actually simulating what it's supposed to before I move forward.
Here's what I did:
set.seed(2172)
arima.sim(n=200, list(ar=c(1.2, -.6)), innov = rnorm(200, 0, 3)) + 2
|
You are asking a good question and I found few good answer. In the R documentation of the function it is not explicit. But I give you my result which are based on this answer of Rolf Turner. It convinced me :
<
The solution is :
error.model = function(n){rnorm(n, sd=3)}
x = arima.sim(model = list(ar=c(1.2, -0.6)), n = 200, rand.gen = error.model) + 2
To check the order, you can use `pacf`, the question is how to correctly chek the noise because you have an AR. Maybe you can check it with a small sample, for instance t = 1, 2, 3, 4, and check your result.
Good luck.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "r, time series"
}
|
Alternative to TableGateway for Zend Framework 2
I'm using **Zend framework 2** to create web pages.
Through **TableGateway** I'm accessing my **PostgreSQL** **DB**.
Is there any alternative to **TableGateway** that can be used effectively in **Zend framework 2** , with easy-to-use documentation and stuff?
I'm trying to get away from **Doctrine 2** ( _unless you could convince me otherwise_ ).
_Any help would be appretiated._
|
As I commented, I used 3 ways to handle data access.
* TableGateway patter is ok but it's not easy to maintain for larger applications.
* Another commonly used pattern is the data mapper pattern, for this you can use AbstractDbMapper and hydrator for mapping. AbstracDbMapper Link
* Entity pattern, like Doctrine
I finally decided to use doctrine basically cause is very easy to maintain and you can save some hours of code, but if you don't want to use doctrine i think that Data Mapper Pattern is the best option.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "php, postgresql, doctrine orm, zend framework2, tablegateway"
}
|
Delete a dimension in a array
Is there a way to delete a dimension in a array (only if it's empty), it's pretty dificult to explain with words, so that's what i want to do :
I have an array that returns :
(
[region1] => Array
(
[] => Array
(
[0] => citie1
[1] => citie2
)
[region2] => Array
(
[] => Array
(
[0] => citie1
[1] => citie2
[2] => citie3
)
)
)
I want it to be :
(
[region1] => Array
(
[0] => citie1
[1] => citie2
)
[region2] => Array
(
[0] => citie1
[1] => citie2
[2] => citie3
)
)
|
foreach($array as $key => $value) {
$array[$key] = reset($value);
}
That will replace each value in the outer array with the first element of that value.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, arrays"
}
|
how to build errors like that shown in Androffice screenshots
Anyone knows how to build errors like that shown in Androffice screenshots on AppBrain ([<
I think that I saw errors like that before. Is that built in Android SDK?
!enter image description here
|
I've found it out that I can call `mEditField.setError("Error message for field");` on field.
And... yes mechanism is build into Android. For sure it's available from Android API v1.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "android, validation"
}
|
How to get the DataGridTextColumn sender's datagrid parent
Hi I have a datagrid and the DataGridTextColumn shown in code below:
<DataGridTextColumn Header="" Width="1*" Binding="{Binding FORECAST_MIN, UpdateSourceTrigger=PropertyChanged,NotifyOnTargetUpdated=True}" >
<DataGridTextColumn.EditingElementStyle>
<Style TargetType="{x:Type TextBox}">
<EventSetter Event="LostFocus" Handler="fMin_LostFocus" />
</Style>
</DataGridTextColumn.EditingElementStyle>
Now in the LostFocus event, I'd like to get the parent datagrid from the sender. Code
private void fMin_LostFocus(object sender, RoutedEventArgs e)
{
//Get the datagrid parent
}
Is there a easy way to do so? Thank you. Something like adding a Tag?
#
Both Jeff and OptimusPrime's answers work. It only allows me to choose one answer.
|
Jeff's answer should work. Since you mentioned "Tag". This might be another way to go? Probably not the most elegant way though.
<DataGridTemplateColumn Header="">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding FORECAST_MIN, UpdateSourceTrigger=PropertyChanged,NotifyOnTargetUpdated=True}" Tag="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}}" LostFocus="fMin_LostFocus"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
and in your code:
private void fMin_LostFocus(object sender, RoutedEventArgs e)
{
var tb = (TextBox)sender;
DataGrid parentDataGrid = (DataGrid)tb.Tag;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "wpf, datagrid, parent"
}
|
How to Set the BackGround color in Visualforce page
Iam using Standard controller in visualforce page. How to set the background colour or image. Please Give me Example
|
Here is an example, how you can change the background colors of the input fields. Hope this will help.
<apex:page standardcontroller="Contact">
<style>
input[type=text] {
width: 150px;
display: block;
margin-bottom: 10px;
background-color: yellow;
}
</style>
<apex:form >
<apex:pageBlock title="Contact Create/Edit">
<apex:pageBlockSection title="Contact Information">
<apex:inputField value="{!contact.FirstName}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
|
stackexchange-salesforce
|
{
"answer_score": 0,
"question_score": 1,
"tags": "visualforce"
}
|
What kind of RF connector is this?
I have ZTE MF112 and Huawei E173 3G modems with this kind of connector on mainboard:
!enter image description here
What I want to try is to hook up an external 1.8-2.4GHz to modem. It looks like U.FL male connector to me, but I am not sure.
|
It's a ITT Cannon MiniRF test connector (Part No. 120220-0180) or Hirose MS-156C Receptacle. These components provide a straight-through connection until a test probe is inserted in the hole at the top. Which end of the connection the test probe is connected to depends on which way around the connector is soldered onto the PCB, so that would determine whether it would be possible to connect an external antenna here. However these are not latching connectors (unlike the u.Fl mentioned above) so not ideal for a permanent connection. You might be able to solder on a u.Fl connector in its place though.
|
stackexchange-electronics
|
{
"answer_score": 4,
"question_score": 7,
"tags": "connector"
}
|
python - same instruction, different outcome
Could someone help me understand what is going on in the following Python code (python 3.2)? I'm really clueless here.
import sys
u = sys.stdin.readline()
# try entering the string "1 2 3"
r = map(lambda t: int(t.strip()),u.split())
print(sum(r)) # prints 6
print(sum(r)) # prints 0 ?
Thank you.
|
`map()` in Python 3.x returns an iterator, not a list. Putting it through `sum()` the first time consumes it, leaving nothing for the second time.
|
stackexchange-stackoverflow
|
{
"answer_score": 14,
"question_score": 7,
"tags": "python, python 3.x"
}
|
RedirectToAction MVC 3 after $.ajax call
From my view I am sending via $.ajax a JSON object to my controller to save it in the database. If all succeeded i want to redirect to another action which will show a diferent view.
If i use this code:
return RedirectToAction("CreatePage", "Survey", new {id = question.PageId});
The execution goes to the Survey controller which returns a view but it is not shown.
I have read some post which said that it is not posible to redirect via ajax.
The solution I use so far is to redirect via javascript like this:
success: function (ret) {
window.location.href = "/Survey/CreatePage/" + $("#PageId").val();
}
Although this always works, sometimes i need to refresh the CreatePage view to show the last changes made.
Any idea of how to solve this problem better?
Thanks in advance
|
As mccow002 suggested, I wasn't really needing to make the call via AJAX for that part. After studying the solutions suggested, i realized that i could simple submit it in a form. My confusion came because I have a save and continue editing and a save. For the save and continue I use the AJAX call, but for the save option with the form being submitted is ok.
Thanks very much for your help.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "asp.net mvc 3, jquery, redirect"
}
|
scrollTop = scrollHeight does not work in Chrome
I'm scrolling a chat box as new messages come in, and it works fine in Firefox and Chrome incognito, but not normal Chrome. What could be the reason behind this?
My simple scrolling code:
var container = document.querySelector(".dc-messages-container");
container.scrollTop = container.scrollHeight;
|
Your script won't work in Chrome unless you set the container style to `overflow: auto`, or `overflow: scroll`. Chrome simply ignores the element.scrollTop setter otherwise.
So, your script is fine, styles are missing.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "javascript, scroll"
}
|
AWS - ssh: connect to host instance_ip port 22: Connection refused
I've changed following line in the ssh_config file to enable password logging:
PasswordAuthentication Yes
After that I've reboot the ec2 instance. Now trying to ssh but it saying refused connection.
ssh -vvv -i _key_.pem ubuntu@instance_ip
Output Log:
OpenSSH_7.4p1, LibreSSL 2.5.0`
debug1: Reading configuration data /etc/ssh/ssh_config`
debug2: resolving 'instance_ip' port 22`
debug2: ssh_connect_direct: needpriv 0`
debug1: Connecting to 'instance_ip' ['instance_ip'] port 22.`
debug1: connect to address 'instance_ip' port 22: Connection refused`
ssh: connect to host 'instance_ip' port 22: Connection refused
I've checked the port 22 which is allowed in the security group.
Now I'm unable to login to the server. Is there any way to ssh to the instance or recover data and config files in it?
|
In `sshd_config`, while keywords are case-insensitive, arguments are case-sensitive. From the manual:
PasswordAuthentication
Specifies whether to use password authentication. The argument to this keyword must be “yes”
or “no”. The default is “yes”.
`Yes` is not `yes`, so the configuration is invalid, and the ssh daemon is not starting, which is why you TCP connection on port 22 is being refused -- no daemon is listening.
|
stackexchange-unix
|
{
"answer_score": 2,
"question_score": 1,
"tags": "ubuntu, ssh, amazon ec2, aws"
}
|
find a function satisfies two conditions
I need a function that satisfies the following two conditions. I have been thinking for a long time but still do not get any ideas.
1. $f(x)$ is a monotonically increasing function on the interval $[-1, 1]$ and $f(-1) = 0$, $f(1) = 1$.
2. $f^2(x) + f^2(-x) = 1$ for all $x \in [-1,1]$. I think it comes from $cosin$ functions but do not get any ideas fro construct it.
|
$f(x) = \sin(\frac{\pi}{4}(x+1))$
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 1,
"tags": "functions"
}
|
Heroku deployment fails during Bundle Install
When pushing my app Rails3 to Heroku, it gets rejected with:
> Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment sh: Syntax error: Unterminated quoted string
but when I run `ruby -c Gemfile` I get `Syntax OK`.
Any tips?
Edit: source code can be found here: < I'm using ruby 2.1.0 and Rails 3.2.17
|
We had the same issue on two of our apps. It turned out that a recent stack upgrade caused one of Heroku config variables to throw this error. One of our passwords had a double quote which caused the`Syntax error: Unterminated quoted string` Error. I suggest checking your Heroku config variables for this issue.
To check this run `heroku config` in your console
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "ruby on rails, heroku, gemfile"
}
|
Updating a row according to a spatial intersection in SQL-SERVER
So basically I have 2 tables;
1. `BORDERS` table includes `Id(int)` and `Geo(DbGeometry)` spatial column including polygons and multi polygons.
2. `OBJECTS` table includes `Id(int)`, `BorderId(int)` and `Point(DbGeometry)` spatial column including points.
I would like to fill `BorderId` column in `OBJECTS` table according to the intersection of `Point` column in it with `Geo` column in `BORDERS` table.
I would like to do it with SQL query. Any help would be much appreciated! Thanks!
|
You can use`STIntersects` to find the intersection. Your update query should look like following query.
UPDATE O
SET O.BorderId = B.Id
FROM BORDERS B INNER JOIN OBJECTS O ON O.Point.STIntersects(B.Geo)=1
Above Query will not work properly when you have multiple intersections, to get the best intersection based on **Area covered** , you can use `.STArea()` to find the intersecting area like following.
UPDATE O
SET O.BorderId =
(
SELECT TOP 1 B.Id FROM BORDERS B
WHERE O.Point.STIntersects(B.Geo)=1
ORDER BY O.Point.STIntersects(B.Geo).STArea() DESC
)
FROM OBJECTS O
Above query will update the `BorderId` with the `Border` table `Id` column having the maximum intersection area.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "sql, sql server, geospatial, spatial"
}
|
Understanding when the entropy $H(f(X))=0$?
I've been trying to understand this for a while now, but can't seem to get it. This question only refers to a discrete random variable X and some function $f$ in $\mathbb{R}$.
I've been told that $f(X)$ being an injective function is enough for the statement to hold.
But isn't $H(f(X)) = H(X)$ if the function is injective? This says nothing about the entropy being $0$. I would have assumed that it is only equal to $0$ if the function is injective **AND** the random variable already has $0$ entropy.
Am I completely off track here?
|
you're right, since if $f$ is injective, it can't change the probability density of the new random variable $Y = f(X)$. Are you sure the questions asks $f$ to be injective?
For a simple counterexample, let $f(x) = x$. Now, $H(f(X)) = H(X)$, an if $H(x) \neq 0$, then $H(f(X)) \neq 0$
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "information theory, entropy"
}
|
Probability of die threshold
Suppose there is a fair die with $n$ faces labeled from $1$ to $n$, and a number $1\leq k \leq n$.
How many times does one need to throw the die (on average) to get a number $j$ with $j\geq k$?
|
Let $X$ be the number of times the die is thrown until a number $j$ with $j\geqslant k$ is obtained. Then $X$ is geometrically distributed with parameter $(n-k+1)/n$. So the probability mass function of $X$ is given by $$ \mathbb P(X=m) = (1-(n-k+1)/n)^{m-1}(n-k+1)/n. $$ We compute the expectation by \begin{align} \mathbb E[X] &= \sum_{n=1}^\infty m\cdot\mathbb P(X=m)\\\ &= \sum_{n=1}^\infty m(1-(n-k+1)/n)^{m-1}(n-k+1)/n\\\ &= \frac n{n-k+1}. \end{align}
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "probability, dice"
}
|
how to achieve paging vertically in asp.net C# in gridview
I want to have paging in my asp.net gridview but here is the twist, I want the paging vertically. i.e when I hit page up and page down paging should occur vertically. Like when I do normal paging 1,2,3,4..... pages occur but I want no 1,2,3,4..pages, I want it to be done vertically when I hit page up and page down considering 10 records per page
|
Wrap your gridview around a div and add `width` `height` and `overflow:scroll` to the div's style attribute.
<div style="width: 100%; height: 400px; overflow: scroll">
<ASP:GridView></ASP:GridView>
</div>
Also remove the `AllowPaging`attribute from the GridView. Adjust the width and the height of the div according to your needs.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "c#, asp.net"
}
|
Functional Testing in Java
I believe functional testing is testing of two or more modules together with the intent of finding defects, demonstrating that defects are not present, and verifying that the module performs its intended functions.
Is there any functional testing tool for java applications? I'm in need to do this. I know of junit which I have used in unit testing and also T2 utility which is an extension of junit, which I have used for automated testing. Is there any particular framework or tool for functional testing?
|
JUnit is more aimed at unit testing. For functional testing, take a look at TestNG, which offers advanced functional testing features such as:
* Groups.
* Testing multithreaded code.
* Runs in parallel.
* Dependencies.
* Suite-level configurations.
* Dependency injection (Guice).
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 4,
"tags": "java, testing, junit, integration testing"
}
|
Array destructuring assignement with optional values
Is there any solution in PHP to make an array destructuring assignment with associative keys can extract optional values/default values (like the example below)? Because when I tried, I always get undefined index 'age' (it's because it is not set).
See example:
// implementation
function myFunction(array $params = ['name' => 'user-name', 'age' => 15]){
['name' => $name, 'age' => $age ] = $params;
echo $name.' '.$age;
}
// Execution:
// normal case
myFunction(['name' => 'user', 'age' => 100]);
// Output: user 100
// Wanted case to be released
myFunction(['name' => 'user']);
// Output: user 15 <== i want to get this default age value if i don't set it in the given associative array params.
|
Well, since you pass in a parameter, it will always take that instead of the default one. However, you can use the union operator `+` to merge it with default values if not present in the originally supplied value during function call.
<?php
function myFunction(array $params = []){
$params = $params + ['name' => 'user-name', 'age' => 15];
['name' => $name, 'age' => $age ] = $params;
echo $name.' '.$age;
}
myFunction(['name' => 'user']);
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, arrays"
}
|
How and where to store user settings per session?
I'd like to store some user choices per session, but have no idea where and how. To keep the problem as simple as possible:
* Lets say we have two links in the header: EN and FR (for language selecting purposes)
* When a user clicks on one of them we should be able to store somewhere the selected option
* Later on the site we should be able to access the selected option to take further steps to... translate some texts
So the question remains: Where and how to store the chosen language, and how to access it from anywhere on server side?
|
Not the most complete answer but you can see an illustrated example of writing and reading sessions The Apostrophe Way in the `apostrophe-personas` module
<
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "apostrophe cms"
}
|
Difficulty in getting exact charecters after character shuffling
Suppose I have a String "CAA". What I am doing now is randomly adding some Character to it for e.g. lets say I am adding Character 'B' and 'D' and shuffle that whole Character ArrayList and placing them in some Buttons as below
!enter image description here
Here my character ArrayList contains {'A','C','B','A','D'}
What I am trying to do is when I click on a button I want something like below !enter image description here
I mean only keep the Buttons that contain letters of Original string and disable all other Buttons.
|
1. Create a Custom Class that wraps a Character and a boolean flag to maintain that its original character.
class MyCharacter {
private Character c;
private boolean isOriginal;
public MyCharacter(Character c, boolean isOriginal) {
this.c = c;
this.isOriginal = isOriginal;
}
public Character getChar() {
return c;
}
public boolean isOriginal() {
return isOriginal;
}
}
2. Instead of adding Character into list. Add MyChracter object.
3. For original chracters pass boolean true in constructor and for later random ones pass false in it.
4. Do shuffling or whatever you want. At any moment iterate over the list. Get the MyChracter object and check whether its original or not.
This should be simple to do. Hope this helps
Cheers
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -1,
"tags": "java, android, arrays, data structures, arraylist"
}
|
Float precision with specific numbers
The following value gives me wrong precision. It is observed with only specific numbers. It might be a floating representation problem, but wanted to know the specific reason.
String m = "154572.49"; //"154,572.49";
Float f = Float.parseFloat(m);
System.out.println(f);
The output it is printing is `154572.48` instead of `154572.49`.
|
If you want decimal numbers to come out as exactly as you entered them in Java, use BigDecimal instead of float.
Floating point numbers are inherently inaccurate for decimals because many numbers that terminate in decimal (e.g. 0.1) are recurring numbers in binary and floating point numbers are stored as a binary representation.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "java, floating point, floating accuracy"
}
|
Background Image in CSS Class inside to <div>
I am new at web design and I have a question to ask. I can not see background image in . Here is my code. What am I doing wrong? I am sure that image is in the right location and I linked style.css to my html code.
PHP:
<div style="main_div">
<div style="banner">
</div><!--banner end-->
</div><!--main end-->
CSS:
.main_div{width: 1000px; margin: auto;}
.banner{
width:100%;
height:100%;
background-image: url(../img/bannerimg.png);
margin-top:50px;}
I also have reset code of Eric Meyer in CSS code. Thanks in advance.
|
you should change the `style` to `class` and it should work. your problem is that you are working with the wrong keyword.
* `class` is to identify elements
* `id` is to identify a unique element
* `style` is to write `CSS` in the element
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "html, css, class, background, stylesheet"
}
|
How to show the tabs according to the logged in user role? (Omega subtheme)
I´m using an Omega subtheme in a Drupal 7 installation. I´ve set at the theme configuration, that Drupal should show the tabs (`$tabs`).
What I want is to show the tabs only to a specific role. I try this snippet out, wich didn´t worked. **My guess is that it didn´t worked because I´ve told Drupal through the omega subtheme, to show the tabs. And the theme show them to everybody**.
If I uncheck "show tabs" variable, they won´t show up, no matter what I do at my template file.
If I uncheck the tabs but add them inside my page template file, whey won´t show up either.
I want to be able to show the tabs or not according to the logged in user role. Here´s my snippet that doesn´t worked (at my page.tpl.php file):
<?php
global $user;
if (!in_array('admin', array_values($user->roles))) {
print render($tabs);
}
else {}
?>
What should I do? Thanks for your help!!
|
If you are using the Omega sub theme then there would be a template file for each of the regions defined by the Theme.
The content comes in the template called region--content.tpl.php
You should see the tab printed there. you can put your logic there.
|
stackexchange-drupal
|
{
"answer_score": 1,
"question_score": 0,
"tags": "7, users, theming, routes"
}
|
passing a list to subprocess.check_output
argument_list = ['name=Jon', 'id=100' ]
output = subprocess.check_output(
['/usr/bin/python', 'test.py', argument_list ], stderr=subprocess.STDOUT)
In simple terms, I am trying to invoke a script using subprocess called test.py; I want to pass arguments to test.py through a list. Importatnt - List can be of any size.
Things I tried ,
output = subprocess.check_output(
['/usr/bin/python', 'test.py', ", ".join(argument_list) ], stderr=subprocess.STDOUT)
and
output = subprocess.check_output(
['/usr/bin/python', 'test.py', '%s' % argument_list ], stderr=subprocess.STDOUT)
Neither works because in subprocess.checkoutput should be (' ', ' ' ,' ') etc....
Is there a better way to do this ?
|
You can make a new list by adding lists together:
output = subprocess.check_output(['/usr/bin/python', 'test.py'] + argument_list, stderr=subprocess.STDOUT)
This will run `test.py` with `argument_list` as it's command-line parameters.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "python, subprocess"
}
|
Yii2 and Postman - empty POST
Again yii2, again problem. I need yii/rest/Controller, not yii/rest/ActiveController I have contorller with method and config: my files
my Postman: my postman
Always have empty POST array. Where is problem? If send as form-data, all is well.
|
I found! I Found!! I FOUND ANSWER!!!! Thank you to all the good people who helped me find the answer. And i'm sorry. Answer is very simple) Just use **Yii::$app->request->post()** I forgot about it)) Uhhh .....
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "yii2, postman"
}
|
How to offset a cubic bezier curve?
I'm trying to create a "parrallel" bezier curve. In my attempts I've gotten close but no cigar. I'm trying to keep a solid 1px offset between the 2 curves (red,blue).
!current attempt
My main goal is use a edge offseting algorythm to expand/shrink a svg path.
* * *
**Solution**
For anyone else who is looking for a solution, I've create a AS3 version.
<
|
From wikipedia: ( < )
The curve at a fixed offset from a given Bézier curve, often called an offset curve (lying "parallel" to the original curve, like the offset between rails in a railroad track), cannot be exactly formed by a Bézier curve (except in some trivial cases). However, there are heuristic methods that usually give an adequate approximation for practical purposes.
You might also see the paper indicated here: Outline of cubic bezier curve stroke
|
stackexchange-stackoverflow
|
{
"answer_score": 11,
"question_score": 32,
"tags": "graphics, bezier, cad"
}
|
TDD - write test first?
I am trying to understand what is TDD.
After some reading if I understand correctly - for Laravel development, I need to write some PHPUnit Test **BEFORE** implementing functionality in controllers, routes, model, etc?
It should not be other way around? Implement functionality and then do some PHPUnit Test?
|
Your understanding is correct. Following a test-driven development approach to software development your tests will set the expectation for the functionality that is yet to be written. Therefore, initially any given test you write will fail and you will continue to develop a unit of code until it passes. It's worth mentioning that in addition to the more common TDD approach towards unit tests, you may also embrace a similar methodology with an ATDD approach towards any potential acceptance tests.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "php, laravel, phpunit, tdd"
}
|
Algorithm for computing fundamental group of simplicial complexes
For computing homology of a simplicial complex, there is the well-known reduction algorithm.
How about for fundamental group of simplicial complexes? Is there any (implementable) algorithm to compute it? (By implementable I mean that it can be programmed on a computer and actually compute the fundamental group.)
I am aware of the method of using maximal trees and generators to determine fundamental group, is that implementable as an algorithm? So far I have only learnt working it out on pen and paper, I am unsure if the simplification of the relations of the generators can be made into an algorithm.
Thanks a lot.
|
Depends on what you mean by "computing" and "algorithm". It is undecidable (even for a two-complex) whether the fundamental group is trivial, though computing a presentation is relatively easy.
|
stackexchange-mathoverflow_net_7z
|
{
"answer_score": 3,
"question_score": 3,
"tags": "at.algebraic topology"
}
|
Statistics version of "What is..." columns in Notices
Each issue of the AMS monthly magazine _Notices_ contains a "What is..." column. This column is an expository article on a given topic, e.g. "What is...Noncommutative Topology". Do statisticians have something similar?
|
These days you often find such stuff in blogs! Here are two favourites of mine:
andrewgelman.com
normaldeviate.wordpress.com/
|
stackexchange-stats
|
{
"answer_score": 1,
"question_score": 6,
"tags": "references"
}
|
Affine combination absolute sum?
For an equation $\sum_{k=0}^n c_k x^k$, i have coefficients which have the affine combination property $\sum_{k=0}^n c_k=1$. Upon taking the absolute sum, i found that i get $\sum_{k=0}^n |c_k|=n$. I know that by the triangle inequality $|\sum_{k=0}^n c_k | \leq \sum_{k=0}^n |c_k|$ which seemingly makes this a special case, but i haven't read in a book or paper that the absolute sum is necessarily equal to $n$? If anyone knows why this is, or if the equation has to have some sort of property for this to happen, or is this a special case of affine combination coefficients?
|
$$\sum_{k=0}^n|c_k|=\sum_{k=0}^{n-1}|c_k|+\left|1-\sum_{k=0}^{n-1}c_k\right|$$ where the $n-1$ $c_k$ are unconstrained. This expression can take arbitrary values.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "absolute value, affine geometry"
}
|
JQuery horizontal centred div's
How to center all div's using a JQuery or CSS?
Example: <
<div id="parrent">
<div class="item">
content
</div>
<div class="item">
content
</div>
...
</div>
!Example image
|
Just remove `float: left;` from `#parrent .item` selector and add `display: inline-block;`
jsFiddle demo.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "javascript, jquery, css"
}
|
How to compare all the buttons? Or check if all are disabled?
I'm trying to do a memory game using "cards" all works fine but I need to know when the user win the game to display a message but I can't figure out how to do that? How can I check using a condition if all the buttons are `.setEnabled(false)`? Or should I compare all the buttons using a loop? I hope you can help me.
|
Since you have cartas as an array. You should just iterate through a loop to see if all cards are set to false.
for(int x =0; x< cartas.length;x++)
{
if(cartas[x].isEnabled()) //enabled
{
break; //a button is still enabled so cancel loop
}
else if(x == cartas.length-1&& !cartas[x].isEnabled())
{
//All cards have been disabled. Do Something.
}
}
Therefore, the method
isEnabled();
allows you to check if all buttons are
.setEnabled(false);
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "java"
}
|
Wrong time calculated having more than 30min
Im having a a bit strange problem, Im having this code and on output it adds always one hour more if the second time has 30 or more minutes.
$time1 = '12:00';
$time2 = '13:30';
list($hours, $minutes) = explode(':', $time1);
$startTimestamp = mktime($hours, $minutes);
list($hours, $minutes) = explode(':', $time2);
$endTimestamp = mktime($hours, $minutes);
$seconds = $endTimestamp - $startTimestamp;
$minutes = ($seconds / 60) % 60;
$hours = round($seconds / (60 * 60));
Whats happening here?
|
Instead of using `round` use `intval` as `$seconds / (60 * 60)` expression always returns a float and we need only the integer part of that result
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, time, calculator"
}
|
Managing page paths in ASP .NET application
Currently in my web application I have plenty of lines like this:
Response.Redirect("~/Default.aspx");
etc. Now, I'm in the process of reorganizing aspx pages structure, as it's pretty flat - everything is in one folder. So I have to thoroughly search all the code in order to fix aspx paths. So my question is: is there any way to manage/organize web site pages structure in ASP .NET - some kind of SiteMap, so that I have a code similar to:
Response.Redirect(Pages.Default);
so that my code will be closed for modifications where some aspx pages are moved between folders?
|
I've written an open source project that will help you, <
You list your pages and transitions in a config file. Here's an example:
<state key="Page1" page="~/Page1.aspx">
<transition key="Next" to="Page2"/>
</state>
<state key="Page2" page="~/Page2.aspx"/>
Then in your code you can move from Page1.aspx to Page2.aspx like this:
StateController.Navigate("Next");
Let me know if you're interested or need any help.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 2,
"tags": "asp.net"
}
|
Set JAVA_HOME to be the root of java installation
I'm currently using hadoop and in the config part there's "define JAVA_HOME at least to be the root of your java installation" I'm actually confused about it. Say, my JAVA_HOME when using: `echo $JAVA_HOME` is: `/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home`
and my java installation when using: which java is: `/usr/bin/java`
What change should I make to set JAVA_HOME as the java root?
Thanks!
And for a follow up, I think the tutorial mentioned to make the change inside the conf/en-sh part. I tried the combinations of the below answers proposed, but still got the error of 1\. invalid identifier for the export JAVA_HOME = .. part 2\. unable to load hadoop library
Please help..... Any suggestion?
|
On my system, I have JAVA_HOME set to `/Library/Java/Home` on Mountain Lion. Fair enough... add `export JAVA_HOME=/Library/Java/Home` line to the .bash_profile, .zshrc file in your home directory. If you're using tcsh, the line you want is `setenv JAVA_HOME /Library/Java/Home`. The default shell on recent versions of OS X for users in bash. You can find out what you're using using `echo $SHELL`.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "java, hadoop, java home"
}
|
Abort function after X seconds - lisp
I've been searching a way to stop a function after X seconds on lisp and I haven't found anything and have no ideia how to do it.
It's for finding heuristic weights on a function for a tetris game and if the weights are bad the program will run for more than 30 seconds and I don't want that. Any ideias, please?
|
One possible way is to pass down an "expiry timer" and check if the current time is later than the expiry time in every iteration and, if it has expired, return the best solution so far. The standard function `get-universal-time` may be useful, but gives you a minimal granularity of seconds. A rough skeleton below. If you use recursive functions, simply pass the expiry timer down with whatever else you pass down and use that as your first recursion termination criterion.
(defun do-tetris-stuff (tetris-weights expiry-time)
(let ((best-solution nil))
(loop while (and (<= expiry-time (get-universal-time))
(not (good-enough-p best-solution)))
do (let ((next-solution ...))
(when (better-than-p next-solution best-solution)
(setf best-solution next-solution))))
best-solution))
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 4,
"tags": "lisp, common lisp, clisp"
}
|
What's the difference between the .NET Unit Testing framework out there?
I've heard many different opinions as to what makes one better than another. But can anyone provide a technical explanation as to why I should choose one unit testing framework over another. For example, I use Visual Studio Team System. Why would I choose an Open Source testing framework (NUnit, xUnit, MbUnit, etc) over Visual Studio's built-in unit testing capabilities? Does it matter?
Edit: To be clear, I'm not looking for an opinion on "Which unit testing framework is best"...I'm looking for technical details as to how they are different,.
|
There's a comparison of the attribute and assertion differences between NUnit, MbUnit, MSTest, and xUnit.net at <
as for MSTest vs OpenSource solution, it's widely seen that the open source packages, in particular MBUnit and xUnit.net are where the innovation around unit testing is occuring.
That said, now that Peli de Halleux is working for MS and producing inovation like Pex things could change.
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 4,
"tags": ".net, unit testing"
}
|
Extend Alexander-Whitney and Eilenberg-Zilber map to n-fold tensor products
See the definition of the Alexander-Whitney transformation:
<
and the Eilenberg-Zilber transformation:
<
Is there a natural or obvious way to extend them to higher tensor powers i.e to, lets say
$$ \Delta_{A_1,\ldots,A_n} : C(\otimes_{j=1}^n A_j) \to \otimes_{j=1}^n C(A_j) $$ and $$ \nabla_{A_1,\ldots,A_n} : \otimes_{j=1}^n C(A_j) \to C(\otimes_{j=1}^nA_j) $$
or to the infinite tensor power series, such that the adjointness is still there?
(My first obvious guess is to simply iterate them using associativity of the usual tensor product but I'm not sure if it is that simple due to concerns about braiding and singns)
|
Yes, there is a generalization to a finite number of simplicial complexes. A reference is _Corollary 2.2_ in the paper
> Eilenberg, MacLane: On the groups $H(\Pi,n)$, II: Methods of Computation, Ann. of. Math. 60(1954), No. 1, 49 - 139.
Using the definitions from nLab, the maps are given as follows:
1) Let $a_i \in A_i$ be homogen. $$\nabla(a_1 \otimes \cdots \otimes a_n) = a_1 \nabla a_2 \nabla ... \nabla a_n$$ (well-definied since $\nabla$ is associative)
2) Let $a_i \in (A_i)_m$. $$\Delta(a_1 \otimes \cdots \otimes a_n) = \sum \displaystyle \otimes_{i=1}^n\displaystyle\tilde{d}^{m-j_i}d_0^{j_{i-1}}a_i$$ where the sum is taken over $0 \le j_1 \le \cdots \le j_{n-1} \le m$ and $\tilde{d}^{m-j_n},\;d_0^{j_0}$ has to be interpreted as identity.
|
stackexchange-mathoverflow_net_7z
|
{
"answer_score": 6,
"question_score": 4,
"tags": "simplicial stuff, homological algebra"
}
|
Array of objects - modyfing object's fields C#
I've got such a problem. I'm a beginner in C#. I have an object array (various classes) and in one place of application I want to modify fields like an age or name. Construction
static Object[] prac = new Object[10];
public static void Main(string[] args)
{
prac[0].age = 21;
}
shouts an error
> 'object' does not contain a definition for 'age' and no extension method 'age' accepting a first argument of type 'object' could be found
I thought that will be similiar to a Java code, but it isn't. What am I doing wrong?
Regards.
|
You need to cast your member to the class type that contains the age. I'll just assume that your class name is `Person` and that is has a `age` member :
static Object[] prac = new Object[10];
public static void Main(string[] args)
{
((Person)prac[0]).age = 21;
}
Important to note are the brackets : `(Person)prac[0]` is the cast part, you cast the `Object` `prac[0]` to a `Person` object. The outer brackets `((Person)prac[0])` are there so that the code is taken as a `Person` object, instead of a regular `Object`.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -1,
"tags": "c#, arrays, object"
}
|
In iOS is there a way to prevent auto spelling correction in a UITextView?
I already implement textView:shouldChangeTextInRange:replacementText: as shown below. I need it to remove the prompt text and also to end editing. Do I need to add something else to it to turn off auto-correction? Or how else do I turn it off?
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if ([self.noteView.text isEqualToString:initialText]) {
textView.text = @"";
self.noteView.textColor = [UIColor blackColor]; // initialText was lightGray
} else if ([text isEqualToString:@"\n"]) {
[textView resignFirstResponder];
}
return YES;
}
|
You can set it on storyboard. Select `UITextView` and check it:
FROM (SELECT id1 AS id FROM mytable
UNION ALL
SELECT id2 AS id FROM mytable) t
GROUP BY id
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "mysql, sql, select, count"
}
|
Why do size of "*.ipa" files for different targets in one project are different?
I have a project with 5 targets. Each target has its own settings and its own "*.xcassets" resource (spleshscreen images, background images). One target is a Test-Target with secret settings to change configs and it has access to all resources.
Why do size of "*.ipa" files (and size of app in TestFlight) are different, from 12 to 18 megabytes? And the size of the Test-Target ipa-file, which includes all of the resources, is not the biggest, only 15 megabytes. I checked the "Copy bundle resources" of targets and there are no extra resources.
What's wrong with my project settings? Thanks in Advance.
. Cela dit, on ne peut pas vraiment parler d'une expression consacrée, même si elle semble parfaitement correcte — rien chez _Le Grand Robert_ (2005), par ex.
**Édition :** la réponse d'Iside m'évoque aussi les « larrons » bibliques, et de là les “larrons en foire” — d'après le _Grand Robert_ :
> S'entendre comme larrons en foire, à merveille, **comme des voleurs qui sont de connivence pour monter un coup.**
|
stackexchange-french
|
{
"answer_score": 3,
"question_score": 2,
"tags": "expressions"
}
|
How to clone project from code.google on windows
see i need to download code from this page
<
which shows to clone
hg clone
on my linux machine i have installed `hg` and then this command work and i got the copy of that project on my machine
but how to get this on windows machine??
|
Download and install TortoiseHg.
Run the same command:
C:\>hg clone TreeView
requesting all changes
adding changesets
adding manifests
adding file changes
added 44 changesets with 255 changes to 111 files
updating to branch default
98 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 2,
"tags": "windows, mercurial, google code"
}
|
Convert the output of for loop of JSON in string
How can I combine the output data and make it a string, from a for loop in Javascript.
Here's my snippet.
for (let index = 0; index < routes.length; index++) {
let element = routes[index];
meSpeak.speak(element.narrative, speakConfig);
}
It results,
word1
word2
word3
word4
I want to make it as a one String only. like this
word1 word2 word3 word4
|
Just use `join()`
const routes = [{'narrative':'word 1'},{'narrative':'word2'},
{'narrative':'word 3'},{'narrative':'word 4'}];
let out = []
routes.map((el)=>(out.push(el.narrative)));
res = out.join(' ');
See Demo
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, json"
}
|
how to get data into view from controller in cakephp
$this->loadModel('Siteconfig');
$data=$this->Siteconfig->find('all');
foreach($data as $data)
{
$email=$data['Siteconfig']['email'];
$companyname=$data['Siteconfig']['companyname'];
$cfa=$data['Siteconfig']['cfa'];
}
Above is **Controller**
How to get **cfa** data in view using **CAKEPHP?**
|
In your controller method, you can use this
$this->set('var_name_in_view', $cfa); //You will find the variable $cfa as $var_name_in_view in your view(You have to use $var_name_in_view in view)
You can also send multiple variables to your view at once
$this->set(compact('cfa', 'another_variable')); //You can acceess using $cfa and $another_variable
> Compact makes an array keeping the variable name as key and variable value as the value for the array key.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "php, cakephp, cakephp 2.x"
}
|
Difference between $n$-th and $(n-1)$-th composite numbers
Let $f(n)$ = 1 if $n$ belongs to A014689, $\operatorname{prime}(n)-n$, the number of nonprimes less than $\operatorname{prime}(n)$. Here $\operatorname{prime}(n)$ is the $n$-th prime number, $\operatorname{prime}(1)=2$.
Let $a(n)$ be the $n$-th composite numbers, $a(1)=4$.
Then I conjecture that
$$a(n) = 1 + a(n-1) + f(n)$$
Is there a way to prove it?
|
Surely $f(n)$ is meant to be the indicator function of the range of the function $k\mapsto p(k)-k$, where $p(k)$ denotes the $k$-th prime number. With this supplemented definition, the conjecture is true.
Indeed, $n=p(k)-k$ holds if and only if there are $n-1$ composite numbers up to $p(k)$, that is, $a(n-1)<p(k)<a(n)$. Therefore, $f(n)=1$ means that there is a prime number between $a(n-1)$ and $a(n)$. So we have $a(n)=a(n-1)+2$ when $f(n)=1$, and we have $a(n)=a(n-1)+1$ when $f(n)=0$.
|
stackexchange-mathoverflow_net_7z
|
{
"answer_score": 8,
"question_score": 2,
"tags": "nt.number theory, co.combinatorics, prime numbers, sequences and series"
}
|
SQL average of a subset of a column
Give the table "shop"
[product] [type] [price]
pen A 10
glasses B 20
lipstick A 30
Is there a way to find the list of products(whether A or B) whose price is less or equal to the average price or type A?
[product] [price]
pen 10
glasses 20
I tried the following:
SELECT product, price
FROM shop
WHERE price <= avg(price) AND type = 'A'
|
Use a subquery to find the average price of type A items:
SELECT product, price
FROM shop
WHERE price <= (SELECT AVG(price) FROM shop WHERE type = 'A');
Just for fun, we could also use analytic functions here:
WITH cte AS (
SELECT *, AVG(price) FILTER (WHERE type = 'A') OVER () avg_price_a
FROM shop
)
SELECT product, price
FROM cte
WHERE price <= avg_price_a;
## Demo
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "sql, postgresql"
}
|
Best option to map dates for consume REST API
I need to consume a Rest API using Java/Spring (RestTemplate). After doing some smoke test with Postman I see the dates fields have this structure
"clipStartDate": {
"__type": "Date",
"iso": "2010-09-14T00:00:00.000Z"
}
I tried to map this fields in my DTO using java.time.LocalDateTime. But I'm getting a serialization exception. (org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot construct instance of `java.time.LocalDateTime`)
What is the best practice in this case?
|
This error you're seeing means that your `ObjectMapper` is not configured properly. In Spring Boot this comes autoconfigured out of the box, so if you use e.g Spring Boot 2.2 this error will disappear.
However if for some reason you don't have this possibility, then you need to configure an `ObjectMapper` with an additional module called `JavaTimeModule`.
@Bean
public ObjectMapper objectMapper(){
return new ObjectMapper()
.registerModule(new JavaTimeModule());
}
Here's a suplementary article describing how to further customize `ObjectMapper`
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "java, spring, resttemplate"
}
|
Find $f(2015)$ given the values it attains at $k=0,1,2,\cdots,1007$
> Let $f$ be a polynomial of degree $1007$ such that $f(k)=2^k$ for $k=0,1,2,\cdots, 1007$. Determine $f(2015)$.
Taking $f(x)=\sum_{n=0}^{1007} a_n x^n $, (whence $a_0=1$), I tried to combine $$a_1=1-\sum_{n=2}^{1007} a_n$$ and the easily derivable $$ a_n = \frac{2^n-1}{n^n} - \sum_{k=1}^{n-1} a_k n^{k-n} - \sum_{k=n+1}^{1007} a_k n^{k-n},$$ hoping to find several null coefficients, but that didn't work. I looked for the solution on Yahoo Answers, and I came to know it's about binomial coefficients, Tartaglia in particular; however the explanation is confusing to me, I'd like a better one, or even a different approach.
|
It is not difficult to guess what is the representation of $f(x)$ with respect to the binomial base.
For fearless people that do not like to guess, Lagrange's interpolation gives:
$$ f(x) = \sum_{j=0}^{1007} 2^j\cdot\,\\!\\!\\!\\!\\! \prod_{\substack{k\in[0,1007]\\\k\neq j}}\frac{(x-k)}{(j-k)}=\sum_{j=0}^{1007}\frac{2^j}{x-j}\cdot 1008!\binom{x}{1008}\cdot\frac{(-1)^j}{j!(1007-j)!} \tag{1}$$ hence: $$ f(2015)=\sum_{j=0}^{1007}\frac{(-2)^j\cdot 1008}{2015-j}\binom{2015}{1008}\binom{1007}{j}$$ or: $$ f(2015)=2^{1007}\binom{2015}{1008}\sum_{j=0}^{1007}\frac{(-1)^j\cdot 1008}{2^j\cdot(1008+j)}\binom{1007}{j}, \tag{2}$$ but: $$\begin{eqnarray*}\sum_{j=0}^{1007}\frac{(-1)^j}{2^j(1008+j)}\binom{1007}{j}&=&2^{1008}\int_{0}^{1/2}x^{1007}(1-x)^{1007}\,dx\\\&=&2^{1007}\frac{\Gamma(1008)\Gamma(1008)}{\Gamma(2016)}\\\&=&\frac{2^{1007}}{1008}\cdot\frac{1}{\binom{2015}{1008}}\tag{3}\end{eqnarray*} $$ by the Euler beta function, so line $(3)$ nicely simplifies to:
> $$ f(2015)=2^{2014}.\tag{4} $$
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 5,
"tags": "algebra precalculus, polynomials, contest math"
}
|
SELECT a row WHERE column + x minutes
I am trying to find a way to select a row where a date column + x minutes is superior or inferior to given value.
Example :
$theday = "2020-04-07 14:30:25";
$query = $mysqli("SELECT * FROM table WHERE columndate + 5 minutes < '$theday'");
This query is meant to show what I am trying to do.
Thank you very much for your help
|
Use `TIMESTAMPDIFF`:
SELECT *
FROM yourTable
WHERE ABS(TIMESTAMPDIFF(MINUTE, columndate, ?)) < 5;
To the `?` placeholder you should bind `$theday` variable.
This would find all records where your day timestamp and column are within 5 minutes of each other. If you want the opposite, where the two timestamps are at least 5 minutes apart, then change the direction of the inequality.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, mysql, select"
}
|
List user defined variables from a parent module (Python 3)
I have a function within a module that lists defined variables
Simplified Example:
for var_name in globals():
if not var_name.startswith('__'):
var_value = eval(var_name)
var_type = type(var_value)
print(var_name, "is", var_type, "and is equal to ", var_value)
This works when I run it from within the origin module, but not when the module is imported to another script. It only ever reads the variables defined in the origin module.
I also tried:
import __main__
for var_name in __main__.__dict__:
But that didn't work either. How can I get this function to work when imported into another script?
Thanks!
|
You mean to use `__main__.__dict__`, not `__main__.dict`. That, with some minor loop modifications (i.e. `eval` will not work as you want it to in this context, instead use `__main__.__dict__[var_name]`) should get your code working.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, python import"
}
|
How to enable SSH in Deeplens camera after the initial registration
I have registered my Amazon Deeplens camera in the AWS console and selected to disable SSH and automatic updates. Then I found that in order to update it manually it's necessary to login into the shell of the the camera (Ubuntu) so, for convenience, I want to enable back SSH.
How can I do this?
|
In order to do that you will have to access the camera using a monitor, mouse and keyboard. then login into Ubuntu using the same credentials as the user you selected for the camera configuration, open a shell and login and verify ssh is running:
> service ssh status
If it is enabled then you just need to enable the rules to connect to port 22:
> sudo ufw allow ssh
If it's not then you need to enable and start ssh first:
> sudo systemctl start ssh
> sudo systemctl enable ssh
Then you can ssh into the cam with:
> ssh aws_cam@YOUR_CAM_IP_ADDRESS
and optionally update awscam manually (if this is what you want):
> sudo apt-get update
> sudo apt-get install awscam
> sudo reboot
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "amazon web services, aws deeplens"
}
|
Getting all my check-ins from a single category via Foursquare's API
So here's what I'm trying to do: I have a space on my website that says X cups of coffee. Ideally the X would be replaced with the number of times I have checked into a venue on Foursquare that falls under the coffee shop category. Right now, I have to manually update the number from my site's backend. This is just too much work, and I'd rather be able to check-in and have the Foursquare API update the number automatically. Is this possible, and if so, what would be the easiest way to execute it?
Thanks so much in advance for your suggestions and help!
|
You can use the realtime push API to notify your server whenever you check in on Foursquare. You can then use the information in the check-in to update statistics on your website.
Here is the documentation for the push API: <
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "api, foursquare"
}
|
Excel: return date from days count
In a cell I have a starting date (e.g. 01 Jan 2000). What function allows me to print the exact date after an amount of days (01/01/2000+ e.g. 165,728066 days). It should count for months with 28,30 and 31 days of course. It should be something like (~) 15 June 2000
|
As I mentioned in comments above, you can use
=DATE(2000,1,1)+165,728566
or write in `A1` cell `1/1/2000` and in `B1` cell `=A1+165,728566`
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "excel, excel 2007, excel formula"
}
|
Editing static control both statically and dynamically
I've got a static control in ASP.NET - a regular old `<ul>` on a master page. On some of the content pages I add to this `<ul>` statically by just inserting `<li>` statically in the content placeholder, but on one of the others I'd like to add dynamically on the server side, e.g. an `<li>` for each file in a directory. How can I achieve both these objectives? When I add `runat="server"` it still doesn't seem to have a server-side representation I can modify.
|
I just wrote a loop in the template directly, instead of some C# code-behind.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c#, asp.net 4.0"
}
|
Typescript declare type of defined strings or any string
I failed to find information on this elsewhere. I want to create a type that has both defined strings or allows any type of string to be used, but giving auto suggestion for the defined entries.
Right now if I add the `// | string` at the end, it sort of takes over, and doesn't give any auto suggestion.
// if I add this it stops suggestions
type DefinedLetters = 'A' | 'B' | 'C' // | string
const Letter: DefinedLetters = '' // Should suggest A, B or C, but also allow D, E, F, etc.
|
I found this cool `LiteralUnion` type researching this for you, I think it works like a charm!
type LiteralUnion<T extends U, U = string> = T | (U & { });
type DefinedLetters = LiteralUnion<'A' | 'B' | 'C'>
const Letter: DefinedLetters = "Cool!"
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "javascript, typescript"
}
|
Can I link node@6 by force?
Is it ok to link `node@6` by force?
$ which node
$ echo $?
1
$ brew link node
Error: No such keg: /usr/local/Cellar/node
$ brew search node
leafnode llnode node node-build [email protected] [email protected] node@4 node@5 node@6 nodebrew nodeenv nodenv
Caskroom/cask/mindnode-pro Caskroom/cask/node-profiler Caskroom/cask/nodebox Caskroom/cask/nodeclipse Caskroom/cask/printnode Caskroom/cask/soundnode
$ brew link node@6
Warning: node@6 is keg-only and must be linked with --force
Note that doing so can interfere with building software.
* * *
Edit:
I went ahead and did it:
$ brew link node@6 --force
Linking /usr/local/Cellar/node@6/6.9.5... 7 symlinks created
`node` and `npm` work fine now. Scary warning.
|
You may (I have) run into some Cellar issues..
What is the output you got from brew doctor?
I had this when executing `brew doctor`:
Warning: Some keg-only formula are linked into the Cellar. Linking a keg-only formula, such as gettext, into the cellar with `brew link <formula>` will cause other formulae to detect them during the `./configure` step. This may cause problems when compiling those other formulae.
I had to execute `brew unlink node@6` for it to return 'your system is ready to brew'.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 11,
"tags": "node.js, macos, npm, homebrew"
}
|
How to fetch first 100 records from Redis
I am working on small application where I am using redis to hold my intermediate data. After inserting data, I need to reload my data in same order in which i have inserted.
I am using `keys` method to get all keys but the order of returned keys is not same as they were inserted.
|
You have to maintain order yourself, by keeping a separate list for inserted keys. So, instead of
SET foo, bar
you may do something like this:
SET foo, bar
RPUSH insert_order, foo
Then you can do
LRANGE insert_order, 0, 100
to get first 100 set fields.
If you want to track actual insertion (and not updates), you can use SETNX, for example. Also, you can use a sorted set instead of a list (as mentioned by @Leonid) Additionally, you can wrap the whole thing in Lua, so that the bookkeeping is hidden from the client code.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "redis"
}
|
Is it possible to automatically move objects from an S3 bucket to another one after some time?
I have an S3 bucket which accumulates objects quite rapidly and I'd like to automatically move objects older than a week to another bucket. Is it possible to do this with a policy and if so what would the policy look like.
If there can't be move to another S3 bucket is them some other automatic mechanism for archiving them potentially to glacier?
|
Yes you can archive automatically from S3 to Glacier.
You can establish it by creating a Lifecycle Rule in the Amazon Console.
<
Archiving Amazon S3 Data To Amazon Glacer
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "amazon web services, amazon s3, amazon glacier"
}
|
Excel - verify that all identical values in a column are in consecutive rows / Highlight or count non-consecutive duplicate values
I need to verify if all duplicate values in an Excel column are in consecutive rows or not. I do not want to change the sort order of Excel. I just need to know whether there are duplicate values which are not in consecutive rows, as some of the processing I need to do relies on the assumption that all identical values will be in consecutive rows.
For example, if the values are like this:
John
John
Mary
Mary
John
Bob
Bob
Mary
I need to identify the John in the 5th row and Mary in the 8th row as non-consecutive duplicates, so that I can send the data back to the user and ask them to correct the data before I process it further.
|
Here's a way to identify them with a new column, using a relatively simple formula:
=IF(AND(A2<>A1,COUNTIF($A$2:A2,A2)>1),"non-consec dupe","ok")
It's counting the number of times that name appeared in the list from that point and above, and if it's more than one time AND the name above it is different, then flag as "non-consec dupe".
Or if you rather want to use a conditional formula to highlight the cell rather than add a new column, then use this as a conditional format formula in column A:
=(AND(A2<>A1,COUNTIF($A$2:A2,A2)>1))
, but $\pi_1(S^2 \times S^1) \simeq \pi_1(S^1) = \Bbb{Z}$.
More intuitively, try this: in $S^3$, any imbedded 2-sphere will separate the space into two connected components. But in $S^2 \times S^1$, a 2-sphere $S^2 \times \\{x\\}$ does not separate the space.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "differential geometry, fiber bundles, fibration, hopf fibration"
}
|
Simple future or "be going to" in: "Help! I will/am going to fall"
Do I use the simple future tense or the "be going to" tense in a situation that has not yet happened?
> 1. Help! I will fall.
> 2. Help! I am going to fall
>
My approach:
I think the action will happen in the future. Hence _we will fall_ if no one helps. Therefore, I think the simple future tense _will_ is correct.
Am I right In my approach?
|
Your approach is about probability of an event in the future but for this case, custom rules govern.
"am going to" is better to describe an immediate action, for example, the falling is going to happen in few seconds.
"Am falling" or "am about to fall" is also fine, serving a function similar to "am going to".
"Will fall" seems to lead people think that the falling is not going to happen soon, or only conditionally happens. For example,
"Help prepare my funeral tonight. I will fall at 10pm sharp." (Not going to happen soon.)
"Help reduce the weight or the plane will fall in an hour." (Conditionally happen)
|
stackexchange-ell
|
{
"answer_score": 1,
"question_score": 0,
"tags": "future tense, progressive aspect, future time, will vs going to"
}
|
How to generate Android app bundle in React Native?
I used the official documentation of React Native to build apk file. All other procedures worked fine but creating aab file is not working for me. I used the following command cd android && ./gradlew bundleRelease But it's not working on Windows. It is just giving me error of ". is not recognized"
|
to create main js Bundle
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
and then run cd android && ./gradlew assembleRelease
|
stackexchange-stackoverflow
|
{
"answer_score": 23,
"question_score": 12,
"tags": "android, react native, apk"
}
|
Running SSIS Package simultaneously on 2 different servers
I have made a SSIS package which takes data from source through a stored procedure and saving it in my tables through a stored procedure in destination side. Destination and Source are at different server. So basically i have an Insert Stored Procedure at Source and an Insert Stored Procedure at destination. I have two different servers Server 1(dev server) and Server 2(test server). i want to use the same SSIS package without needing to change the schema names and server names ( Transferring data from there dev server to my dev server OR their test server to my test server)
How to proceed for this and what all steps to follow .?
|
Are you using DataFlow tasks to move the data from Source to Destination? Or are you using the "Execute SQL Task" to execute your stored procedures?
Are you running the SSIS package manually or is it being scheduled?
Here are your options: 1\. Make a copy of the DataFlow with Dev connections and then change it to connect to Test Server. 2\. Setup Package configurations utilizing Environment Variable and SSIS Config table.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "sql server, stored procedures, ssis"
}
|
AngularJS ui-sref links stuck
I got an AngularJS based website. Everything is working fine. For navigation I use ui.router.
After I use a lightbox (simplbox.js) links stop working. There is no error message in the log, no warning or anything that indicates that using simplbox and ui.router might cause problems.
Could there be any other reason, why links stop working? If not, how could I debug this?
EDIT:
Once I open and close the simplbox I can use exactly one more link, then links stop working. However, simplbox is still working, as well as other features of the site. "Only" navigation is frozen.
|
I found a solution that still does not satisfy me entirely. So if anybody can provide some insight I'd be happy to change the accepted answer.
The error was caused by the way I implemented the jquery.min.js. So totally unrelated to angularJS and ionic. First I use a generated cdn code such as
`<script src=" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="crossorigin="anonymous"></script>`
Back then it was version 2.2.2. What I did was to download the exact same version and include it directly in my index.html.
Changing it back from local to cdn everything works as should do. No problems with the ui-sref links.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "javascript, angularjs, anchor"
}
|
Почему в функцию передает только первый элемент массива
 {
return sizeof(arr)/sizeof(T);
}
int main()
{
int nums[]{9, 23, 54, 23};
cout << arr_size<int>(new int[4]{7,34,54,14});
return 0;
}
|
Да потому что несмотря на вашу инициализацию
new int[4]{7,34,54,14}
вы получаете и передаете в шаблон указатель `int*`. Поскольку в шаблон вы передаете массив по значению, тип низводится до указателя, и может принять ваш `int*` без проблем. Именно по этой причине (из-за низведения) даже если вы передадите в шаблонную функцию ваш `nums` \- результат будет тем же.
У вас может сработать - для массива `nums`, не для `new int...` \- вот такой шаблон:
template <class T, int N>
T arr_size(T (&arr)[N]) {
return sizeof(arr)/sizeof(T); // А еще лучше - return N;
}
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "c++, массивы, шаблоны с++"
}
|
can we access a python console in a terminal via an interruption within the python script for debugging
To clarify my question, for example in some IDEs such as PyCharm one can put a breakpoint in the code, run the python script and when the code reaches that breakpoint, the program stops while the user can investigate some of the variables until that breakpoint.
Is such functionality possible through a terminal, that is executing a python code but while having it stopped at a certain line, a python console would be available for debugging.
|
Yes, you can use builtin Python Debugger `import pdb; pdb.set_trace()` as a one-liner to get full access to the current scope you are in, ability to call any functions, step through code, display values etc.
There's also < which needs to be installed separately. It has all the features that pdb has and then some.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python"
}
|
Recover data deleted by diskpart
After accidentally deleting all data on my disk using "clean" on diskpart, my HDD is now empty. I've searched and used some recovery data apps, one of them is EaseUS. After scanning hours, it shows up exactly all data I lost but requiring fee to recover.
I want to know that how all the data is still remained and found by the app while the disk show in my computer is empty and is there any reliable and safe ways to recover all data that do not require money?
_p/s: Sorry for bad english, I hope you guys understand and help me with this problem._
|
Knoppix is a free data recovery system based on Linux but can recover Windows data as well.
<
Create a bootable USB.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "disk partitioning, file recovery, diskpart"
}
|
Delete a JSON object from a file on discord.js v12
I've searched for a very long time on every site I can get my hands on. Each provided no help and left me with the same issue of the object remains. The code for the command is here and the JSON file I am attempting to modify is here. Is there a solution for this? I've added a temporary one where I have to manually remove it myself by the bot DMing me with a request
|
You can use edit-json-file package from NPM.
It has an "`unset(path)` **Remove a path from a JSON object.** " method.
An example can be:
const editJsonFile = require("edit-json-file");
let file = editJsonFile("C:/Users/worko/Desktop/GitHub/area-17/characters.json");
//Put your discord code here
file.unset("Tavi-chan Wood");
//or
file.unset("Tavi-chan Wood.content");
file.save();
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "javascript, json, discord.js"
}
|
Was making 'dyslexia' hard to spell, a sadistic act?
!enter image description here
Dyslexic (n.) is first recorded 1961; dyslectic (adj.) from 1964.
My point is this - the Latin "legere" was already sufficient, "lexis" was contrived (I jest) out of the 'confusion' (see image) of "legere" and "legein". Unnecessarily I would suggest.
The word could have easily been "disleger", without any confusion of readability or spelling whatsoever.
Although some negative connotative association surrounding leg removal may have arisen.
|
I think that, while somewhat ironic, the word follows normal pathways of development. Since dyslexia is difficulty in learning to read or interpret words, letters, and other symbols, it follows that terms already in existence for _words_ would be used.
Before _dyslexia_ was _lexicon_ :
c.1600, "a dictionary," from Middle French lexicon or directly from Modern Latin lexicon, from Greek lexikon (biblion) "word (book)," from neuter of lexikos "pertaining to words," from lexis "word," from legein "say".
Used originally of dictionaries of Greek, Syriac, Hebrew and Arabic, because these typically were in Latin and in Modern Latin lexicon, not dictionarius, was the preferred word.
From lexikos (pertaining to words), we add dys- (prefix meaning _bad, ill, abnormal_ ) and get dyslexia.
Internationally, dyslexia has no single definition; more than 70 names are used to describe its manifestations, characterizations or causes. It would be interesting to find these names, but I could not.
|
stackexchange-english
|
{
"answer_score": 6,
"question_score": 1,
"tags": "meaning, etymology"
}
|
From Keyword Not Found Where Expected Error in Self Join
I have a data table Employees, I want to show the employee name, the employee number, the manager number and the manager name of the employee who has the least salary in the company. I decide to perform a self join, and here's my code:
select worker.employee_id, worker.last_name "Worker Last Name",
worker.salary manager.last_name "Manager Last Name", manager.manager_id
from employees worker join employees manager
on worker.manager_id = manager.employee_id
having worker.salary = (select min(salary)
from employees);
However, when I run this, the error "from keyword not found where expected" pops up. What should I do?
|
Oops, realized my own mistakes. I forgot to place a comma between worker.salary and manager.last_name, and I should not have WHERE instead of HAVING.
select worker.employee_id, worker.last_name "Worker Last Name",
worker.salary, manager.last_name "Manager Last Name", manager.manager_id
from employees worker join employees manager
on worker.manager_id = manager.employee_id
where worker.salary = (select min(salary)
from employees);
After fixing those two mistakes, the code runs fine.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "oracle sqldeveloper"
}
|
How to remove definition In between lines by coc-nvim
I want to remove the inline definition that come like this (underline parts): 
:e %
Or either:
:call coc#config("inlayHint", {"enable" : v:false})
:CocRestart
|
stackexchange-vi
|
{
"answer_score": 1,
"question_score": 1,
"tags": "vimrc, plugin coc, original vim"
}
|
how to find distinct values in has_many :through
Say I have the following in my console:
@user.favcolors
=> [#<FavColors id: 1, color_id: 18, fav_id: 1>,
#<FavColors id: 2, color_id: 19, fav_id: 1>]
@user.favcolors.count
=> 2
However, since fav_id is same in both results (1). I want this count to be 1, instead of 2.
Is there a way I can put `where` clause in the code `@user.favcolors`?
|
@user.favcolors.find(:all, :group => 'favcolours.fav_id')
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "ruby on rails, activerecord"
}
|
Use or don't use 'this' within a object
My question refers to the case when I want to call other methods of the same class. Where's the difference of doing this with and without the use of 'this'? The same with variables of the class. Is there a difference accessing those variables through 'this'? Is it related to whether those methods / variables are private / public? Example:
class A {
private:
int i;
void print_i () { cout << i << endl; }
public:
void do_something () {
this->print_i(); //call with 'this', or ...
print_i(); //... call without 'this'
this->i = 5; //same with setting the member;
i = 5;
}
};
|
Generally, it's a question of style. All of the places I've worked have preferred not using the `this->`, except when necessary.
There are cases where it makes a difference:
int func();
template <typename Base>
class Derived : public Base
{
int f1() const
{
return func(); // calls the global func, above.
}
int f2() const
{
return this->func(); // calls a member function of Base
}
};
In this case, `this->` makes the name of the function dependent, which in turn defers binding to when the template is instantiated. Without the `this->`, the function name will be bound when the template is defined, without considering what might be in `Base` (since that isn't known when the template is defined).
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c++, methods, this, member"
}
|
Call to undefined function bzdecompress PHP
I have an Ubuntu 16.04 server with PHP7 + nginx running. I already have a project in PHP Laravel 5.1 running in my local enviroment (Windows with Xampp) and everything is running great. I have a PHP script that uses the function `bzdecompress` of `Bzip2` but then, in the server just crash and show this message:
Call to undefined function App\Http\Controllers\bzdecompress()
I don't see instructions of how install this library (if needed) or how to load it or check at least that is loaded. Thank you very much!
|
**1)** check your installed packages `php -m`
if bzip2 is installed move to step **3** directly , if not installed then install it by running :
**2)** for php7 :
apt-get install php7.0-bz2
for php5:
apt-get install php-bz2
**3)** then make sure that you've enabled your extension via :
phpenmod bz2
**4)** then you can restart your server
service nginx restart
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 4,
"tags": "nginx, laravel 5.1, ubuntu 16.04, php 7, bzip2"
}
|
how can I copy arrays with their keys and values with a foreach loop in c#?
in php, I cna use foreach $key->$value but in c sharp i couldn't find a similar solution, I have data values and I want to save them to session with their keys will be column names.so I'm tring to copy a datarow to session which will get key names from column names of datarow with a loop.
|
If it's a dictionary, you can use:
foreach (var item in dict) {
var key = item.Key;
var value = item.Value;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -2,
"tags": "c#, asp.net, arrays, session, loops"
}
|
Jackson processor for java bean to json\xml serialization
Hi I am having a java bean and i need to serialize it to json. For this purpose i am using the jackson processor which is very powerful. But I also need to convert the java bean to XML. Can this be achieved using the jackson processor ?? If yes then please provide with the links where I can get the examples. Thanks!!!!
|
Yes it is possible. You would need to annotate your Java bean using the JAXB annotations which will give you the XML marshalling and unmarshalling support. Then, using Jackson's support for JAXB annotations you can go back and forth between Java and JSON.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "java, jackson"
}
|
On the surjectivity of the Hurewicz homomorphism
The Hurewicz homomorphism is a surjective homomorphism from $\pi_n(X) \to H_n(X)$ if $\pi_{n-2}(X)=0$ according to Wikipedia.
But if it is surjective then how could the following (contradiction) I constructed be true?
$\pi_2(\mathbb{RP}^5)=\pi_2(S^5)=0$ so $\mathbb{RP}^5$ is $2$-connected. Thus $\pi_4(\mathbb{RP}^5)\to H_4(\mathbb{RP}^5)$ is a surjective homomorphism. But $H_4(\mathbb{RP}^5)=\mathbb{Z}/2$ and $\pi_4(\mathbb{RP}^5)=\pi_4(S^5)=0$. So the Hurewicz homomorphism can't be surjective.
|
A topological space $X$ is called $k$-connected if $\pi_i(X) = 0$ for $0 \leq i \leq k$. The Hurewicz theorem states that if $X$ is $(n-2)$-connected, then the Hurewicz homomorphism $h_* : \pi_n(X) \to H_n(X)$ is surjective.
In your example, while $\pi_2(\mathbb{RP}^5) = 0$, $\pi_1(\mathbb{RP}^5) = \mathbb{Z}/2\mathbb{Z} \neq 0$, so $\mathbb{RP}^5$ is not $2$-connected and therefore the Hurewicz theorem does not apply.
|
stackexchange-math
|
{
"answer_score": 7,
"question_score": 6,
"tags": "algebraic topology, homology cohomology, homotopy theory"
}
|
Can I restore a SQL Server 2008 R2 backup to SQL Server 2008 R2 Express?
I have a server that's currently running SQL Server 2005 Express, and I need to restore a database backup that a developer has modified using SQL Server 2008 R2 [I _think_ the full version, but still waiting to hear back on whether it's a full edition or Express].
I know that I can't restore a database from SQL Server 2008 R2 to SQL Server 2005 Express, and I know that I can't even restore a database from SQL Server 2008 R2 to SQL Server 2008. BUT! Can I restore a database from SQL Server 2008 R2 to SQL Server 2008 R2 Express? The only difference here being that one is a full paid version, and the other is the express version. If so, I'll just update the SQL Server 2005 Express server to 2008 R2 Express.
Thanks in advance!
|
Yes.
It's the database version that matters and is what gets attached to the database, not the edition of MSSQL used. As long as the database version is the same, you can move it between the free (Express) and paid versions to your heart's content... not that it's a process I'd recommend for recreational purposes.
EDIT: Since it's been mentioned, the relevant database-limitation in SQL Express 2008 R2 is a size limit of 10GB. It also has some limitations on the services and resources available to MSSQL Server, but those won't prevent you from restoring the database to it, only (possibly) using it how you'd like.
Full Technet feature comparison for 2008 R2 versions linked here.
|
stackexchange-serverfault
|
{
"answer_score": 2,
"question_score": 5,
"tags": "sql server 2008, sql server 2005, sql server 2008 r2, backup restoration"
}
|
Rounding the place.geometry.location value in Google Maps API
I am using Google Maps API to do Reverse Geocoding (Address Lookup). My code result a extremely detail `Lat Long` as:
(-7.799250499999999, 110.40451239999993)
How to round the place.geometry.location result into a certain digit decimals?
e.g. (-7.7992505, 110.4045124)
This is the scheme of my code:
**In my HTML**
<div id="infowindow-content">
<span id="place-coord"></span>
</div>
**In my Javascript**
...
function() {
...
infowindowContent.children['place-coord'].textContent = place.geometry.location;
...
}
...
I had tried to use:
place.geometry.location.toUrlValue(precision?:number)
or
place.geometry.location.toUrlValue(precision?:7)
and result some crash.
Any helps would be highly appreciated. Thanks
|
The `precision?:number` code must be replaced by an integer.
place.geometry.location.toUrlValue(WriteYourDesiredPrecisionHere)
in this question, it sould be:
place.geometry.location.toUrlValue(7)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -2,
"tags": "javascript, php, google maps api 3, location, coordinates"
}
|
Update database column in rails
I have a problem, I want to update my database's "active" column. my schema =
tablename(name:string , id:int , active:0 ,created_at)
I want to update active attribute in my rails app after a certain period of time let say 2 days from the created_at time
I have tried few stuff like this from controller but none of this worked for me.. can anyone help ?
def check_aim
@aim = Aim.find(1)
aimdays = @aim.day
futuredate = @aim.created_at+aimdays.days
if(Time.now == futuredate)
@aim.active = false # i have tried @aim.update_attribute(:active,1) also didn't word either
@aim.save
end
if @aim.save
saved
else
not saved
end
end
helper_method :check_aim
view class
=debug check_aim
this returns
saved
but when i see my database nothing has changed ... plz help
|
I figured it out.. stupid rails
Guys this is the most stupid thing by rails... it was nothing but the problem of keyword 'active' i changed column name from active to status and now it works fyn.. damm it !!! I wasted hours on this :/
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "ruby on rails, ruby, ruby on rails 3, ruby on rails 4, rubygems"
}
|
A group topology which commutes with closed subgroups
For a topological group $(G,\mathcal T)$ and a subgroup $H\le G$, we say $\mathcal T$ and $H$ are permutable if for every neighborhood $U$ of $1$, there is a neighborhood $V$ of $1$ with $VH\subseteq HU$.
Do you have an example of an infinite (preferably nonabelian) Hausdorff topological group $(G,\mathcal T)$ such that $\mathcal T$ is not discrete and for every closed subgroup $H$ of $G$, $\mathcal T$ and $H$ are permutable?
|
I will give a class of metric examples.
Let $G_1$ be an abelian group with a metric $d_1$.
Let $G_2$ be a discrete nonabelian group, with metric $d_2(x,y)=1$ for all $x\not=y$.
Let $G:= G_1\times G_2$, with $d( (x_1, x_2), (y_1, y_2)) = d_1(x_1,y_1) + d_2(x_2, y_2)$.
Let $H$ be any subgroup of $G$. Let $U$ be a neighborhood of $1$. Wlog the neighborhood $U$ is a ball of radius $\varepsilon$, and wlog $\varepsilon < 1$.
Then for all $(x,y)\in U$ we must have $y=1$. So $UH=HU$.
|
stackexchange-mathoverflow_net_7z
|
{
"answer_score": 0,
"question_score": 0,
"tags": "topological groups"
}
|
Monitor GAC changes in registry with WMI - RegistryKeyChangeEvent GACChangeNotification Not Found
I'm trying to monitor the registry for changes to the GAC using WMI. I have the following code:
WqlEventQuery query = new WqlEventQuery(@"SELECT * FROM RegistryKeyChangeEvent WHERE Hive = 'HKEY_LOCAL_MACHINE' AND KeyPath='SOFTWARE\\Microsoft\\Fusion\\GACChangeNotification\\Default'");
_regWatcher = new ManagementEventWatcher(query);
_regWatcher.EventArrived += new EventArrivedEventHandler(_regWatcher_EventArrived);
_regWatcher.Start();
But when it calls Start(), it causes a ManagementException with the message "Not Found". I copied the key path from the registry so I know it exists. I have never done this before, so maybe I'm misusing it. I want to receive notification when any value is changed in the Default key (specifically when a value is added). Why is it giving the "Not Found" exception and how do I correctly monitor this key for changes using WMI?
|
You are surely yet another victim of the registry redirector in the 64-bit version of Windows. Project + Properties, Build tab, change the Platform target setting from x86 to AnyCPU. On VS2012 and up, untick the "Prefer 32-bit" checkbox.
Your program will now as a 64-bit process and can properly see the registry key. Instead of the HKLM\Software\Wow6432Node subkey you tried to look at before.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, .net, registry, wmi query"
}
|
Calling C++ DLLs from Python
I'd like to know if it is possible to use ctypes to access C++ DLLs from Python and run functions (or class methods) from them.If not, is there another way to do this?
|
This question has been answered many times (this one is an exact duplicate!)
In summary, no you can't do it with Ctypes (yet) but there are a number of other code generators you could use to do the job. SWIG and Boost.Python are two of the most popular.
|
stackexchange-stackoverflow
|
{
"answer_score": 10,
"question_score": 8,
"tags": "ctypes"
}
|
How to do Laravel ORM subquery
How can I do the `sql` below in laravel ORM.
select * from comments where page_id in (
select id from pages where pages.user_id = "kombuwa"
)
|
You can do it this way:
$userId = 'kombuwa';
$comments = DB::table('comments')->whereIn('page_id', function($q) use ($userId) {
$q->select('id')->from('pages')->where('pages.user_id', $userId);
})->get();
(I moved `$userId` to variable just in case you want to use it from input for example)
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "laravel, orm"
}
|
How is the Cofinite Topology on an infinite set even possible?
To be a topology we need the empty set to be open but- X is not finite so the empty set can't be in it and if X was finite every subset of X would be in the topology...
|
The definition of the cofinite topology is that the open sets are the cofinite sets _and_ the empty set.
|
stackexchange-math
|
{
"answer_score": 6,
"question_score": 0,
"tags": "general topology"
}
|
Sql lite - date calculation result is in year only
I have col1 with date inserted values... YYYY-MM-DD
I am trying to do simple date calculation with returning days
select current_date - col1 from my_table;
This result calculates only years, but i am trying to get only days since two dates. Any suggestions?
|
Compute the number of days since the signing of the US Declaration of Independence.
SELECT julianday('now') - julianday('1776-07-04');
from <
So you should be able to write something like this
select julianday('now') - julianday( col1 ) from my_table;
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "sqlite"
}
|
git error "Please tell me who you are." and Heroku
I was working in `branch master`, and committing to Git repository. Everything worked fine. I connected new app to this repository on Heroku.
I was committing to both Heroku and Git. Everything worked fine again (except I cannot run db:migrate on Heroku but that is another question...). After my last commit I run `git status` and received: `On branch master. Your branch is up-to-date with 'origin/master'.`
Today I made some changes in my code, but suddenly I cannot commit - received error "Please tell me who you are." The only difference from previous commits is that had a migration, if it is of any importance. When I run `git config --global --get user.email`command I get an empty line in return.
Why have I suddenly lost connection to git?
|
It seems that your `email`, and `name` parameters in global config are empty. Probably you have executed something like this, that has dropped the values:
git config --global user.name ""
git config --global user.email ""
Just fill them with commands again:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Where `[email protected]` is your github email.
**NOTE:** You can push out of hand to heroku, bypassing the github, since heroku also have git repo itself.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "ruby on rails, git, heroku, github"
}
|
Is it true $\forall\ n\ \exists\ p (p^2 \leq n < (p + 1)^2$) where the domain of the quantifiers is $\mathbb{N}$?
Is it true $\forall\ n\ \exists\ p ( p^2 \leq n < (p + 1)^2$) where the domain of the quantifiers is $\mathbb{N}$?
I think this is true.
How to prove?
|
For given $n$, the set $$\tag1\\{\,k\in\Bbb N\mid n<(k+1)^2\,\\} $$ is non-empty because it contains $n$, for example: $$ (n+1)^2=n+(n^2+n+1)\ge n+1>n.$$ Hence $(1)$ has a minimal element $p$. If $p=\min\Bbb N$ (i.e., $p=0$ or $p=1$, depending on how you define $\Bbb N$), then $p^2=\min \Bbb N\le n$. If $p>\min \Bbb N$, then $p=k+1$ for some $k\in\Bbb N$, where by minimality of $p$, we have $n\not<(k+1)^2$, i.e., again $n\ge p^2$.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": -1,
"tags": "discrete mathematics"
}
|
How to load the math tesseract module?
So I am new to use tesseract and I want to load the math input module. Unfortunately, I do not know how to use it with the math module as found in this link. How do I made this properly load? Will it load the trained data by default? I've already added the trained data to the appropriate tessdata folder? i cannot figure out what the isocode for the lang parameter should be? is something like mat? There is very limited documentation on this issue and any help would be appreciated.
I am also coding this with pytesseract, but I am open to other modules if it does not support changing the trained dataset.
|
Okay so apparently the iso-639 for "math" is equ even though this is technically not an isocode according to the official list on Wikipedia.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, ocr, tesseract, pytesser"
}
|
How to use a 2d array to declare an array_view or array object in c++ AMP
I'm trying to use an array such as `int myarray[2][3]` to initialize an `array_view` object. I've tried `array_view<int, 2> a(2,3, myarray);` However that does not work. I would also like to be able to do the same thing with a vector. Any ideas?
|
Try `array_view<int, 2> a(2, 3, *myarray);`
**EDIT :**
A vector of (fixed-size) vectors can't be used directly to init an array_view object.
However you could do something like that:
vector< vector<int> > my_multi_vector; // Fill my_multi_vector with data
vector<int> my_composed_vector;
for(int i = 0, ie = my_multi_vector.size(); i != ie; ++i)
my_composed_vector.insert(my_composed_vector.end(), my_multi_vector[i].begin(), my_multi_vector[i].end());
array_view<int, 2> a(2, 3, &my_composed_vector.front());
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "c++, parallel processing, gpgpu, c++ amp"
}
|
PDFBox 2.0 : Invisible text from PDFTextStripper
File example is here
I think I need some help from _mkl_ again( in attached file there are some hidden () characters which PDFTextStripper extracts. For now I don't see what makes it invisible (for example see column 6 values - all they are in brackets:
Publix Liquors 1,600 2.5 1/1/2014 12/31/2018 ($ 24,000.00) ($ 4,032.00) ($ 28,032.00) BayCare Health Systems 3,200 5 7/30/2004 7/31/2018 ($ 51,200.00) ($ 9,648.00) ($ 60,848.00) No rent change until Option Period 8/11/2018
..............
Could you please at least point why they are hidden _in this case_? thanks in advance!
|
In this case you deal with actual transparency.
The hidden brackets are created by blocks of instructions like this
q
/Alpha3 gs
0 0 0 rg
BT
0 Tr
/Font0 14.299999 Tf
1.0 0 0 -1.0 537.66486 195.42578 Tm
0 0 Td
<037F>
Tj
ET
Q
The extended graphics state **Alpha3** in the resources is declared as
14 0 obj
<<
/CA 0
/ca 0
>>
endobj
Thus, `/Alpha3 gs` sets both the stroke and the fill opacity to 0, i.e. anything drawn using fill or stroke is completely transparent.
In the PDFBox `PDFTextStripper` these values can be retrieved in `processTextPosition` from the current graphic state (`getGraphicsState`) as properties `getAlphaConstant` and `getNonStrokeAlphaConstant`
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -1,
"tags": "java, pdf, pdfbox"
}
|
String replace in unix
I am to remove some text after a number for example: 1.2.0_testing. I just want the number part which is 1.2.0. SO anything after the underscore needs to be removed. Below is the code I am using:
echo $str | sed 's/_*//'
However the wildcard doesn't seem to work and I still get the full string. Can someone please help me.
Thanks!
|
No need for expensive forks to sed, awk, or - gasp! - perl. The shell can do this nicely:
$ str=1.2.0_testing
$ echo ${str%%_*} # Remove longest part from the right matching _*
1.2.0
Learn all there is about built-in string manipulation with %, %%, #, ## in your fine shell manual. These remove from the right (percent) or left (hash) the shortest (single) or longest (double) match.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "bash, shell, unix, string matching"
}
|
Wronskian of the ODE $u''(t)+P(t)u'(t)+Q(t)u(t)=R(t)$?
Given equation $$u''(t)+P(t)u'(t)+Q(t)u(t)=R(t)$$ where $P,Q$ and $R$ are continuous functions defined on $t\in[0,1]$ and $u_1$ and $u_2$ be two solutions of this ODE. Then which of the following is the Wronskian $W$.
1. $W(t)=2t-1,~0\leq t \leq 1$
2. $W(t)=\sin{2\pi t},~0\leq t \leq 1$
3. $W(t)=\cos{2\pi t},~0\leq t \leq 1$
4. $W(t)=1,~0\leq t \leq 1$
This is a non-homogeneous case. I do know how to find the Wronskian for the homogeneous case by using the relation $W'=uv''-vu''$ but I failed with the non-homogeneous case with this trick. How can I do this?
Also if it says $u_1$ and $u_2$ are two solutions then does it implies they are necessarily linearly independent, in general? How can I conclude this?
|
The Wronskian is **always** associated with a homogeneous equation, hence the question is about the Wronskian of the corresponding homogeneous equation, not the Wronskian of the equation itself.
By Abel's identity, the Wronskian is either zero for all $t\in [0,1]$, or else it is never zero. Now let's look at the options:
1. $2t-1$ is equal to zero at $t=1/2$, but not equal to zero at some other points in $[0,1]$, so it is not the Wronskian.
2. $\sin 2\pi t$ is equal to zero at $t=1/2$, but not equal to zero at some other points in $[0,1]$, so it is not the Wronskian.
3. $\cos 2\pi t$ is equal to zero at $t=1/4$, but not equal to zero at some other points in $[0,1]$, so it is not the Wronskian.
It follows that among the four options given, only $W(t)=1\,\forall t\in[0,1]$ can be the Wronskian, that is, if it is known that it must be one of these four.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 2,
"tags": "ordinary differential equations"
}
|
Does the geometry of a lever alter the behavior of rotation
Here is a simplified example

|
You forgot to specify `blank=True` in your `ManyToManyField` declaration:
class Article(models.Model):
tags = models.ManyToManyField(ArticleTag, blank=True,
related_name="articles")
> Also, is there a fairly easy way to create a control to facilitate tagging as per stack overflow or delicious.com?
There's nothing built-in, but there are several add-on libraries for Django that do tagging. One of them might fit your needs.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "python, django, django models, django admin"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.