qid
int64 1
74.7M
| question
stringlengths 0
70k
| date
stringlengths 10
10
| metadata
list | response
stringlengths 0
115k
|
---|---|---|---|---|
57,546,337 |
I want to open a file (`file`) that is stored in a folder (`Source`) which is in the same directory as the current workbook. I get a runtime error 1004 indicating that it the file can't be located. What am I doing worng?
```
Set x = Workbooks.Open(ThisWorkbook.Path & "\Source\file*.xlsx")
```
|
2019/08/18
|
[
"https://Stackoverflow.com/questions/57546337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3435347/"
] |
Since you want the wildcard to stay, you need to loop through the files in the folder. Something like this may be of interest to you:
```
Sub FileOpen()
Dim sPath As String
Dim sFile As String
Dim wb As Workbook
sPath = ThisWorkbook.Path & "\Source\"
sFile = Dir(sPath & "file*.xlsx")
' Loops while there is a next file found in the specified directory
' When there is no next file the Dir() returns an empty string ""
Do While sFile <> ""
' Prints the full path of the found file
Debug.Print sPath & sFile
' Opens the currently found file
Set wb = Workbooks.Open(sPath & sFile)
' Place your code here
' Place your code here
' Place your code here
' Close the current workbook and move on to the next
wb.Close
' This line calls the Dir() function again to get the next file
sFile = Dir()
Loop
End Sub
```
Good luck!
|
37,242,600 |
I'm struggling with this and I'm not so clear about it.
Let's say I have a function in a class:
```
class my_class(osv.Model):
_name = 'my_class'
_description = 'my description'
def func (self, cr, uid, ids, name, arg, context=None):
res = dict((id, 0) for id in ids)
sur_res_obj = self.pool.get('contratos.user_input')
for id in ids:
res[id] = sur_res_obj.search(cr, uid, # SUPERUSER_ID,
[('contratos_id', '=', id), ('state', '=', 'done')],
context=context, count=True)
return res
columns = {
'function': fields.function(_get_func,
string="Number of completed Contratos", type="integer"),
my_class()
```
Now I want to call this very same function from another class-object:
```
class another_class(osv.Model):
_inherit = 'my_class'
_name = 'my_class'
columns = {
'another_field' : fields.related('function', 'state', type='char', string = "Related field which calls a function from another object"),
}
```
But this isn't working, I'm very confused about this, how can I call a function from another object in Odoov8?
I've heard about `self.pool.get` but I'm not really sure on how to invoke it.
Any ideas?
Thanks in advance!
|
2016/05/15
|
[
"https://Stackoverflow.com/questions/37242600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2089267/"
] |
Since you're using odoo8 you should use the new API. from the docs
>
> In the new API the notion of Environment is introduced. Its main
> objective is to provide an encapsulation around cursor, user\_id,
> model, and context, Recordset and caches
>
>
>
```
def my_func(self):
other_object = self.env['another_class']
other_object.create(vals) # just using create as an example
```
That means you don't need to explicity pass `cr`, `uid`, `ids`, `vals` and `context` in your methods anymore and you don't use `self.pool.get()` even though it's still there for backward compatibility
`env` is dictionary-like object that is used to store instances of the Odoo models and other information so you can access other objects and their methods from any Odoo model.
|
37,916,763 |
I need to remove a string ("DTE\_Field\_") from the id of elements in the dom.
```
<select id="DTE_Field_CD_PAIS" dependent-group="PAIS" dependent-group-level="1" class="form-control"></select>
var str=$(el).attr("id");
str.replace("DTE_Field_","");
```
|
2016/06/20
|
[
"https://Stackoverflow.com/questions/37916763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1883099/"
] |
Use [**`attr()`** method with callback](http://api.jquery.com/attr/#attr-attributeName-function). That will iterate over element and you can get old attribute value as callback argument you can update attribute by returning string where `DTE_FIELD` using **[`String#replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)** method.
```
$('select').attr('id', function(i, oldId) {
return oldId.replace('DTE_field_', '');
});
```
```js
$('select').attr('id', function(i, oldId) {
return oldId.replace('DTE_Field_', '');
});
```
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="DTE_Field_CD_PAIS" dependent-group="PAIS" dependent-group-level="1" class="form-control"></select>
```
---
If the element is not always select then you can use **[`attribute contains selector`](https://api.jquery.com/attribute-contains-selector/)**(or if `DTE_field_` is always at the beginning then use **[`attribute starts with selector`](https://api.jquery.com/attribute-starts-with-selector/)**).
```
$('[id*="DTE_field_"]').attr('id', function(i, oldId) {
return oldId.replace('DTE_field_', '');
});
```
|
2,880,293 |
$$I=\large \int\_{0}^{\infty}\left(x^2-3x+1\right)e^{-x}\ln^3(x)\mathrm dx$$
$$e^{-x}=\sum\_{n=0}^{\infty}\frac{(-x)^n}{n!}$$
$$I=\large \sum\_{n=0}^{\infty}\frac{(-1)^n}{n!}\int\_{0}^{\infty}\left(x^2-3x+1\right)x^n\ln^3(x)\mathrm dx$$
$$J=\int \left(x^2-3x+1\right)x^n\ln^3(x)\mathrm dx$$
We can evaluate $J$ by integration by parts but problem, the limits does not work.
**How to evaluate integral $I?$**
|
2018/08/12
|
[
"https://math.stackexchange.com/questions/2880293",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] |
Here's a way that only requires the identity $\Gamma'(1) = - \gamma$ , since all derivatives of higher order cancel:
\begin{align}
I &=\int \limits\_0^\infty (x^2 - 3x+1) \ln^3 (x) \mathrm{e}^{-x} \, \mathrm{d} x \\
&= \left[\frac{\mathrm{d}^2}{\mathrm{d} t^2} + 3 \frac{\mathrm{d}}{\mathrm{d}t}+1 \right] \int \limits\_0^\infty \ln^3 (x) \mathrm{e}^{- t x} \, \mathrm{d} x ~\Bigg\vert\_{t=1}\\
&= \left[\frac{\mathrm{d}^2}{\mathrm{d} t^2} + 3 \frac{\mathrm{d}}{\mathrm{d}t}+1 \right] \frac{1}{t} \int \limits\_0^\infty \left[\ln^3 (y) - 3 \ln^2(y) \ln(t) + 3 \ln(y) \ln^2(t) - \ln^3 (t)\right] \mathrm{e}^{-y} \, \mathrm{d} y ~\Bigg\vert\_{t=1}\\
&= \left[\frac{\mathrm{d}^2}{\mathrm{d} t^2} + 3 \frac{\mathrm{d}}{\mathrm{d}t}+1 \right] \frac{1}{t} \left[\Gamma'''(1) - 3 \Gamma''(1) \ln(t) + 3 \Gamma'(1) \ln^2(t) - \ln^3 (t)\right] ~\Bigg\vert\_{t=1} \\
&= 2 \Gamma'''(1) + 6 \Gamma''(1) + 3 \Gamma''(1) + 6 \Gamma'(1) - 3 \Gamma'''(1) - 9 \Gamma''(1) + \Gamma'''(1) \\
&= 6 \Gamma'(1)\\
&= - 6 \gamma \, .
\end{align}
In fact, integration by parts yields the following generalisation:
\begin{align}
\gamma &= \int \limits\_0^\infty (-\ln (x)) \mathrm{e}^{-x} \, \mathrm{d} x
= \int \limits\_0^\infty \frac{-\ln (x)}{x} x \mathrm{e}^{-x} \, \mathrm{d} x \\
&= \int \limits\_0^\infty (-\ln (x))^2 \frac{1-x}{2} \mathrm{e}^{-x} \, \mathrm{d} x \\
&= \int \limits\_0^\infty (-\ln (x))^3 \frac{x^2 - 3x +1}{6} \mathrm{e}^{-x} \, \mathrm{d} x \\
&= \dots \, \\
&= \int \limits\_0^\infty (-\ln (x))^{n+1} \frac{p\_n (x)}{(n+1)!} \mathrm{e}^{-x} \, \mathrm{d} x \, .
\end{align}
The polynomials $p\_n$ are defined recursively by $p\_0(x) = 1$ and
$$p\_n (x) = \mathrm{e}^{x} \frac{\mathrm{d}}{\mathrm{d}x} \left(x p\_{n-1} (x) \mathrm{e}^{-x}\right) \, , \, n \in \mathbb{N} \, ,$$
for $x \in \mathbb{R}$ . The exponential generating function
$$ \sum \limits\_{n=0}^\infty \frac{p\_n(x)}{n!} t^n = \mathrm{e}^{t+x(1-\mathrm{e}^t)}$$
can actually be computed from a PDE and it turns out that the polynomials are given by
$$p\_n(x) = \frac{B\_{n+1}(-x)}{-x} \, , \, x \in \mathbb{R} \, , \, n \in \mathbb{N}\_0 \, , $$
where $(B\_k)\_{k \in \mathbb{N}\_0}$ are the [Bell](http://mathworld.wolfram.com/BellPolynomial.html) or [Touchard](https://en.wikipedia.org/wiki/Touchard_polynomials) polynomials.
|
16,124,667 |
Hi i am working in java and want to know how String objects are created in the String pool
and how they are managed.
So in the following example i am creating two Strings s and s1,so can anyone explain me how many Objects are created in LIne1?Also how many Objects are eligible for garbage collection in Line3?
```
String s = "x" + "y";//Line 1
String s1 = s;//Line 2
s = null;//Line 3
```
|
2013/04/20
|
[
"https://Stackoverflow.com/questions/16124667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2303011/"
] |
Only one object is created `"xy"` . compiler does it for optimization.
No object is eligible for garbage collection.
|
19,423,030 |
I am using c# MVC 4 and have embedded a Report Viewer aspx page to render reports from SSRS. I am using Sql Server 2008R2, Microsoft.ReportViewer.WebForms version 11.0.
Firstly the issue I am facing,
I am using session variables within the project to hold values relative to the site. These have nothing to do with SSRS, for example UserId.
In the web.config I have
Note: The timeout is set ridiculously high for this testing scenario.
Simarlarly I have updated ConfigurationInfo in the ReportServer database for the key SessionTimeout to 60 (again ridiculous value to test with).
My ReportViewer code is as follows to open the :
```
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ReportViewer1.Reset();
string Reportpath = Request["ReportName"];
string ServerUserName = ConfigurationManager.AppSettings["ReportServerUser"];
string ServerPassword = ConfigurationManager.AppSettings["ReportServerPwd"];
string ReportServerDomain = ConfigurationManager.AppSettings["ReportServerDomain"];
string ReportsPath = ConfigurationManager.AppSettings["ReportsPath"];
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
// Get report path from configuration file
ReportViewer1.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServer"]);
ReportViewer1.ServerReport.ReportPath = String.Format(ReportsPath + "/" + Reportpath);
IReportServerCredentials irsc = new CustomReportCredentials(ServerUserName, ServerPassword, ReportServerDomain);
ReportViewer1.ServerReport.ReportServerCredentials = irsc;
ReportViewer1.ShowPrintButton = false;
#region Parameters for report
Microsoft.Reporting.WebForms.ReportParameter[] reportParameterCollection = new Microsoft.Reporting.WebForms.ReportParameter[1];
reportParameterCollection[0] = new Microsoft.Reporting.WebForms.ReportParameter();
reportParameterCollection[0].Name = "Example";
reportParameterCollection[0].Values.Add("Example");
ReportViewer1.ServerReport.SetParameters(reportParameterCollection);
#endregion Parameters for report
ReportViewer1.ServerReport.Refresh();
}
}
```
The issue I am facing
When I login, I have values set in the session.
When I open a report, the report executes fine in under a second and displays on the page.
Behind the scenes, I've noticed a row gets inserted in the Report Server Temp DB with an expiration date of 1 minute later (with my config).
A session key gets added to my
```
HttpContext.Current.Session.Keys
```
At this point all is fine and I even close the report page.
At this point I wait a minute which would mean that the session expires in the ReportServerTempDB.
I then navigate to a page whose action uses HttpContext.Current.Session for a value. Again, this action has nothing to do with reports. However when it tries to retrieve the key I get the following error
```
Microsoft.Reporting.WebForms.ReportServerException: The report execution <key> has expired or cannot be found. (rsExecutionNotFound)
```
I have been Googling this and have not found a working solution for my problem as most people seem to have had this with long running reports where the report session timed out before the execution was complete.
Any ideas?
Please comment if any more info is needed and I'll update the question.
Thanks in advance
|
2013/10/17
|
[
"https://Stackoverflow.com/questions/19423030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/128756/"
] |
I ran into the same issue. It appears that when the objects that the ReportViewer puts in Session are accessed, they try to ping the report server. If the report has expired, a ReportServerException gets thrown, which is expected behavior when a user is still viewing an expired report, but not when they're no longer on that page.
Unfortunately, these Session entries don't get cleaned up after the user leaves the page containing the ReportViewer. And for some reason, accessing the list of keys in the Session will trigger the report server to be pinged, thus raising this exception on completely unrelated pages.
While we can't get the list of keys, one thing we do have access to is the number of entries in Session. Using this information, we can walk through each item in Session and determine if it's one of those associated with the ReportViewer, and remove it.
```
[WebMethod]
public static void RemoveReportFromSession()
{
var i = HttpContext.Current.Session.Count - 1;
while (i >= 0)
{
try
{
var obj = HttpContext.Current.Session[i];
if (obj != null && obj.GetType().ToString() == "Microsoft.Reporting.WebForms.ReportHierarchy")
HttpContext.Current.Session.RemoveAt(i);
}
catch (Exception)
{
HttpContext.Current.Session.RemoveAt(i);
}
i--;
}
}
```
The catch block helps to remove reports that have already expired (and thus throw an exception when accessed), while the type check in the if-statement will remove reports that have not yet expired.
I recommend calling this from the onunload event of the page that contains your ReportViewer.
|
29,830,501 |
I'm quite a newbie with SQL. I'm currently working on an **Oracle database** and I've created a report that pulls up data depending on the date range parameter.
**The code is as follows:**
```
SELECT
DISTINCT C.CUSTOMER_CODE
, MS.SALESMAN_NAME
, SUM(C.REVENUE_AMT) Rev_Amt
FROM
C_REVENUE_ANALYSIS C
, M_CUSTOMER_H MC
, M_SALESMAN MS
WHERE C.COMPANY_CODE = 'W1'
AND C.CUSTOMER_CODE = MC.CUSTOMER_CODE
AND MC.SALESMAN_CODE = MS.SALESMAN_CODE
AND trunc(C.REVENUE_DATE) between to_date(<STARTDATE>,'YYYYMMDD') and to_date(<ENDDATE>,'YYYYMMDD')
AND MS.COMPANY_CODE = '00'
GROUP BY C.CUSTOMER_CODE, MS.SALESMAN_NAME
ORDER BY C.CUSTOMER_CODE, MS.SALESMAN_NAME
```
**The resulting report for a date range from Jan 1st to April 30th is:**
```
+-----------+--------------+--------------+
|Customer |Salesman Name |Revenue Amount|
+-----------+--------------+--------------+
|Customer 1 |Salesman 1 | 5000.00|
+-----------+--------------+--------------+
|Customer 2 |Salesman 1 | 8000.00|
+-----------+--------------+--------------+
|Customer 3 |Salesman 2 | 300.00|
+-----------+--------------+--------------+
|Customer 4 |Salesman 3 | 600.00|
+-----------+--------------+--------------+
|Customer 5 |Salesman 3 | 5000.00|
+-----------+--------------+--------------+
|Customer 6 |Salesman 3 | 8000.00|
+-----------+--------------+--------------+
|Customer 7 |Salesman 4 | 9000.00|
+-----------+--------------+--------------+
|Customer 8 |Salesman 5 | 2000.00|
+-----------+--------------+--------------+
|Customer 9 |Salesman 6 | 1000.00|
+-----------+--------------+--------------+
|Customer10 |Salesman 6 | 5000.00|
+-----------+--------------+--------------+
|Customer11 |Salesman 7 | 6000.00|
+-----------+--------------+--------------+
|Customer12 |Salesman 8 | 8000.00|
+-----------+--------------+--------------+
```
Now here is where I need your help, please. I need to show a break up of revenues for each Salesman for each month between Jan to April.
**So I would like the result to look like this:**
```
+-----------+--------------+-----------+-----------+-----------+-----------+-------------+
|Customer |Salesman Name |Rev for Jan|Rev for Feb|Rev for Mar|Rev for Apr|Total Rev Amt|
+-----------+--------------+-----------+-----------+-----------+-----------+-------------+
|Customer 1 |Salesman 1 | 1000.00| 1000.00| 1000.00| 2000.00| 5000.00|
+-----------+--------------+-----------+-----------+-----------+-----------+-------------+
|Customer 2 |Salesman 1 | 2000.00| 2000.00| 2000.00| 2000.00| 8000.00|
+-----------+--------------+-----------+-----------+-----------+-----------+-------------+
|Customer 3 |Salesman 2 | 100.00| 0.00| 100.00| 100.00| 300.00|
+-----------+--------------+-----------+-----------+-----------+-----------+-------------+
|Customer 4 |Salesman 3 | 100.00| 200.00| 100.00| 200.00| 600.00|
+-----------+--------------+-----------+-----------+-----------+-----------+-------------+
|Customer 5 |Salesman 3 | 1000.00| 2000.00| 1000.00| 1000.00| 5000.00|
+-----------+--------------+-----------+-----------+-----------+-----------+-------------+
|Customer 6 |Salesman 3 | 1000.00| 2000.00| 1000.00| 4000.00| 8000.00|
+-----------+--------------+-----------+-----------+-----------+-----------+-------------+
|Customer 7 |Salesman 4 | 2000.00| 2000.00| 3000.00| 2000.00| 9000.00|
+-----------+--------------+-----------+-----------+-----------+-----------+-------------+
|Customer 8 |Salesman 5 | 500.00| 400.00| 500.00| 600.00| 2000.00|
+-----------+--------------+-----------+-----------+-----------+-----------+-------------+
|Customer 9 |Salesman 6 | 200.00| 200.00| 200.00| 400.00| 1000.00|
+-----------+--------------+-----------+-----------+-----------+-----------+-------------+
|Customer10 |Salesman 6 | 1000.00| 1000.00| 2000.00| 1000.00| 5000.00|
+-----------+--------------+-----------+-----------+-----------+-----------+-------------+
|Customer11 |Salesman 7 | 2000.00| 2000.00| 1000.00| 1000.00| 6000.00|
+-----------+--------------+-----------+-----------+-----------+-----------+-------------+
|Customer12 |Salesman 8 | 2000.00| 2000.00| 2000.00| 2000.00| 8000.00|
+-----------+--------------+-----------+-----------+-----------+-----------+-------------+
```
Unfortunately, since I am a newbie, I don't have rights to create a Stored Procedure to regularly call this data. So I may have to write redundant code.
**But the question really is, what would the code be to be able to break down revenues per each month per salesman?**
Also, the number of columns varies depending on the Date Range. Eg; when Jan to April is selected, I get 4 columns for revenue plus 1 column for Total revenue. When Previous year's October to this year April is selected, I get 7 columns for revenue plus 1 column for Total revenue.
PLEASE can someone help a newbie eager to learn and prove himself? I would greatly appreciate your help. Thanks a lot in advance.
EDIT :
------
After a little persuasion, my manager has agreed to submit my stored procedure for approval and if approved, it will be created.
If I do get to create a stored procedure, what will be the code to get the desired result?
Thanks in advance.
|
2015/04/23
|
[
"https://Stackoverflow.com/questions/29830501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4403824/"
] |
Change `id` to `name` - after that you can access value of input field
```js
function myFunction(form, event) {
event.preventDefault();
alert(form.num_cluster.value);
}
```
```html
<form onsubmit="return myFunction(this, event)">
Num. Cluster: <input name="num_cluster" type="text">
<input type="submit">
</form>
```
As problem is little more interesting - we can extend our method **onsubmit**
```js
function s(form, event) {
event.preventDefault();
var values = Array.prototype.slice.call(form.elements) // as form elements are not an array
.filter(function(element) {
return element.type !== 'submit'; // I don't need submit button
})
.map(function(element) {
return (element.name + ': ' + element.value); // get name and value for rest form inputs and assign them to values variable
});
alert('values => ' + values.join(', ')) // finish
}
```
```html
<form onsubmit="return s(this, event)">
<p>Foo:
<input type="text" name='foo' />
</p>
<p>Bar:
<input type="text" name='bar' />
</p>
<p>Baz:
<select name='baz'>
<option value="lorem">lorem</option>
<option value="ipsum">ipsum</option>
</select>
</p>
<p>
<input type="submit" />
</p>
</form>
```
|
37,014,685 |
So I am trying to make a valid login for my web dev class' final project. Whenever I try to log in with the correct credentials, I always get redirected to the "something.php" page, and I never receive any of the output that I put in my code. This even happens when I input valid login credentials.I know this isn't a secure way to do a login, but this is for final project purposes only. I've attached all of my files below (minus pictures), even though you probably don't need all of them.
The something.php file (the php for the login)
```
<?php
$action = empty($_POST['action']) ? false : $_POST['action'];
/*var radio = document.getElementById('radio');*/
switch ($action) {
case 'login':
$username = empty($_POST['username']) ? '' : $_POST['username'];
$password = empty($_POST['password']) ? '' : $_POST['password'];
if ($username=='test' && $password=='pass') {
setcookie('userid', $username);
$response = 'Login: Sucess';
}
else {
$response = 'Login: Fail';
}
print $response;
break;
case 'get':
$userid = empty($_COOKIE['userid']) ? '' : $_COOKIE['userid'];
if ($userid=='test') {
$response = 'Todays special are organic Brazilian strawberries $1.75 a pound';
}
if ($username!='test' || $password!='pass'){
header('Location: XXX/something.php');
echo "username and password combo are not valid";
//radio.value = "logged out";
}
print $response;
break;
case 'logout':
setcookie('userid', '', 1);
print 'Logged out';
break;
}
?>
```
login.html page
```
<div class="group">
<div id="radio">
<form id="radio" action="">
<input type="radio" name="select" value="login"> Logged In<br>
<input type="radio" name="select" value="logout" checked> Logged Out<br>
</form>
</div>
<form id="content2" class="itemBlock">
<p> Don't have an account? Sign up here!</p>
First name:<br>
<input type="text" name="firstname"><br>
Last name:<br>
<input type="text" name="lastname"><br>
E-mail: <br>
<input type="text" name="email"><br>
Password: <br>
<input type="text" name="password"><br>
<br>
<input type="button" value="Register" onclick="addToCartFxn()">
</form>
<div id="center">
<form id="content" class="itemBlock" action="something.php" method="post">
<br> <br>
E-mail: <br>
<input type="text" name="email"><br>
Password: <br>
<input type="password" name="password"><br>
<input type="submit" class="get" value="Login" id="login">
<input type="submit" value="Logout" id="logout">
</form>
</div>
</div>
```
final.php page
```
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Tabs - Content via Ajax</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<!--<link rel="stylesheet" href="/resources/demos/style.css">-->
<!--<script src="jquery-1.10.2.min.js"></script>-->
<script>
$(function() {
$( "#tabs" ).tabs({
beforeLoad: function( event, ui ) {
ui.jqXHR.fail(function() {
ui.panel.html(
"Couldn't load this tab. We'll try to fix this as soon as possible. ");
});
}
});
});
$(function(){
$('#login').click(function(){
$.post('something.php',
{
action: 'login',
username: $('#username').val(),
password: $('#password').val()
},
function(data){
$('#center').html(data);
});
});
$('#logout').click(function(){
$.post('something.php',
{
action: 'logout'
},
function(data){
$('#center').html(data);
});
});
$('.get').click(function(){
$.post('something.php',
{
action: 'get'
},
function(data){
$('#center').html(data);
});
});
});
function addToCartFxn() {
alert("This feature is coming soon!");
}
</script>
<style>
#floatright {
float:right;
}
#header{
background-image: url("tree rocks header.jpg");
width: 100%;
height: 200px;
padding-top: 1px;
text-align: center;
background-size: cover;
background-position-y: 3255px;
background-position-x: -2112px;
}
#headertext {
z-index: 100;
color: white;
font-size: 72px;
font-family: exo, arial, serif;
}
@font-face {
/* Declare the name of the font (we make this value up) */
font-family: exo;
/* And where it's located */
src: url("Exo-Medium.otf");
}
.addtocart{
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 7px 12px;
border-radius: 7px;
text-align: center;
text-decoration: none;
font-size: 5px;
margin-bottom: 3px;
}
#radio {
float: right;
}
#content {
font-family: exo, arial, serif;
text-align: center;
border-radius: 25px;
background-color:forestgreen;
align-content: center;
}
#content2 {
font-family: exo, arial, serif;
float:left;
}
#logout{
margin: 5px;
}
#login{
margin: 5px;
}
.itemBlock{
display:inline-block;
margin: 10px;
border: 2px black;
border-style: solid;
text-align: left;
padding-left: 5px;
padding-right: 5px;
}
@font-face {
/* Declare the name of the font (we make this value up) */
font-family: exo;
/* And where it's located */
src: url("Exo-Medium.otf");
}
#center{
margin-left: 42%;
}
body {
min-height: 100%;
height: auto! important;
}
.group:after {
content: "";
display: table;
clear: both;
}
</style>
</head>
<body>
<div id="header">
<p id="headertext"> Claw's Cache</p>
</div>
<div id="tabs">
<ul>
<li><a href="#tabs-1"> Our Products </a></li>
<li><a href="#tabs-2"> Available Produce </a></li>
<li id="floatright"> <a href="login.html"> Login</a></li><!--tabs-3's content is being put there by ajax-->
</ul>
<div id="tabs-1">
<p>Listed here are all the current vendors that are associated with us products.</p>
<?php
//Use glob function to get the files
//Note that we have used " * " inside this function. If you want to get only JPEG or PNG use
//below line and commnent $images variable currently in use
$images = glob("*.png");
$i=0;
//Display image using foreach loop
foreach($images as $image){
echo '<div class="itemBlock"> <a href="'.$image.'" target="_blank"><img src="'.$image.'" height="250" width="200" /></a> <br>';
echo '<button type="button" class="addtocart" onclick="addToCartFxn()"> add to cart</button> </div>';
}
?>
</div>
<div id="tabs-2">
<p>Our available produce page is being updated currently!
<br> <br> As a placeholder, we have attached a video that many of our customers recommend to every person interested in indoor gardening.</p><br>
<iframe width="560" height="315" src="https://www.youtube.com/embed/RWCIaydwM_w" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</body>
</html>
```
|
2016/05/03
|
[
"https://Stackoverflow.com/questions/37014685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5948316/"
] |
As other have suggested you should create the `Point` class:
```
public partial class Point
{
public int X { get; set; }
public int Y { get; set; }
public Point(int x, int y)
{
this.X = x;
this.Y = y;
}
}
```
And, let's encapsulate the *functions* for computing distance and total cost :
```
public partial class Point
{
public static int CalculateDistance(Point p0, Point p1)
{
return Math.Max(
Math.Abs(p0.X - p1.X),
Math.Abs(p0.Y - p1.Y)
);
}
}
public static class PointExtensions
{
public static int GetTotalCost(this IEnumerable<Point> source)
{
return source
.Zip(source.Skip(1), Point.CalculateDistance)
.Sum();
}
}
```
Finally, you will need another extension method to create "all possible combination" :
```
public static class PermutationExtensions
{
public static IEnumerable<IEnumerable<T>> GetPermutations<T>(this IEnumerable<T> source)
{
if (source == null || !source.Any())
throw new ArgumentNullException("source");
var array = source.ToArray();
return Permute(array, 0, array.Length - 1);
}
private static IEnumerable<IEnumerable<T>> Permute<T>(T[] array, int i, int n)
{
if (i == n)
yield return array.ToArray();
else
{
for (int j = i; j <= n; j++)
{
array.Swap(i, j);
foreach (var permutation in Permute(array, i + 1, n))
yield return permutation.ToArray();
array.Swap(i, j); //backtrack
}
}
}
private static void Swap<T>(this T[] array, int i, int j)
{
T temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
```
*Source from [Listing all permutations of a string/integer](https://stackoverflow.com/questions/756055/listing-all-permutations-of-a-string-integer) adapted to be more LINQ-friendly*
---
Usage :
```
void Main()
{
var list = new List<Point>
{
new Point(1, 2),
new Point(1, 1),
new Point(1, 3),
};
// result: Point[] (3 items) : (1, 1), (1, 2), (1,3)
list.GetPermutations()
.OrderBy(x => x.GetTotalCost())
.First();
}
```
---
**EDIT** : As @EricLippert pointed out, `source.OrderBy(selector).First()` has some extra cost. This following extension method deals with this issue :
```
public static class EnumerableExtensions
{
public static T MinBy<T, TKey>(this IEnumerable<T> source, Func<T, TKey> keySelector, IComparer<TKey> comparer = null)
{
IEnumerator<T> etor = null;
if (source == null || !(etor = source.GetEnumerator()).MoveNext())
throw new ArgumentNullException("source");
if (keySelector == null)
throw new ArgumentNullException("keySelector");
var min = etor.Current;
var minKey = keySelector(min);
comparer = comparer ?? Comparer<TKey>.Default;
while (etor.MoveNext())
{
var key = keySelector(etor.Current);
if (comparer.Compare(key, minKey) < 0)
{
min = etor.Current;
minKey = key;
}
}
return min;
}
}
```
And, we can rewrite the above solution as :
```
list.GetPermutations().MinBy(x => x.GetTotalCost())
```
|
5,605,181 |
Is it possible to disable the execution of the logger during testing?
I have this class
```
public class UnitTestMe {
private final MockMe mockMe;
private final SomethingElse something;
private final Logger logger = LoggerFactory.getLogger(this.getClass().getClass());
public UnitTestMe(MockMe mockMe, SomethingElse something) {
this..
}
public toTest() {
logger.info("Executing toTest. MockMe a: {}, Foo: b: {}", mockMe.toString(), something.foo().bar());
mockMe.execute();
}
}
```
My Unit Test is failing with an NullPointerException because something.foo() is not a mocked object (i am using mockito with nicemock).
How can I test this class without removing the logger statement and without mocking irrelevant parts of the dependencies like `something`?
**Edit:** something is in this case a Customer Object, that is not used in the `toTest()` function but needed in other parts of this Class. I am using the Customer class in the logger statement to relate an action to an user.
**Edit 2:** Would it help to mock the logger object? I would assume that I will get an `NullPointerException` again, because the methods of the `something´ object are executed, too.
|
2011/04/09
|
[
"https://Stackoverflow.com/questions/5605181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
**Poor answer**: first decrease logging level to `WARN` or `ERROR` for this logger. Then, surround logging statement with `isInfoEnabled()`:
```
if(logger.isInfoEnabled())
logger.info("Executing toTest. MockMe a: {}, Foo: b: {}", mockMe.toString(), something.foo().bar());
```
---
**Better one**: it looks a bit weird that you are using some object only for logging, so when you are testing a `toTest()` method, mocked dependency is used only for logging. I understand this is just an example, but looks like there is some design flaw. I would suggest mocking `SomethingElse` for the sake of simplicity as well.
|
36,344,180 |
I am working on filtering out a massive dataset that reads in as a list. I need to filter out special markings and am getting stuck on some of them. Here is what I currently have:
```
library(R.utils)
library(stringr)
gunzip("movies.list.gz") #open file
movies <- readLines("movies.list") #read lines in
movies <- gsub("[\t]", '', movies) #remove tabs (\t)
#movies <- gsub(, '', movies)
a <- movies[!grepl("\\{", movies)] # removed any line that contained special character {
b <- a[!grepl("\\(V)", a)] #remove porn?
c <- b[!grepl("\\(TV)", b)] #remove tv
d <- c[!grepl("\\(VG)", c)] #remove video games
e <- d[!grepl("\\(\\?\\?\\?\\?\\)", d)] #remove anyhting with unknown date ex (????)
f <- e[!grepl("\\#)", e)]
g <- e[!grepl("\\!)", f)]
i <- data.frame(g)
i <- i[-c(1:15),]
i <- data.frame(i)
i$Date <- lapply(strsplit(as.character(i$i), "\\(....\\)"), "[", 2)
i$Title <- lapply(strsplit(as.character(i$i), "\\(....\\)"), "[", 1)
```
I still need to clean it up a bit, and remove the original column (i) but from the output you can see that it is not removing the special characters ! or #
```
> head(i)
i Date Title
1 "!Next?" (1994)1994-1995 1994-1995 "!Next?"
2 "#1 Single" (2006)2006-???? 2006-???? "#1 Single"
3 "#1MinuteNightmare" (2014)2014-???? 2014-???? "#1MinuteNightmare"
4 "#30Nods" (2014)2014-2015 2014-2015 "#30Nods"
5 "#7DaysLater" (2013)2013-???? 2013-???? "#7DaysLater"
6 "#ATown" (2014)2014-???? 2014-???? "#ATown"
```
What I actually want to do is remove the entire rows containing those special characters. Everything I have tried has thrown errors. Any suggestions?
|
2016/03/31
|
[
"https://Stackoverflow.com/questions/36344180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5970435/"
] |
out.print("\"");
This solution ended up being the one that worked. My editor kept telling me that it wasn't valid code, but it ran just fine.
|
26,323,137 |
I am trying to plot a spline graph with the following data:
```
[
{
"name": "Version 1.0",
"data": [
"10/9/2014, 11:47:03 AM",
170.023
]
},
{
"name": "Version 1.1",
"data": [
"10/8/2014, 1:00:00 AM",
1967.02,
[
"10/9/2014, 11:00:19 AM",
167.023
],
[
"10/9/2014, 9:34:49 PM",
1974.03
],
[
"10/9/2014, 9:45:33 PM",
1983.02
],
[
"10/9/2014, 10:36:10 PM",
1989.03
],
[
"10/10/2014, 3:05:37 AM",
1972.02
],
[
"10/10/2014, 5:01:43 AM",
1980.02
],
[
"10/10/2014, 8:37:18 AM",
16.0215
],
[
"10/10/2014, 2:37:44 PM",
1994.02
]
]
}
]
```
Here is a JSFiddle of it: <http://jsfiddle.net/rknLa2sa/3/>
The points are correctly plotted but they are not connected with a line. How do I make these points be connected on the graph?
Also how do I make the dates I have in the data array show up on the x-axis as well as the tool-tip.
|
2014/10/12
|
[
"https://Stackoverflow.com/questions/26323137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/317512/"
] |
You have forgotten some brackets in your data around
```
"10/8/2014, 1:00:00 AM",
1967.02,
```
<http://jsfiddle.net/rknLa2sa/4/>
In order to show label you could preprocess your data and convert the dates to UTC format
like this
```
[
Date.UTC(2014, 8, 10, 10),
167.023
],
```
<http://jsfiddle.net/rknLa2sa/7/>
|
254,551 |
If using Python on a Linux machine, which of the following would be faster? Why?
1. Creating a file at the very beginning of the program, writing very large amounts of data (text), closing it, then splitting the large file up into many smaller files at the very end of the program.
2. Throughout the program's span, many smaller files will be created, written to and closed.
Specifically, the program in question is one which needs to record the state of a very large array at each of many time-steps. The state of the array at each time-step needs to be recorded in independent files.
I've worked with C on Linux and know that opening/creating and closing files is quite time-expensive, and fewer open/create operations means faster programs. Is the same true if writing in Python? Would changing the language even matter if still using the same OS?
I'm also interested in RAM's role in this context. For example -- correct me if I'm wrong -- I'm assuming that parts of a file being written to will be placed in RAM. If the file gets too big, will it bloat RAM and cause problems in speed or other areas? If an answer could incorporate RAM that would be great.
|
2014/08/27
|
[
"https://softwareengineering.stackexchange.com/questions/254551",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/143527/"
] |
To answer your question, you really should benchmark (i.e. measure the execution time of several variants of your program). I guess it might depend on how many small files you need (10 thousand files is not the same as 10 billion files), and what file system you are using. You could use `tmpfs` file systems. It also obviously depends on the hardware (SSD disks are faster).
I would also suggest to avoid putting a big lot of files in the same directory. So prefer `dir01/file001.txt` ... `dir01/file999.txt` `dir02/file001.txt` ... to `file00001.txt` ... `file99999.txt` ie have directories with e.g. at most a thousand files.
I would also advise to avoid having a big lot of tiny files (e.g. files with less than a hundred bytes of data each): they make a lot of filesystems unhappy (since a file needs at least its [inode](http://en.wikipedia.org/wiki/Inode)).
However, you should perhaps consider other alternatives, like using a database (which might be as simple as [Sqlite](http://sqlite.org) ...) or using some indexed file (like [`gdbm`](http://www.gnu.org.ua/software/gdbm/) ...)
Regarding RAM, the kernel tries quite hard to keep file data in RAM. See e.g. [linuxatemyram.com](http://www.linuxatemyram.com/); read about [posix\_fadvise(2)](http://man7.org/linux/man-pages/man2/posix_fadvise.2.html), [fsync(2)](http://man7.org/linux/man-pages/man2/fsync.2.html), [readahead(2)](http://man7.org/linux/man-pages/man2/readahead.2.html), ...
BTW, Python code will ultimately call C code and use the same (kernel provided) [syscalls(2)](http://man7.org/linux/man-pages/man2/syscalls.2.html). Most file system related processing happens *inside* the [Linux kernel](http://en.wikipedia.org/wiki/Linux_kernel). So it won't be faster (unless Python adds it own user-space buffering to e.g. [read(2)](http://man7.org/linux/man-pages/man2/read.2.html) data in megabyte chunks, hence lowering the number of executed syscalls).
Notice that every Linux system is able to deal with a lot of disk data, either with a single huge file (much bigger than available RAM: you could have a 50Gbyte file on your laptop, and a terabyte file on your desktop!) or in many files.
|
24,893,236 |
[Material design](http://www.google.com/design/spec/material-design/introduction.html#introduction-principles) makes a huge emphasis on the metaphor of "sheets of paper". To make these, shadows are essential. Since Material design is a philosophy and **not an API** (despite it being built into L), this should be done anywhere (Windows Forms, HTML/CSS, etc.). **How do I do this in Android API 14 to 20?**
Note that premade PNGs won't really be that practical for circular and other non-square shapes.
|
2014/07/22
|
[
"https://Stackoverflow.com/questions/24893236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/453435/"
] |
If you're not worried about backwards compatibility past Lollipop, you can set the elevation Attribute directly in the XML
```
android:elevation="10dp"
```
Otherwise you have to set it in Java using the support.v4.ViewCompat library.
```
ViewCompat.setElevation(myView, 10);
```
and add this to your build.gradle
```
compile 'com.android.support:support-v4:21.+'
```
<http://developer.android.com/reference/android/support/v4/view/ViewCompat.html#setElevation(android.view.View,%20float)>
|
98,945 |
I have got a shortcode that displays a custom post type, via a `foreach`. The shortcode has been used in the standard post type. I have used `the_title();` in the shortcode. `the_title();` outputs the post\_title of the standard post type (which the shortcode is in), rather than `the_title();` of the custom post type. My code:
```
function faq_register_shortcode() {
add_shortcode( 'display_faqs', 'mp_faq_shortcode' );
}
function mp_faq_shortcode() {
$args = array( 'post_type' => 'faq_type_mp', 'numberposts' => 3, 'post_status' => 'any', 'post_parent' => null );
$attachments = get_posts( $args );
if ($attachments) {
foreach ( $attachments as $post ) {
the_title();
the_content();
}
}
}
```
So for example, if the standard post type (which the shortcode is in), had a `post_title` of 'this is the standard post type', this is what is outputted in the shortcode. I want to display the `post_title` which belongs to the custom post type, NOT the standard post (which the shortcode is in).
What have I done wrong please?
|
2013/05/09
|
[
"https://wordpress.stackexchange.com/questions/98945",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] |
You need to add `setup_postdata($post);` inside your loop:
```
foreach ( $attachments as $post ) {
setup_postdata($post);
the_title();
the_content();
}
```
|
263,238 |
I have a prediction model tested with four methods as you can see in the boxplot figure below. The attribute that the model predicts is in range of 0-8.
You may notice that there is **one upper-bound outlier** and **three lower-bound outliers** indicated by all methods. I wonder if it is appropriate to remove these instances from the data? Or is this a sort of cheating to improve the prediction model?
[](https://i.stack.imgur.com/dFVsJ.png)
|
2017/02/21
|
[
"https://stats.stackexchange.com/questions/263238",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/91142/"
] |
It is **almost always** a cheating to remove observations **to improve** a regression model. You should drop observations only when you truly think that these are in fact outliers.
For instance, you have time series from the heart rate monitor connected to your smart watch. If you take a look at the series, it's easy to see that there would be erroneous observations with readings like 300bps. These should be removed, but not because you want to improve the model (whatever it means). They're errors in reading which have nothing to do with your heart rate.
One thing to be careful though is the correlation of errors with the data. In my example it could be argued that you have errors when the heart rate monitor is displaced during exercises such as running o jumping. Which will make these errors correlated with the hart rate. In this case, care must be taken in removal of these outliers and errors, because they are not [at random](http://missingdata.lshtm.ac.uk/index.php?option=com_content&view=article&id=76:missing-at-random-mar&catid=40:missingness-mechanisms&Itemid=96)
I'll give you a made up example of when to not remove **outliers**. Let's say you're measuring the movement of a weight on a spring. If the weight is *small relative to the strength* of the weight, then you'll notice that [Hooke's law](https://en.wikipedia.org/wiki/Hooke's_law) works very well: $$F=-k\Delta x,$$ where $F$ is force, $k$ - tension coefficient and $\Delta x$ is the position of the weight.
Now if you put a very heavy weight or displace the weight too much, you'll start seeing deviations: at large enough displacements $\Delta x$ the motion will seem to deviate from the linear model. So, you might be tempted to remove the *outliers* to improve the linear model. This would not be a good idea, because the model is not working very well since Hooke's law is only approximately right.
UPDATE
In your case I would suggest pulling those data points and looking at them closer. Could it be lab instrument failure? External interference? Sample defect? etc.
Next try to identify whether the presnece of these outliers could be correlated with what you measure like in the example I gave. If there's correlation then there's no simple way to go about it. If there's no correlation then you can remove the outliers
|
56,943,623 |
Hi,
I have this html code:
```
<ul>
<li>
<a href="#">Locations</a>
<ul class="submenu1">
<li><a href="https://url.com">London</a></li>
<li><a href="https://url.com">York</a></li>
</ul>
</li>
<li>
<a href="#">About</a>
<ul class="submenu2">
<li><a href="https://url.com">Site</a></li>
<li><a href="https://url.com">Contact</a></li>
</ul>
</li>
</ul>
```
I want to select all the a elements EXCEPT the ones that are children to the `submenu` class elements.
I tried like this:
```
ul li a:not([class^="submenu"] a) {background-color:darkkhaki;}
```
but it wont work. Whats the right selector for this case?
Thank you.
|
2019/07/08
|
[
"https://Stackoverflow.com/questions/56943623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2230939/"
] |
Hello dear CSS friend!
In other words, taking your example, you want to select "Locations" and "About" links but not the others.
(Kind of) dirty one
-------------------
The easier to understand solution is to apply styles to all `a` then remove the styles to the others.
```
li > a {
/* Styles you want to apply */
}
[class^="submenu"] a {
/* Remove styles here */
}
```
It's always dirty to place styles then remove them, because it's less maintainable and a bit more heavy. But it will do the job.
Nicer solution
--------------
In your case, the submenu links are the only child of your `li` elements. That's why I would try to target the links that are not only child of your list item to style those, like that.
```
li a:not(:only-child) {
/* Your styles here */
}
```
For more information on :only-child pseudo class, I leave you with some reading :)
<https://developer.mozilla.org/fr/docs/Web/CSS/:only-child>
Don't hesitate if you have question, and have fun!
|
15,150,430 |
I am trying to use the TimePicker in the 24 hour format and I am using setIs24HourView= true, but I am still not getting 24 hour format on the TimePicker. Here is my code in the onCreate of the Activity.
```
timePicker = (TimePicker) findViewById(R.id.timePicker1);
timePicker.setIs24HourView(true);
```
I even tried timePicker.setCurrentHour(cal.HOUR\_OF\_DAY) after setIs24HourView, but I am not able to see the 24 hour format on the TimePicker.
```
<TimePicker
android:id="@+id/timePicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="110dp" />
```
Am I missing anything here?

|
2013/03/01
|
[
"https://Stackoverflow.com/questions/15150430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2103792/"
] |
ok, I see what the problem is now.
It's not correctly setting the currentHour to the new 24 hour format, which is why you got 9:05 instead of 21:05. I'm guessing it isn't 9am where you are!
It is a bug, as mentioned in this [question](https://stackoverflow.com/questions/13662288/timepicker-hour-doesnt-update-after-switching-to-24h)
seems the only work around, for now, is to do something like:
```
timePicker = (TimePicker) findViewById(R.id.timePicker1);
timePicker.setIs24HourView(true);
timePicker.setCurrentHour(Calendar.get(Calendar.HOUR_OF_DAY));
```
I see you tried cal.HOUR\_OF\_DAY, but didn't provide the code you actually used, but try this and see if it helps.
|
56,908,604 |
I'm on Fedora 30. I am trying to install "epel-release".
I am following this guide: <https://www.phusionpassenger.com/library/install/standalone/install/oss/el7/> -- I am unable to successfully run the command:
```
$ sudo yum install -y epel-release yum-utils
```
I get as a result:
```
No match for argument: epel-release
```
So, I tried the following commands from this article: <https://www.liquidweb.com/kb/enable-epel-repository/>
```
$ cd /tmp
$ wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
$ yum install ./epel-release-latest-*.noarch.rpm
```
No such luck - this is the output:
```
Error:
Problem: problem with installed package fedora-release-workstation-30-1.noarch
- package epel-release-7-11.noarch conflicts with fedora-release provided by fedora-release-workstation-30-1.noarch
- package epel-release-7-11.noarch conflicts with fedora-release provided by fedora-release-workstation-30-4.noarch
- conflicting requests
```
I have also tried:
```
$ sudo dnf install epel-relase
```
which that didn't work either, here's the results:
```
No match for argument: epel-release
Error: Unable to find a match
```
I have come across several different articles basically saying to either use the first command listed or variations of the second command I've tried - all unsuccessful. side note: Is this because Fedora 30 was just "recently" released?
My end goal is to deploy a Ruby on Rails web app internally using Nginx. For that, I am following this guide: <https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/nginx/oss/el7/deploy_app.html>
Any direction for how to install epel-release would be great as I can't move forward until passenger is installed.
|
2019/07/05
|
[
"https://Stackoverflow.com/questions/56908604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5479897/"
] |
Note that [EPEL](https://fedoraproject.org/wiki/EPEL) is not suitable for use in Fedora! Fedora is not Enterprise Linux. EPEL provides "a high quality set of additional packages **for Enterprise Linux**, including, but not limited to, Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL), Oracle Linux (OL)". Put simply, *Enterprise Linux* is a term that refers to *Red Hat Enterprise Linux* or one of its clones. And Fedora is not a Red Hat clone.
That is why you cannot install the "epel-release" package in Fedora. It simply does not exist. Don't try to use EPEL on Fedora.
As noted before, the Fedora repositories provide most (if not all) of the EPEL packages. Additional software for Fedora is available in the [RPMFusion](https://rpmfusion.org/) repositories. In their own words, RPMFusion is "an extension of Fedora" that "provides software that the Fedora Project or Red Hat doesn't want to ship." RPMFusion can not be used on Enterprise Linux. You could see RPMFusion as the "EPEL alternative" for Fedora, but be aware that the software collections provided by RPMFusion and EPEL are entirely unrelated and uncomparable.
EPEL is managed from within the Fedora project, and thus part of Red Hat. RPMFusion is an independent organization. You can consider their repositories reliable, but always be cautious when you install software from external sources.
Finally - on a sidenote - on recent Fedora versions, 'dnf' has [replaced](https://opensource.com/article/18/8/guide-yum-dnf) 'yum'.
|
2,168,510 |
The question is related to the question [Transition between matrices of full rank](https://math.stackexchange.com/questions/2166866/transition-between-matrices-of-full-rank)
Suppose we have in matrix space (I treat matrices here as vectors describing points in some $n \times n$ dimensional space) three real square matrices $A\_1,A\_2,A\_3$ that all are of full rank and any matrix $P$, lying on the segment $A\_1A\_2$ or $A\_2A\_3$ or $A\_3A\_1$ between these matrices, is also of full rank.
(what is equivalent to the fact that this matrix $P = t\_i{A\_i}+{t\_iA\_j}$ where $t\_i,t\_j$ are positive and $t\_i+t\_j=1$)
* Does it mean that any matrix $D$ in the interior of $\triangle ABC$ located in the two-dimensional plane determined by these matrices is
also of full rank?
* If not what condition should be stated additionally to satisfy non-singularity for all these internal matrices?
Matrix $D$ is treated as an internal point of $\triangle ABC$ if the equation $D= t\_1A+t\_2B+t\_3C$ is satisfied for some positive $t\_1$, $t\_2$, $t\_3$ constrained by the equation $t\_1+t\_2+t\_3=1$.
|
2017/03/02
|
[
"https://math.stackexchange.com/questions/2168510",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/334463/"
] |
Given a curve $\gamma$ of class $C^{1}$ in $\mathbb{R}^{2}$ parametrized by a
function $h:[a,b]\rightarrow\mathbb{R}^{2}$, the integral of a function $f$
along $\gamma$ is given by
$$
\int\_{\gamma}f\,d\sigma=\int\_{a}^{b}f(h(t))\sqrt{(h\_{1}^{\prime}%
(t))^{2}+(h\_{2}^{\prime}(t))^{2}}dt.
$$
In your case, you can take $h(\theta)=(R\cos\theta,R\sin\theta)$ and so
$h^{\prime}(\theta)=(-R\sin\theta,R\cos\theta)$ which gives
\begin{align\*}
\int\_{\partial B\_{R}}f\,d\sigma & =\int\_{0}^{2\pi}f(R\cos\theta,R\sin
\theta)\sqrt{(-R\sin\theta)^{2}+(R\cos\theta)^{2}}d\theta\\
& =\int\_{0}^{2\pi}f(R\cos\theta,R\sin\theta)R\,d\theta.
\end{align\*}
The outer normal $\nu$ to $\partial B\_{R}$ at $(x,y)$ is given by
$\frac{(x,y)}{\sqrt{x^{2}+y^{2}}}$, so in polar coordinate $\nu(\theta
)=(\cos\theta,\sin\theta)$ and so
\begin{align\*}
\frac{\partial u}{\partial\nu}(R\cos\theta,R\sin\theta) & =\nabla
u(R\cos\theta,R\sin\theta)\cdot\nu(\theta)\\
& =\partial\_{x}u(R\cos\theta,R\sin\theta)\cos\theta+\partial\_{y}u(R\cos
\theta,R\sin\theta)\sin\theta\\
& =\frac{\partial u}{\partial r}(R\cos\theta,R\sin\theta)=7R^{6}\left(
\frac{1}{98}+\frac{1}{90}\cos2\theta\right) .
\end{align\*}
It follows that
\begin{align\*}
\int\_{\partial B\_{R}}g\frac{\partial u}{\partial\nu}\,d\theta & =\int%
\_{0}^{2\pi}g(R\cos\theta,R\sin\theta)\frac{\partial u}{\partial r}(R\cos
\theta,R\sin\theta)R\,d\theta\\
& =\int\_{0}^{2\pi}g(R\cos\theta,R\sin\theta)7R^{6}\left( \frac{1}{98}%
+\frac{1}{90}\cos2\theta\right) R\,d\theta,
\end{align\*}
which is what you have in your notes.
|
38,766,636 |
i m trying to keep Hello as a heading below nav tag.
This is my HTML.
```
<nav class="navbar navbar-default navbar-fixed-top" style="background-color: aliceblue;" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<img class="img-responsive" src="img/logo.png" style="width: 330px; height: 49px;" />
</div>
<ul class="nav navbar-nav navbar-right" id="navbarprop">
<li id="home" class="active">
<a class="color" href="#"><i class="glyphicon glyphicon-home"></i>  Home</a>
</li>
</ul>
</div>
</nav>
<div class="container">
<h1>HELLO</h1>
</div>
```
I want to make my page responsive. The problem arise is the Hello is printed inside the nav tag. i have to apply margin-top:50px; to make "HELLO" visible. How do i make it responsive.
This is the image with no margin top
<http://imgur.com/q5yol6t>
Hello is inside the nav.
This is the image with margin top
<http://imgur.com/j8tjUbZ>
Thank You in advance!
|
2016/08/04
|
[
"https://Stackoverflow.com/questions/38766636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6677896/"
] |
<http://getbootstrap.com/components/#navbar-fixed-top>
Look particularly at the part where it says the body requires padding.
>
> The fixed navbar will overlay your other content, unless you add padding to the top of the `<body>`. Try out your own values or use our snippet below. Tip: By default, the navbar is 50px high.
>
>
>
```
body { padding-top: 70px; }
```
>
> Make sure to include this after the core Bootstrap CSS.
>
>
>
|
232,805 |
In *Asterix and the Magic Carpet*, [Cacofonix's](https://www.asterix.com/en/portfolio/cacofonix/) singing produces rain. (Previously, this had never happened.)
**Why is it that when Cacofonix sings, it rains in #28 (*Magic Carpet*, 1987), but not in Books #1-27 (1961-83)?** (Others may disagree, but I find this problematic, puzzling, and in need of explanation.)
(This effect also continues in the next book *Asterix and the Secret Weapon*.)
---
Four of the five current answers simply quote from Wikipedia's (unsourced) assertion that there is a French saying that when one sings poorly, it rains.
This could very well be an explanation. But absent either in-universe (i.e. within the comic books, perhaps cleared up in later books) or out-of-universe (e.g. interviews with Uderzo) evidence, this is just speculation. Moreover, it is unsatisfying because it fails to address my above question (in bold).
---
Edit: In case it isn't clear, I am not disputing the existence of such a French saying. I am disputing that the existence of such a French saying is a satisfactory explanation to my question. In particular, it fails to explain why Cacofonix's singing had not previously produced rain in the previous 27 books.
|
2020/06/15
|
[
"https://scifi.stackexchange.com/questions/232805",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/130048/"
] |
This is an ongoing joke that Cacofonix's singing is so bad, it causes negative things to happen (a common trope).
[](https://i.stack.imgur.com/6xBoN.jpg)
According to [Wikipedia](https://en.wikipedia.org/wiki/List_of_Asterix_characters#Cacofonix) (My emphasis):
>
> In Asterix and the Normans [his singing] is so unbearable that it teaches the fearless Normans the meaning of fear. In later albums his music is so spectacularly horrible that it actually starts thunderstorms (even indoors), **because of an old French saying that bad singing causes rain.**
>
>
>
The joke even leads to him causing it to rain inside:
[](https://i.stack.imgur.com/groSL.png)
And sometimes even leads to Cacofonix saving the day:
[](https://i.stack.imgur.com/wURO3.png)
|
191 |
I'm having a hard time figuring out which is the correct form of asking this kind of question. I mean speaking strictly, this doesn't sound right: ***You alright?*** or ***You eaten anything?*** compared to ***Are you alright?*** and ***Have you eaten anything?***.
So please enlighten me. Are those both forms correct or just something which is ignored for the sake slang speakers?
|
2013/01/24
|
[
"https://ell.stackexchange.com/questions/191",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/101/"
] |
Those phrases are examples of ellipsis: the omission of words that can be understood from the context, or given contextual clues.
While ellipsis is not normally used in formal English, it is more used in spoken English, or informal English.
|
30,343,029 |
I am new to Perl. How do I create a a loop that runs until the current time is a multiple of 5 seconds?
|
2015/05/20
|
[
"https://Stackoverflow.com/questions/30343029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
If you just want to suspend your process until the seconds are a multiple of 5, then you can use the [`Time::HiRes`](https://metacpan.org/pod/Time::HiRes) module like this
```
use Time::HiRes qw/ gettimeofday usleep /;
my ($s, $us) = gettimeofday;
my $delay = 1_000_000 * (5 - $s % 5) - $us;
usleep $delay;
# Do stuff
```
or if you want to execute some code until the next multiple of 5 seconds then use this
```
use Time::HiRes qw/ gettimeofday tv_interval /;
my $t1 = [ gettimeofday ];
$t1->[0] += 5 - $t1->[0] % 5;
$t1->[1] = 0;
while ( tv_interval([ gettimeofday ], $t1) > 0 ) {
# Do stuff
}
```
|
9,648,015 |
I put [a package on PyPi](http://pypi.python.org/pypi/powerlaw) for the first time ~2 months ago, and have made some version updates since then. I noticed this week the download count recording, and was surprised to see it had been downloaded hundreds of times. Over the next few days, I was more surprised to see the download count increasing by sometimes hundreds *per day*, even though this is a niche statistical test toolbox. In particular, older versions of package are continuing to be downloaded, sometimes at higher rates than the newest version.
What is going on here?
Is there a bug in PyPi's downloaded counting, or is there an abundance of crawlers grabbing open source code (as mine is)?
|
2012/03/10
|
[
"https://Stackoverflow.com/questions/9648015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/897578/"
] |
This is kind of an old question at this point, but I noticed the same thing about a package I have on PyPI and investigated further. It turns out PyPI keeps reasonably detailed [download statistics](http://pypi.python.org/stats/), including (apparently slightly anonymised) user agents. From that, it was apparent that most people downloading my package were things like "z3c.pypimirror/1.0.15.1" and "pep381client/1.5". (PEP 381 describes a mirroring infrastructure for PyPI.)
I wrote [a quick script](https://gist.github.com/Cairnarvon/4715057) to tally everything up, first including all of them and then leaving out the most obvious bots, and it turns out that **literally 99%** of the download activity for my package was caused by mirrorbots: 14,335 downloads total, compared to only 146 downloads with the bots filtered. And that's just leaving out the very obvious ones, so it's probably still an overestimate.
It looks like the main reason PyPI needs mirrors is because it has them.
|
9,653,926 |
I have a directory
```
D:\SVN_HOME\EclipseWorkspace\MF_CENTER_INFO
```
`SVN_HOME` - is a root svn working folder
`MF_CENTER_INFO` - the folder which I want to be commited to another svn repository
The default repository for `D:\SVN_HOME\` is `svn://10.101.101.101/svn/ee/trunk`
but `MF_CENTER_INFO` has to be commit to `svn://10.101.101.101/svn/mf-center-vp/` (**IPs are same**)
so, what I did:
right mouse click on `D:\SVN_HOME\EclipseWorkspace\`
added property

but when I choose commit or view properties for `D:\SVN_HOME\EclipseWorkspace\MF_CENTER_INFO` it shows default rep, now the external one

what's wrong?
|
2012/03/11
|
[
"https://Stackoverflow.com/questions/9653926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/272869/"
] |
I had the same problem when I upgraded to Google App Engine 1.6.0 from 1.5.5 .
I solved the problem by installing `python-memcached`:
```
pip install python-memcached
```
|
61,205,622 |
Can Anyone Please Convert the following Arduino Code to Embedded c code? I am very thankful to the one who converts this to an embedded c code. (this code is for Arduino lcd interfacing with Ultrasonic sensor)
```
#include <LiquidCrystal.h>
int inches = 0;
int cm = 0;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
pinMode(7, INPUT);
}
void loop() {
lcd.clear();
cm = 0.01723 * readUltrasonicDistance(7);
inches = (cm / 2.54);
if (cm<40){
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("Caution: ");
lcd.setCursor(0,1);
lcd.print("Objects Nearby");
delay(1000);
}
}
long readUltrasonicDistance(int pin)
{
pinMode(pin, OUTPUT); // Clear the trigger
digitalWrite(pin, LOW);
delayMicroseconds(2);
// Sets the pin on HIGH state for 10 micro seconds
digitalWrite(pin, HIGH);
delayMicroseconds(10);
digitalWrite(pin, LOW);
pinMode(pin, INPUT);
// Reads the pin, and returns the sound wave travel time in microseconds
return pulseIn(pin, HIGH);
}
```
|
2020/04/14
|
[
"https://Stackoverflow.com/questions/61205622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Accepted answer is not an accessible solution.
----------------------------------------------
I have made some corrections and some observations here. Do not use the accepted answer in production if you stumble across this question in the future. It is an awful experience with a keyboard.
The answer below fixes some of the CSS issues to make it more accessible.
However **I would recommend you reconsider the no JavaScript requirement.**
I can understand having a good fall-back (which the example I give below with the fixes is) but there is no way you can make a fully accessible set of CSS only tabs.
Firstly you should use WAI-ARIA to complement your HTML to make things even more clear for screen readers. See the [tabs examples on W3C](http://%20https://www.w3.org/TR/wai-aria-practices/examples/tabs/tabs-1/tabs.html) to see what WAI-ARIA roles you should be using. This is NOT possible without JavaScript as states need to change (`aria-hidden` for example should change).
Secondly, you should be able to use certain shortcut keys. Press the `home` key for example in order to return to the first tab, something you can only do with a little JS help.
With that being said here are a few things I fixed with the accepted answer to at least give you a good starting point as your 'no JavaScript **fallback**'.
### Problem 1 - `tabindex` on the label.
By adding this you are creating a focusable element that cannot be activated via keyboard (you cannot press `space` or `Enter` on the label to change selection, unless you use JavaScript).
In order to fix this I simply removed the `tabindex` from the labels.
### Problem 2 - no focus indicators when navigating via keyboard.
In the example the tabs only work when you are focused on the radio buttons (which are hidden). However at this point there is no focus indicator as the styling is applying styling to the checkbox when it is focused and not to its label.
In order to fix this I adjusted the CSS with the following
```
/*make it so when the checkbox is focused we add a focus indicator to the label.*/
.tabs__input:focus + label {
outline: 2px solid #333;
}
```
Problem 3 - using the same state for `:hover` and `:focus` states.
------------------------------------------------------------------
This is another bad practice that needs to go away, always have a different way of showing hover and focus states. Some screen reader and screen magnifier users will use their mouse to check they have the correct item focused and orientate themselves on a page. Without a separate hover state it is difficult to check you are hovered over a focused item.
```
/*use a different colour background on hover, you should not use the same styling for hover and focus states*/
.tabs__label:hover{
background-color: #ccc;
}
```
Example
-------
In the example I have added a hyperlink at the top so you can see where your focus indicator is when using a keyboard.
When your focus indicator is on one of the two tabs you can press the arrow keys to change tab (which is expected behaviour) and the focus indicator will adjust accordingly to make it clear which tab was selected.
```css
.tabs {
background-color: #eee;
min-height: 400px;
}
.tabs__list {
border-bottom: 1px solid black;
display: flex;
flex-direction: row;
list-style: none;
margin: 0;
padding: 0;
position: relative;
}
.tabs__tab {
padding: 0.5rem;
}
.tabs__content {
display: none;
left: 0;
padding: 0.5rem;
position: absolute;
top: 100%;
}
.tabs__input {
position: fixed;
top:-100px;
}
.tabs__input+label {
cursor: pointer;
}
.tabs__label:hover{
background-color: #ccc;
}
.tabs__input:focus + label {
outline: 2px solid #333;
}
.tabs__input:checked+label {
color: red;
}
.tabs__input:checked~.tabs__content {
display: block;
}
```
```html
<a href="#">A link so you can see where your focus indicator is</a>
<div class="tabs">
<ul class="tabs__list">
<li class="tabs__tab">
<input class="tabs__input" type="radio" id="tab-0" name="tab-group" checked>
<label for="tab-0" class="tabs__label" role="button">Tab 0</label>
<div class="tabs__content">
Tab 0 content
</div>
</li>
<li class="tabs__tab">
<input class="tabs__input" type="radio" id="tab-1" name="tab-group">
<label for="tab-1" class="tabs__label" role="button">Tab 1</label>
<div class="tabs__content">
Tab 1 content
</div>
</li>
</ul>
</div>
```
|
53,949,061 |
I have various formats of dates, in strings, all in ColumnA. Here is a small example.
```
-rw-r--r-- 35 30067 10224 <-- 2018-09
-rw-r--r-- 36 30067 10224 <-- 2018-09
-rw-r--r-- 65 30067 10224 <-- 2018-10-24
```
Is there a way I can interpret any date from any given string?
|
2018/12/27
|
[
"https://Stackoverflow.com/questions/53949061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5212614/"
] |
I tried to get date with regular expression. As far as I see, the date is either in the end of the string or there's a dot after it (followed by extension). The regex takes into account the length of the year: either 4 or 2. Also it manages the case when month is expressed in text. *Important!* When the day is absent, I set it as first day.
```
Function GetDate(strString$)
Dim sYear$, sMonth$, sDay$
With CreateObject("VBScript.RegExp")
.IgnoreCase = True: .Pattern = "(\d{2})([a-z]{3}|\d{2})(\d{2})?(?=\.|$)"
With .Execute(strString)
If .Count > 0 Then
With .Item(0)
sYear = .SubMatches(0)
sMonth = .SubMatches(1)
sDay = .SubMatches(2)
sYear = "20" & sYear
If Not IsNumeric(sMonth) Then
sMonth = GetMonthIndex(sMonth)
End If
If Len(sDay) = 0 Then sDay = "01"
GetDate = DateSerial(CInt(sYear), CInt(sMonth), CInt(sDay))
End With
End If
End With
End With
End Function
Private Function GetMonthIndex$(strMonth$)
Select Case strMonth
Case "Jan": GetMonthIndex = "01"
Case "Feb": GetMonthIndex = "02"
Case "Mar": GetMonthIndex = "03"
Case "Apr": GetMonthIndex = "04"
Case "May": GetMonthIndex = "05"
Case "Jun": GetMonthIndex = "06"
Case "Jul": GetMonthIndex = "07"
Case "Aug": GetMonthIndex = "08"
Case "Sep": GetMonthIndex = "09"
Case "Nov": GetMonthIndex = "10"
Case "Oct": GetMonthIndex = "11"
Case "Dec": GetMonthIndex = "12"
End Select
End Function
```
|
66,234,556 |
I have a file path which I access like this
```
string[] pathDirs = { Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\")),
"config", "file.txt" };
string pathToFile = Path.Combine(pathDirs);
```
When I run the build from within visual studio it gets the `config` directory from the root directory of the project but when I publish the build and run the program from the published build I get the error
```
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\<user>\AppData\Local\Apps\2.0\GA3VWRPE.G83\KDK3Q6QC.VP1\sv20..tion_333839f4362dc717_0001.0000_958d209d94853f42\config\file.txt'.
```
I'm unsure how to access this directory and file in the published build. How would I do this?
|
2021/02/17
|
[
"https://Stackoverflow.com/questions/66234556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3531792/"
] |
You should specify what column(s) contain(s) duplicates:
```
removeDuplicates = data.drop_duplicates(subset=['COUNTY'])
```
|
25,789,664 |
I have a spreadsheet with roughly 750 part numbers and costs on it. I need to add $2 to each cost (not total the whole column). The range would be something like D1:D628 and I've tried using =SUM but either I'm doing it wrong or it isn't possible.
I initially tried `=SUM(D1:D628+2)` and got a circular reference warning, I've tried variations of the formula and keep getting errors even after removing the circular reference. I also tried the following VBA module insert:
```
Sub Add2Formula()
' Add 2
For Each c In Selection
c.Activate
ActiveCell.FormulaR1C1 = "= " & ActiveCell.Formula & "+2"
Next c
End Sub
```
|
2014/09/11
|
[
"https://Stackoverflow.com/questions/25789664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1139955/"
] |
If you just want to add 2 to a range of numbers (not formulas) then
enter the number 2 in a blank cell somewhere
copy it
Select the cells you want to add 2 to, and then select paste special, choose ADD as the operation option.
|
52,952,279 |
Write the number of days in months program so that the program prompts the user for the file name and reads the dates from the file.
The dates in the file are written in the format dd.mm.yyyy. The program looks for the month in each line (hint: use split) and prints out the number of days in that month.
Rewrite the function so that it does not contain conditional (if) statements for returning the number of days. The function should do it using a list. Do not add the check for a leap year (let’s say that there are 28 days in February).
I have this code:
```
dates = {}
file = input("Enter file name:")
file = open("dates.txt", "r")
for line in file:
month = line.split(".")
dates = month[1]
print (dates)
```
But it only reads the month from the text file. How do I add another formula to read the months and state the days instead, within this code without using "IF"?
|
2018/10/23
|
[
"https://Stackoverflow.com/questions/52952279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
**Yes**.
I could make it work by adding this at the end of the pubspec.yaml:
```
module:
androidPackage: com.teste.embeded
iosBundleIdentifier: com.teste.embeded
```
Add this and then call a *packages get*. This will create 2 hidden folders in your project structure: .android and .ios.
**Becareful with the identation!** This settings must be inside the `flutter:` tag, like this:
```
flutter:
uses-material-design: true
assets:
- images/a_dot_burr.jpeg
- images/a_dot_ham.jpeg
module:
androidPackage: com.test.embeded
iosBundleIdentifier: com.test.embeded
```
After doing this, follow the documentation for the Android/iOS sides (skip the module creating parts).
<https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps>
|
712,463 |
In C, is there a nice way to track the number of elements in an enum? I've seen
```
enum blah {
FIRST,
SECOND,
THIRD,
LAST
};
```
But this only works if the items are sequential and start at zero.
|
2009/04/03
|
[
"https://Stackoverflow.com/questions/712463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66349/"
] |
I don't believe there is. But what would you do with such a number if they are not sequential, and you don't already have a list of them somewhere? And if they are sequential but start at a different number, you could always do:
```
enum blah {
FIRST = 128,
SECOND,
THIRD,
END
};
const int blah_count = END - FIRST;
```
|
821,072 |
While trying to install Ubuntu 16.04 I gave a passphrase which I forgot. Now I am unable to access my HDD.
Please, help me to decrypt and access my files!
|
2016/09/05
|
[
"https://askubuntu.com/questions/821072",
"https://askubuntu.com",
"https://askubuntu.com/users/590820/"
] |
In order to restore all your data, you will need to reformat the drive, and then restore everything from your backups.
The process for restoring from backup will vary depending on what your backup solution was.
If your backup is encrypted, you will need to ensure you remember the encryption passphrase or code for it.
|
187,922 |
I have a need to support multiple websites on a single IIS 7 server. One of these websites needs to be able to support wildcard subdomains. I was hoping to use host headers for this approach but am thinking this is not possible. The site that requires wildcard subdomains won't let me use \*.site.com in the host header and therefore won't respond to subdomain requests unless i set it to listen blindly on port 80. If I have that site listen blindly on port 80, it seems my other sites will not work.
It's completely plausible I'm missing a step. Any help is greatly appreciated!
|
2009/10/23
|
[
"https://serverfault.com/questions/187922",
"https://serverfault.com",
"https://serverfault.com/users/46124/"
] |
Give each separate website its own IP address and configure IIS to listen based on IP address rather than `Host` header.
Then, any single website with multiple or wildcard subdomains but at a separate IP will work with IIS listening to all incoming requests on that IP.
|
23,443,464 |
I am new to bootstrap, and I am trying to align a logo and navbar to in the same line. Actually, in the image you see below. I want the menus, logo and navbar to start from the same point.

I know how the 12 grid-system works. But how do we make classes nested inside the rows to indent properly.
This is my HTML.
```
<section class="header-container jumbotron">
<nav class="col-md-12 col-md-offset-2">
<ul class="menu">
<li> <a href="/"> HOME </a> </li>
<li> <a href="pages/about"> ABOUT </a></li>
<li> <a href="pages/register"> SUBMIT YOUR BUSINESS! </a></li>
<li> <a href="pages/login"> LOGIN </a> </li>
<li> <a href="pages/contact"> CONTACT US </a> </li>
</ul>
</nav>
<div class="col-md-4 col-md-offset-2 logo">
{{ HTML::image('img/logo.png', 'ethio360', array("height"=>44, "width"=>157))}}
</div>
<div class="container">
<div class="search-bar col-md-12">
{{ Form::open(['url'=>'/']) }}
<div>
{{ Form::label('title', 'Title')}}
{{ Form::text('title') }}
</div>
<div>
{{ Form::label('body', 'Body') }}
{{ Form::text('body') }}
</div>
<div>
{{ Form::submit('Create Text')}}
</div>
{{ Form::close() }}
</div>
</div>
</section>
```
The only thing I need is for the menu to appear first, then the logo and finally the searchbar.
But they should all start from the same place from left.
and this is my css.
```
.jumbotron{
background: red;
padding: 0;
margin: 0;
}
.header-container{
min-height: 325px;
background: #ffd106;
background: url(../img/city.jpg);
border-top:1px solid #252525;
}
.menu{
list-style-type: none;
}
.menu li a{
color:#252525;
float:left;
font-size:11px;
padding:1px 10px;
}
.logo{
padding:10px;
}
.search-bar{
width:80%;
background: none repeat scroll 0% 0% #252525;
border-radius: 3px;
box-shadow: 1px 1px 1px #545454;
padding:5px 4px;
color:#efefef;
font-weight: normal;
}
.search-bar div{
float:left;
margin-left: 10px;
}
.search-bar div input{
border:1px solid #CCC;
padding:4px;
margin-left:10px;
}
```
|
2014/05/03
|
[
"https://Stackoverflow.com/questions/23443464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2520374/"
] |
```
#include <iostream>
int addNumber(int x, int y)
{
int answer = x + y;
return answer;
}
int main()
{
int x,y;
std::cin >> x >> y;
std::cout << addNumber(x,y) << std::endl;
return 0;
}
```
|
12,883,490 |
If I load a customer in the following way:
```
$customer = Mage::getModel('customer/customer')
->load($customer_id);
```
Whats the difference between:
```
$customer -> getDefaultShippingAddress();
```
and
```
$customer -> getPrimaryShippingAddress();
```
Thanks in advance!
|
2012/10/14
|
[
"https://Stackoverflow.com/questions/12883490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1259801/"
] |
They return the same result
See /app/code/core/Mage/Customer/Model/Customer.php
```
/*
* @return Mage_Customer_Model_Address
*/
public function getPrimaryBillingAddress()
{
return $this->getPrimaryAddress('default_billing');
}
/**
* Get customer default billing address
*
* @return Mage_Customer_Model_Address
*/
public function getDefaultBillingAddress()
{
return $this->getPrimaryBillingAddress();
}
```
|
6,523,653 |
Prior to Rails 3, I used this code to observe a field dynamically and pass the data in that field to a controller:
```
<%= observe_field :transaction_borrower_netid,
:url => { :controller => :live_validations, :action => :validate_borrower_netid },
:frequency => 0.5,
:update => :borrower_netid_message,
:with => "borrower_netid" %>
```
I'm trying to update that code to work with Jquery and Rails 3, but I can't get it to work. I updated my **routes.rb** to include
```
match "/live_validations/validate_borrower_netid" => "live_validations#validate_borrower_netid", :as => "validate_borrower"
```
and I'm trying to observe the field and make the necessary calls with:
```
jQuery(function($) {
// when the #transaction_borrower_netid field changes
$("#transaction_borrower_netid").change(function() {
// make a POST call and update the borrower_netid_message with borrower_netid
$.post(<%= validate_borrower_path %>, this.value, function(html) {
$("#borrower_netid_message").html(html);
});
});
})
```
but it's not working. My Javascript and Jquery skills are severely lacking, so any help anyone could provide would be much appreciated. Thanks!
|
2011/06/29
|
[
"https://Stackoverflow.com/questions/6523653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751114/"
] |
You are able to do this, but it's not very clean, in terms of the proper `$_GET` variable values. The solution automatically type casts the values to integers:
```
sscanf($_GET['id'], '%d,%d', $id, $lang);
// $id = int(5)
// $lang = int(1)
```
|
8,751,082 |
Trying to put the Dark colored Like Box on my website, everything seems to function properly but the color looks like its the light scheme, what's the problem?
Here's the code I used:
```
<iframe src="//www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fplatform&width=360&height=258&colorscheme=dark&show_faces=true&border_color&stream=false&header=false" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:360px; height:258px;" allowTransparency="true"></iframe>
```
I tried both the iframe and html5 codes.
Another problem is sometimes only a couple faces show in the box and other times it displays max faces.
|
2012/01/05
|
[
"https://Stackoverflow.com/questions/8751082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1133216/"
] |
The dark color scheme is rendering properly, but by design it doesn't have a background (it's transparent). Put it in front of a `div` with the background you want, as [demonstrated here](http://jsfiddle.net/R85V4/).
|
29,310,998 |
I can not set the name of the selected object in "BarraNome" how can I do?
```
public class MainActivity2Activity extends Activity {
String[] lista1 = { "JAN", "FEB", "MAR", "APR", "MAY", "JUNE", "JULY","AUG", "SEPT", "OCT", "NOV", "DEC" };
Button BarraNome;
private ListView lista;
private ArrayAdapter arrayAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_activity2);
lista = (ListView) findViewById(R.id.listacompleta);
arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, lista1);
lista.setAdapter(arrayAdapter);
lista.setOnItemClickListener(new AdapterView.OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> av, View v, int pos,long id){
```
Look this part of code!
```
//This code works//
Toast.makeText(getApplicationContext(),""+ lista1[pos], Toast.LENGTH_LONG).show();
//Don't works, why?//
BarraNome.setText(""+ lista1[pos]);
}});}}
```
Please help me
|
2015/03/27
|
[
"https://Stackoverflow.com/questions/29310998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4671207/"
] |
You may need to call out to `expr`, depending on your mystery shell:
```
d1="2015-03-31" d2="2015-04-01"
if [ "$d1" = "$d2" ]; then
echo "same day"
elif expr "$d1" "<" "$d2" >/dev/null; then
echo "d1 is earlier than d2"
else
echo "d1 is later than d2"
fi
```
```
d1 is earlier than d2
```
---
The `test` command (or it's alias `[`) only implements string equality and inequality operators. When you give the (non-bash) shell this command:
```
[ "$d1" > "$d2" ]
```
the `> "$d2"` part is treated as stdout redirection. A zero-length file named (in this case) "2015-04-01" is created, and the conditional command becomes
```
[ "$d1" ]
```
and as the variable is non-empty, that evaluates to a success status.
The file is zero size because the `[` command generates no standard output.
|
18,243,921 |
I'm very new to Objective-C so sorry if this is extremely obvious to many of you, but I'm trying to work out how the following piece of code is actually working:
```
- (IBAction)chooseColour:(UIButton *)sender {
sender.selected = !sender.isSelected;
}
```
Now it obviously toggles between the selected and unselected states of the button sending the action, but what is the code 'sender.selected = !sender.isSelected' actually saying? Is it just 'set the sender selected property to the opposite (i.e. ! not) of the getter'? So if the getter is 'getting' the current selected value as true then it sets the selected property as !true i.e false. Or is this a piece of convenience code that I'm not yet privy to? Because it also seems that '!sender.isSelected' simply means not selected as in
```
if (!sender.isSelected){
statement
}
```
i.e. do statement if the sender is not selected. This is no doubt really obvious, just I'm a bit confused with it at the moment.
Thanks!
|
2013/08/14
|
[
"https://Stackoverflow.com/questions/18243921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2658664/"
] |
You are entirely correct, it's calling the getter to obtain the value and calling the setter with the NOT (`!`) of the value. It isn't Objective-C, it's plain C syntax.
|
24,056,020 |
Here is HTML:
```
<div class="vl-article-title">
<h3>
<span style="font-size: 24px;">
<a href="http://www.15min.lt/naujiena/sportas/fifa-2014/desimt-pasaul…onato-debiutantu-kurie-atkreips-jusu-demesi-813-430673?cf=vl"></a>
</span>
</h3>
</div>
```
I need to get only links (a) but I don't know how. Is it possible to do something like this:
```
h3 = soup.select('div.vl-article-title > h3 > a')
```
?
|
2014/06/05
|
[
"https://Stackoverflow.com/questions/24056020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2788600/"
] |
The > sign is the direct descendant selector. It will not match the A element because there's a span in between.
You should be able to do this:
```
h3 = soup.select('div.vl-article-title > h3 > span > a')
```
Or, if it's OK to be a little less specific with the selector:
```
h3 = soup.select('div.vl-article-title a')
```
That matches all a elements which are undir the div with the class vl-article-title.
**EDIT:**
Sorry, been a while since I used beautiful soup, I mistakenly thought it worked with CSS selectors, but it does not.
One way to do this is:
```
a = soup.find("div", attrs={"class": "vl-article-title"}).find("h3").find("span").find("a")
```
|
124,576 |
On the Account page, I have a lookup for Secondary Contact. I also have two formula fields: Secondary Contact Email and Secondary Contact Phone.
If you choose someone in the Secondary Contact field, it should populate the Secondary Contact Email and Secondary Contact Phone fields. And this is mostly happening.
I have three email fields on the contact record: Preferred Email, Work Email, and Alternate Email. I can get Preferred and Work to populate the formula in accounts but Alternate will not come into accounts. I am lost....What am I doing wrong?
```
IF(NOT(ISBLANK(Secondary_Contact__r.npe01__HomeEmail__c)), Secondary_Contact__r.npe01__HomeEmail__c,
IF(ISBLANK(Secondary_Contact__r.npe01__HomeEmail__c), Secondary_Contact__r.npe01__WorkEmail__c,
IF( AND( ISBLANK(Secondary_Contact__r.npe01__HomeEmail__c), ISBLANK(Secondary_Contact__r.npe01__WorkEmail__c)), Secondary_Contact__r.npe01__AlternateEmail__c,
null
)
)
)
```
|
2016/06/03
|
[
"https://salesforce.stackexchange.com/questions/124576",
"https://salesforce.stackexchange.com",
"https://salesforce.stackexchange.com/users/32133/"
] |
Something like this should work
```
IF(NOT(ISBLANK(Secondary_Contact__r.npe01__HomeEmail__c))
,Secondary_Contact__r.npe01__HomeEmail__c,
(IF(NOT(ISBLANK(Secondary_Contact__r.npe01__WorkEmail__c))),Secondary_Contact__r.npe01__WorkEmail__c,
Secondary_Contact__r.npe01__AlternateEmail__c))
```
Your version is overcomplicated because you are rechecking things in the "else" part.
If you are in the "else" of `NOT(ISBLANK(Secondary_Contact__r.npe01__HomeEmail__c))` then you do not need to check again `ISBLANK(Secondary_Contact__r.npe01__HomeEmail__c))`
|
32,311 |
I'm interested in \*coin, but I'm afraid of sinking money into something out of idle curiosity and then losing that money to value fluctuations. Would it be a good idea to have several different \*coin (lite, doge, idk what else there is) so that the fluctuations balance each other?
Have different \*coin in the past gained and lost value in 'lockstep', or totally independent or inversely?
I'm aware that I would also loose the chance to gain money from course fluctuations, but I don't that's [something to loose sleep over](http://blockchain.info/de/charts/market-price).
|
2014/11/04
|
[
"https://bitcoin.stackexchange.com/questions/32311",
"https://bitcoin.stackexchange.com",
"https://bitcoin.stackexchange.com/users/13856/"
] |
I don't see how different coins would protect against volatility, as Bitcoin is by far the leading cryptocurrency, and the others (even all of them combined) are really totally insignificant in terms of market cap and trading volume.
If you want to protect against volatility (given that you measure volatility in terms of value expressed in fiat currency), there's two options:
* use [Coinapult Locks](https://coinapult.com/locks/info)
* keep part of your money in fiat
Simple as that. Seriously, just not investing part of your money in something is the best and easiest way to suppress its volatility.
|
29,220,881 |
I am working with VPN on iOS using the NetworkExtension framework. I am able to install the config and make connection. My question is if there's a way to detect if the VPN config is still installed or detect if user has un-installed the config?
I am not necessarily looking for a notification or anything in the background but what I am looking for is some method/workaround that I do when the application is brought to foreground?
I'm using certificate authentication with a certificate issued by an intermediate CA and have tried 'evaluating trust' method from here: [Check if a configuration profile is installed on iOS](http://blog.markhorgan.com/?p=701)
This did not work for me. I always comes to be trusted. I have also tried this:
```
if([NEVPNManager sharedManager].protocol){
//installed
}else{
//not installed
}
```
But this also does not work. After uninstallation the protocol remains valid. If I quit and relaunch the app then the protocol is invalid.
Any suggestions are appreciated.
|
2015/03/23
|
[
"https://Stackoverflow.com/questions/29220881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2060112/"
] |
You can try following
```
if ([[[NEVPNManager sharedManager] connection] status] == NEVPNStatusInvalid) {
//...
}
```
|
1,019,267 |
Consider 3 baskets. Basket A contains 3 white and 5 red marbles. Basket B contains 8 white and 3 red marbles. Basket C contains 4 white and 4 red marbles. An experiment consists of selecting one marble from each basket at random. What is the probability that the marble selected from basket A was white, given that exactly 2 white marbles were selected in this process.
I know P(AB) = 33/176 and I understand how to get there.
However I'm not sure why P(B) = 73/176.
Here is the answer, but can you explain why?
|
2014/11/12
|
[
"https://math.stackexchange.com/questions/1019267",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/177356/"
] |
By Bayes rule, the required probability is equal to
$$P(A\_w|W=2)=\frac{P(W=2|A\_w)P(A\_w)}{P(W=2)}=\frac{\frac{1}{2}\frac{3}{8}}{\frac{73}{176}}=\frac{33}{73}$$ since $$P(W=2|A\_w)=P(B\_w)P(C\_r)+P(B\_r)(C\_w)=\frac{1}{2}$$ and $$\begin{align\*}P(W=2)&=P(A\_w)P(B\_w)P(C\_r)+P(A\_w)P(B\_r)P(C\_w)+P(A\_r)P(B\_w)P(C\_w)\\\\&=\frac{3}{8}\frac{8}{11}\frac{1}{2}+\frac{3}{8}\frac{3}{11}\frac{1}{2}+\frac{5}{8}\frac{8}{11}\frac{1}{2}=\frac{73}{176}\end{align\*}$$
|
14,841,746 |
I have a JS app that saves to localStorage. No big deal. However, what's being stored are fairly large JSONs. 10MB vanishes quickly. What I'd like to do is, if storage is full, delete the oldest record.
Is there a way to reliably find the oldest record in localStorage?
|
2013/02/12
|
[
"https://Stackoverflow.com/questions/14841746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/435175/"
] |
In order to make your LayerSlider display at 100% height and width, leave the "Slider height" attribute in "Slider Settings" blank, and then use a script like the following to set the height:
```
<script type="text/javascript">
function resize()
{
var heights = window.innerHeight;
document.getElementById("layerslider_1").style.height = heights + "px";
}
resize();
window.onresize = function() {
resize();
};
</script>
```
Insert the script into your footer.php file before the closing body tag. If your slider ID isn't number 1, then change "layerslider\_1" to the correct ID.
|
36,287,160 |
DataBase has table with saved Tweets.
There is controller:
```
<?php
namespace app\controllers;
use yii\rest\ActiveController;
class TweetController extends ActiveController
{
public $modelClass = 'app\models\Tweet';
}
```
Corresponding model `app\model\Tweet` created by `gii`.
In `app\web\config` added:
```
..............
'components' => [
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
'rules' => [
['class' => 'yii\rest\UrlRule',
'controller' => 'tweet'],
],
],
'request' => [
'parsers' =>['application/json' => 'yii\web\JsonParser', ],
],
...............
```
In `app\web` added `.htaccess` according <http://www.yiiframework.com/doc-2.0/guide-tutorial-shared-hosting.html>
In `apache` DocumentRoot as `app\web`
According yii2 docs: `curl -i -H "Accept:application/json" "http://localhost/tweets"` must return paged model data. Instead of this:
```
HTTP/1.1 404 Not Found
Date: Tue, 29 Mar 2016 14:04:05 GMT
Server: Apache/2.4.7 (Ubuntu)
Content-Length: 278
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /tweets was not found on this server.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at localhost Port 80</address>
</body></html>
```
Also tryed - urlManager `'controller' => ['tw' => 'tweet']` whit according url.
why there is 404? Guided by <http://www.yiiframework.com/doc-2.0/guide-rest-quick-start.html>
added: well... url should be `http://localhost/index.php/tweets` but it`s not obviously for me.
|
2016/03/29
|
[
"https://Stackoverflow.com/questions/36287160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5923447/"
] |
The path should be
```
http:://localhost/yii2/tweets
```
or
```
http:://localhost/yii2/index.php/tweets
```
(depending by the correct configuration of urlManager)
try also
```
http:://localhost/yii2/tweets/index
```
or
```
http:://localhost/yii2/index.php/tweets/index
```
could be you can find useful this tutorial <http://budiirawan.com/setup-restful-api-yii2/>
|
69,679,870 |
Is there a simple solution (lint rule perhaps?) which can help enforce clean code imports through index files? I'd like to prevent importing code from "cousin" files, except if it is made available through an index file.
Ex:
```
- app
+ dogs
| + index.ts
| + breeds
| | + retriever.ts
| | + schnauzer.ts
| + activities
| + playing.ts
| + walking.ts
+ cats
+ index.ts
+ breeds
| + siamese.ts
| + persion.ts
+ activities
+ sleeping.ts
+ hunting.ts
```
Importing from the perspective of `cats/activities/hunting.ts`:
```
import { sleeping } from './sleeping' // VALID - inside same folder
import { siamese } from '../breeds/siamese' // VALID - inside cats module
import { playing } from '../../dogs' // VALID - importing from an index
import { retriever} from '../../dogs/activities/breeds' // INVALID - cousin file outside module possibly not exported from index
```
|
2021/10/22
|
[
"https://Stackoverflow.com/questions/69679870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2908576/"
] |
You can use eslint's [`import/no-internal-modules` rule](https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/no-internal-modules.md) and configure separate `.eslintrc` rules per "root" module.
In your `dogs` folder, create a new `.eslintrc` file with this contents:
```
{
"rules": {
"import/no-internal-modules": [ "error", {
"allow": [ "app/dogs/**", "app/*" ],
} ]
}
}
```
This means any js/ts file within the dogs folder (or any sub folder of dogs) may import files from its own package *OR* any package like `/cats`
Do the same for your `cats` and any other "root" module.
|
46,250 |
I'm using an API which returns text in the following format:
```
#start
#p 09060 20131010
#p 09180 AK
#p 01001 19110212982
#end
#start
#p 09060 20131110
#p 09180 AB
#p 01001 12110212982
#end
```
I'm converting this to a list of objects:
```
var result = data.match(/#start[\s\S]+?#end/ig).map(function(v){
var lines = v.split('\n'),
ret = {};
$.each(lines, function(_, v2){
var split = v2.split(' ');
if(split[1] && split[2])
ret[split[1]] = split[2];
});
return ret;
});
```
My concern is that the API returns quite a lot of data, therefore I would like some feedback regarding on how to improve the performance.
For instance, is there any way to reduce the mapping complexity from O(N2) to O(N)?
Also, please suggest regex improvements :)
|
2014/04/04
|
[
"https://codereview.stackexchange.com/questions/46250",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/26558/"
] |
I totally agree with Uri and have some further comments:
>
> the class has no idea what the set will contain, it does however know there maybe a IDescriptor that is meant for video..
>
>
>
I'm sorry, but I have to ask: If you're not sure about exactly what the Set contains, why are you storing it in a set in the first place?
Consider instead something like `Map<KEY_TYPE, List<? extends IDescriptor>> descriptors;` where `KEY_TYPE` can be a `Class<? extends IDescriptor>`, a `String`, or something else that can tell you what type it is.
When adding items to this map you could use:
```
List<? extends IDescriptor> list = descriptors.get(descriptor.getClass());
if (list == null) {
list = new ArrayList<>();
descriptors.put(descriptor.getClass(), list);
}
list.add(descriptor);
```
And then all you would need to do is to use `descriptors.get(VideoDescriptor.class)` (assuming `VideoDescriptor` is not subclassed, otherwise you could loop through the supertypes as well when adding to the list).
---
Another thought is that you can use a `enum` to describe what kind of `IDescriptor` it is, and the `IDescriptor` type can have a `getDescriptorType` method. Then you could check `if (fragmentDescriptor.getDescriptorType() == DescriptorType.VIDEO)`
As I only see a portion of your code and not the big picture, I can't really tell what would be best for you.
|
30,336,337 |
I'm a bit confused about the different between **Events** and **Listeners**.
I understood how you can create your events under `Events` then register them and implement the Handlers in `Handlers\Events`. So here I have events and the handling of events.
They work after I define them in `Providers\EventServiceProvider.php`
```
protected $listen = [
UserHasSignedUp::class => [
SendWelcomeEmail::class,
SendAdminEmail::class
]
];
```
So what are **Listeners**?
To me they seem exactly the same thing as **Event Handlers**?
|
2015/05/19
|
[
"https://Stackoverflow.com/questions/30336337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/391986/"
] |
In your example `UserHasSignedUp` is an `Event`. `SendWelcomeEmail` and `SendAdminEmail` are two listeners "waiting" for the event UserHasSignedUp to be fired and they should implement the required business logic at `handle` method of each one.
Super simple example:
Somewhere in UserController
```
Event::fire(new UserHasSignedUp($user)); //UserHasSignedUp is the event being fired
```
SendWelcomeEmail class
```
class SendWelcomeEmail //this is the listener class
{
public function handle(UserHasSignedUp $event) //this is the "handler method"
{
//send an email
}
}
```
As you can see, each event can have multiple listeners, but a listener can't listen to more than a single event.
If you want a class listening to many events, you should take a look to [Event Subscribers](http://laravel.com/docs/5.0/events#event-subscribers)
Hope it helps.
|
24,767,679 |
I wrote this sql query:
```
select first_name, salary
from employees
where salary in( select distinct top(10) salary from employees order by salary disc );
```
When I ran it, I got this error:
SQL Error: ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"
What could have caused the error?
|
2014/07/15
|
[
"https://Stackoverflow.com/questions/24767679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3614370/"
] |
Top-N query is typically performed this way in Oracle:
```
select * from (
select first_name, salary
from employees order by salary desc
) where rownum <= 10
```
This one gets you top 10 salaries.
|
123,439 |
Recently, I learned about the concept of the [51% attack](https://www.investopedia.com/terms/1/51-attack.asp) which a malicious actor could perform on a cryptocurrency. Essentially, if you can control >50% of the hashing power for a given cryptocurrency, you can control the blockchain which allows you to do all sorts of devious things like [double-spending](https://www.investopedia.com/terms/d/doublespending.asp) the cryptocurrency.
There's even a website, [crypto51.app](https://www.crypto51.app/), which keeps track of the theoretical costs of performing such an attack. This cost seems to come from the money one would spend in gaining that >50% control for an hour - usually in terms of renting computing time.
Clearly, the more computing power the cryptocurrency community is putting into mining, for a given cryptocurrency, the harder and more expensive it is to perform a 51% attack. So crypocurrencies like Bitcoin are reasonably safe from an attack like this. However, newer, less mined crypocurrencies are *much* more likely susceptible to the 51% attack.
So my question is, how can new cryptocurrencies even form? It seems like people are forming their own cryptocurrencies left and right, even as jokes (see , e.g., [dogecoin](https://dogecoin.com/)). How can new currencies get off the ground and gain enough critical mass to be reasonably safeguarded against a 51% attack? Why don't most new cryptocurrencies get killed off nearly immediately by an attack like this?
|
2020/04/03
|
[
"https://money.stackexchange.com/questions/123439",
"https://money.stackexchange.com",
"https://money.stackexchange.com/users/44939/"
] |
Generally new cryptocurrencies are protected either by a complete lack of incentive to attack them, or by amassing support leading up to their eventual "launch." Older ones are somewhat protected by people being vigilant and communities occasionally agreeing on hard forks to ignore transactions on "compromised" chains; 51% attacks -- which don't actually need 51% of the network to pull off -- are still a threat even for well established blockchains.
Double spending relies on there being someone who wants the cryptocurrency you have that you can dupe, and the amounts being transacted being high enough to offset hardware costs, time investments, opportunity costs, or other costs related to the attack. Very new cryptocurrencies will typically have almost nobody to transact with in the first place; and will have a very low "market cap", which severely limits the returns. There is generally no financial incentive to attack a new blockchain.
There are some cyrptocurrenices that are "launched" with substantial support, where individuals creating the cryptocurrency will offer "ICOs" and other means of generating interest. While this would make for a much more lucrative target compared to another new crypto that has no such interest, it also means that the costs for the attack are much greater, and there will be more interest in forking away from "compromised" chains among the userbase.
Futher, successfully attacking a blockchain like this is relatively easy to detect, and will erode confidence or interest in a cryptocurrency, of which most new cryptos have little to spare. Even if your attack is not "reversed" by the majority with a fork, you will crater the value of any amount you gain through double spends.
|
21,147,988 |
I'm a junior .NET developer and our company has a ton of code in their main application. All of our css for the web application is using bootstrap 2.3. I've been assigned the task to migrate from 2.3 to the new 3.0. This update has a ton of major changes. I'm looking for any and all suggestions on how I can make this work efficiently without having to go into each file and change the class.
Container fluid and row fluid are now just container and fluid. These classes are probably on every single html page in our application. Please help me :)
|
2014/01/15
|
[
"https://Stackoverflow.com/questions/21147988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2859933/"
] |
Bootstrap 3 is a major upgrade. You will have to "manually" update the classes in each file, and in some cases change the structure of your markup. There are some tools that can help..
See:
[Updating Bootstrap to version 3 - what do I have to do?](https://stackoverflow.com/questions/17974998/updating-bootstrap-to-version-3-what-do-i-have-to-do)
<http://upgrade-bootstrap.bootply.com>
|
16,069,799 |
To get a MapView, I would have to extend my class with MapActivity. When I try to do this, I get an error "Create MapActivity Class".
If I do not extend it with MapActivity and use Activity instead, I get the following Exception.
```
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.strive.gostrive/com.strive.gostrive.EventDetailActivity}: android.view.InflateException: Binary XML file line #168: Error inflating class com.google.android.maps.MapView
```
I have made the required changes in the xml file, android manifest file. I have also included the google play services lib in my project. The target for both google play services and my app is the same.
Need Help!!
Here is my xml file
```
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".EventDetailActivity" >
<ImageView
android:id="@+id/eventDImg"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_alignBaseline="@+id/eventDEndDate"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/innershadow" />
<TextView
android:id="@+id/textView2D"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/eventDDateTV"
android:layout_alignBottom="@+id/eventDDateTV"
android:layout_toRightOf="@+id/eventDDateTV"
android:text="-" />
<TextView
android:id="@+id/eventDEndDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView2D"
android:layout_toRightOf="@+id/textView2D"
android:maxLength="10"
android:text="End Date" />
<TextView
android:id="@+id/eventDStartAge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/eventDEndDate"
android:layout_alignLeft="@+id/textView3D"
android:layout_marginLeft="39dp"
android:maxLength="2"
android:text="frm" />
<TextView
android:id="@+id/textView4D"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/eventDEndDate"
android:layout_toRightOf="@+id/eventDStartAge"
android:text="-" />
<TextView
android:id="@+id/eventDAgeTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/eventDEndDate"
android:layout_toRightOf="@+id/textView4D"
android:maxLength="2"
android:text="to" />
<TextView
android:id="@+id/eventDTitleTV"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:maxLines="2"
android:text="Event Title"
android:textSize="20dp" />
<TextView
android:id="@+id/eventDDateTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/eventDTitleTV"
android:layout_centerVertical="true"
android:maxLength="10"
android:text="Strt Date" />
<TextView
android:id="@+id/textView1D"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/eventDTitleTV"
android:layout_marginLeft="180dp"
android:layout_toLeftOf="@+id/eventDPriceTV"
android:text="$"
android:textSize="20dp" />
<TextView
android:id="@+id/textView3D"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/eventDDayTV"
android:layout_alignBaseline="@+id/eventDEndDate"
android:layout_marginLeft="23dp"
android:layout_toRightOf="@+id/eventDTitleTV"
android:text="Ages:" />
<TextView
android:id="@+id/eventDPriceTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1D"
android:layout_alignBottom="@+id/textView1D"
android:layout_alignLeft="@+id/textView3D"
android:text="Event Fee"
android:textSize="20dp" />
<TextView
android:id="@+id/eventDStrtTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/eventDDayTV"
android:layout_marginTop="16dp"
android:text="Strt Tym" />
<TextView
android:id="@+id/eventDEndTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/eventDStrtTime"
android:layout_alignLeft="@+id/eventDEndDate"
android:layout_marginLeft="26dp"
android:text="End tym" />
<TextView
android:id="@+id/eventDVenueTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/eventDEndTime"
android:layout_alignLeft="@+id/eventDGender"
android:text="Venue" />
<TextView
android:id="@+id/eventDDayTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/eventDImg"
android:layout_below="@+id/eventDDateTV"
android:layout_marginTop="31dp"
android:text="M Tu W" />
<TextView
android:id="@+id/eventDGender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/eventDDayTV"
android:layout_alignBottom="@+id/eventDDayTV"
android:layout_toRightOf="@+id/textView1D"
android:text="gender" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="150dp"
android:layout_alignLeft="@+id/eventDImg"
android:layout_alignRight="@+id/eventDImg"
android:layout_below="@+id/eventDImg"
android:layout_marginTop="16dp"
android:orientation="vertical" >
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="***************************"
android:clickable="true" />
</LinearLayout>
```
Here is the activity
```
import com.google.android.gms.maps.MapView;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
public class EventDetailActivity extends Activity{
MapView map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_event_detail);
Bundle bundle = getIntent().getExtras();
int position = bundle.getInt("position");
map = (MapView) findViewById(R.id.mapview);
TextView txtEventName = (TextView)findViewById(R.id.eventDTitleTV);
TextView txtEventFee = (TextView)findViewById(R.id.eventDPriceTV);
TextView txtStartDate = (TextView)findViewById(R.id.eventDDateTV);
TextView txtEndDate = (TextView)findViewById(R.id.eventDEndDate);
TextView txtStartAge = (TextView)findViewById(R.id.eventDStartAge);
TextView txtEndAge = (TextView)findViewById(R.id.eventDAgeTV);
TextView txtDaysWeek = (TextView)findViewById(R.id.eventDDayTV);
TextView txtEventGender = (TextView)findViewById(R.id.eventDGender);
txtEventName.setText(EventModel.PREF_EVENTNAME);
txtEventFee.setText(EventModel.PREF_EVENTFEE);
txtStartAge.setText(EventModel.PREF_EVENTSATRTAGE);
txtEndAge.setText(EventModel.PREF_EVENTENDAGE);
txtStartDate.setText(EventModel.PREF_EVENTSTARTDATE);
txtEndDate.setText(EventModel.PREF_EVENTENDDATE);
txtDaysWeek.setText(EventModel.PREF_EVENTDAYSWEEK);
txtEventGender.setText(EventModel.PREF_EVENTGENDER);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.event_detail, menu);
return true;
}
}
```
|
2013/04/17
|
[
"https://Stackoverflow.com/questions/16069799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2208748/"
] |
I'm the lead developer and maintainer of Open source project [RioFS](https://github.com/skoobe/riofs): a userspace filesystem to mount Amazon S3 buckets.
Our project is an alternative to “s3fs” project, main advantages comparing to “s3fs” are: simplicity, the speed of operations and bugs-free code. Currently [the project](https://github.com/skoobe/riofs) is in the “beta” state, but it's been running on several high-loaded fileservers for quite some time.
We are seeking for more people to join our project and help with the testing. From our side we offer quick bugs fix and will listen to your requests to add new features.
Regarding your issue:
if'd you use [RioFS](https://github.com/skoobe/riofs), you could mount a bucket and have a write access to it using the following command (assuming you have installed [RioFS](https://github.com/skoobe/riofs) and have exported AWSACCESSKEYID and AWSSECRETACCESSKEY environment variables):
```
riofs -o allow_other http://s3.amazonaws.com bucket_name /mnt/static.example.com
```
(please refer to project description for command line arguments)
Please note that the project is still in the development, there are could be still a number of bugs left.
If you find that something doesn't work as expected: please fill a issue report on the [project's GitHub page](https://github.com/skoobe/riofs/issues?state=open).
Hope it helps and we are looking forward to seeing you joined our community !
|
64,851,611 |
I have an html form that pass values to a php file that performs a query and display the results.
Now I want that if in this first query the result is empty (0 rows), exactly the same query performs but over another table and display results.
Here is the code that performs the first query:
```
<?php
echo "<table style='border: solid 1px black;'>";
echo "<tr>
<th>R1</th>
<th>R2</th>
<th>R3</th>
<th>R4</th>
<th>R5</th>
</tr>";
class TableRows1 extends RecursiveIteratorIterator {
function __construct($it1) {
parent::__construct($it1, self::LEAVES_ONLY);
}
function current() {
return "<td style='width: 70px;'>" . parent::current(). "</td>";
}
function beginChildren() {
echo "<tr>";
}
function endChildren() {
echo "</tr>" . "\n";
}
}
if( isset($_POST['submit']) )
{
$feature = $_POST['R1'];
$feature2 = $_POST['R2'];
$feature3 = $_POST['R3'];
$feature4 = $_POST['R4'];
$feature5 = $_POST['R5'];
};
$feature = $_POST['R1'];
$feature2 = $_POST['R2'];
$feature3 = $_POST['R3'];
$feature4 = $_POST['R4'];
$feature5 = $_POST['R5'];
$values = [$feature, $feature2, $feature3, $feature4, $feature5];
$servername = "";
$username = "";
$password = "";
$dbname = "";
try {
$conn1 = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn1->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt1 = $conn1->prepare(
"SELECT
R1,
R2,
R3,
R4,
R5,
FROM table
WHERE
R1 = ?
AND
R2 = ?
AND
R3 = ?
AND
R4 = ?
AND
R5 = ?");
$stmt1->bindParam(1, $feature, PDO::PARAM_INT);
$stmt1->bindParam(2, $feature2, PDO::PARAM_INT);
$stmt1->bindParam(3, $feature3, PDO::PARAM_INT);
$stmt1->bindParam(4, $feature4, PDO::PARAM_INT);
$stmt1->bindParam(5, $feature5, PDO::PARAM_INT);
$stmt1->execute();
// set the resulting array to associative
$result1 = $stmt1->setFetchMode(PDO::FETCH_ASSOC);
foreach(new TableRows1(new RecursiveArrayIterator($stmt1->fetchAll())) as $k1=>$v1) {
echo $v1;
}
}
catch(PDOException $e1) {
echo "Error: " . $e1->getMessage();
}
$conn1 = null;
echo "</table>";
?>
```
I honestly do not know where and how to place the second query, any ideas and guidance I will appreciate very much!
|
2020/11/16
|
[
"https://Stackoverflow.com/questions/64851611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6884979/"
] |
To check the values inside the radio buttons you can use:
```js
$('input[name="<RADIO_BUTTON_NAME>"]:checked').val();
```
```js
$(function() {
$('#cssStyling').on('submit', function(event) {
event.preventDefault();
var n = $('input[name="colorP"]:checked').val();
// If the value is less than 7, add a red border
if (n == "red") {
$("p").css("color", "red");
}else if (n == "blue") {
$("p").css("color", "blue");
}if (n == "green") {
$("p").css("color", "green");
}
});
});
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!--Form that user fills out to change css styling of the page-->
<form id="cssStyling">
<label for="fontChange">Choose a font:</label>
<select id="fontChange" name="fontChange">
<option value="Times">Times</option>
<option value="Georgia">Georgia</option>
<option value="Helvetica">Helvetica</option>
<option value="Verdana">Verdana</option>
</select>
<br><br>
<p>What color should the paragraph font be?</p>
<!--red radio button-->
<input type="radio" id="red" name="colorP" value='red' required>
<label for="red"> Red</label>
<!--blue radio button-->
<input type="radio" id="blue" name="colorP" value="blue">
<label for="blue"> Blue</label>
<!--green radio button-->
<input type="radio" id="green" name="colorP" value="green">
<label for="green"> Green</label>
<br><br>
<p>Which page elements should have borders?</p>
<!--Checkbox and label for h1-->
<input type="checkbox" id="heading1" name="elements">
<label for="heading1">h1 element</label>
<!--Checkbox and label for h2-->
<input type="checkbox" id="heading2" name="elements" value="heading2">
<label for="heading2">h2 element</label>
<!--Checkbox and label for p-->
<input type="checkbox" id="paragraphs" name="elements">
<label for="paragraphs">p element</label>
<br><br>
<input type="submit" value="Click to submit styling changes" />
</form>
<!--End form-->
<h1>I am h1</h1>
<p>I am p</p>
<h2>I am h2</h2>
```
For more knowledge on how to get values from forms with Jquery : <https://medium.com/@bruce.sarah.a/getting-form-values-with-jquery-7d456cb82080>
|
3,856 |
I've recently signed up for Google Apps because of the email support. I only use the web based gmail client for all my mail. I'd like to have a professional email signature for each email that I send that includes a small image which is the Logo of my company. How can include such an signature with Gmail?
|
2010/07/16
|
[
"https://webapps.stackexchange.com/questions/3856",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/1208/"
] |
Google recently [announced](http://gmailblog.blogspot.com/2010/07/rich-text-signatures.html) support for rich text in signatures. That means you can now configure the font family, size and color, as well as insert images into the signature. Just go to your gmail settings and you'll find it right there, no need to enable as a lab feature or anything! It's possible it hasn't been expanded to Google Apps for your domain yet, in which case it should be coming pretty soon.
[](https://i.stack.imgur.com/Ce09S.png)
(source: [blogspot.com](https://4.bp.blogspot.com/_JE4qNpFW6Yk/TDYhaX9aJCI/AAAAAAAAAok/SUZMdB9N7sI/s1600/rich_text_signatures1.png))
|
682,123 |
I have an OpenVPN client on a Windows 7, that connects to an OpenVPN server with tap.
The tunnel establishes correctly.
AFAIK, tap means that my virtual adapter is 'virtually' connected to the remote LAN, gets a remote LAN ip and participate in the LAN broadcast domani and so on.
When the tunnel is established, **my virtual adapter gets the correct IP.**
**But I cannot ping the other hosts in the remote network.**
It might be a problem on the sererver side, but before checking there i've noticed something strange on the client side, in the way Windows handles the virtual interface.
Let's begin.
When the tunnel is up, the virtual interface is up too. In my routing table i can see my phisical network 192.168.2.0, infact my local IP is 192.168.2.134.
Then I can see the remote network 172.16.1.0, directly attached to my interface 172.16.1.40. So far so good.
(i've removed loopback entries)
```
0.0.0.0 0.0.0.0 192.168.2.1 192.168.2.134 25
172.16.1.0 255.255.255.0 On-link 172.16.1.40 276
172.16.1.40 255.255.255.255 On-link 172.16.1.40 276
172.16.1.255 255.255.255.255 On-link 172.16.1.40 276
192.168.2.0 255.255.255.0 On-link 192.168.2.134 281
192.168.2.134 255.255.255.255 On-link 192.168.2.134 281
192.168.2.255 255.255.255.255 On-link 192.168.2.134 281
224.0.0.0 240.0.0.0 On-link 172.16.1.40 276
224.0.0.0 240.0.0.0 On-link 192.168.2.134 281
255.255.255.255 255.255.255.255 On-link 172.16.1.40 276
255.255.255.255 255.255.255.255 On-link 192.168.2.134 281
```
Thus, clients on the remote network shouldn't be reached via gateway, but through direct routing via the virtual interface provided by openvpn.
But
when i trace the route to an host on the remote network (that my PC should see as local) my client routes it on the gateway, and obviously, get lost.
```
C:\Users\agostinox>tracert 172.16.1.17
1 1 ms 1 ms 1 ms 192.168.2.1
2 14 ms 96 ms 101 ms 192.168.1.1
3 * * * Richiesta scaduta.
4 24 ms 12 ms 12 ms 172.17.129.137
5 * * * Richiesta scaduta.
```
And here it seems that the system routes packages **straight to the gateway** as it didn't see the directly attached network adapter.
Why does this happen?
Edit 1 - details on my OpenVPN client config
============================================
```
C:\Users\agostinox>openvpn --version
OpenVPN 2.3.6 x86_64-w64-mingw32 [SSL (OpenSSL)] [LZO] [PKCS11] [IPv6] built on Mar 19 2015
library versions: OpenSSL 1.0.1m 19 Mar 2015, LZO 2.08
```
And my client config:
```
remote xxx.xxx.xxx.xxx
cipher AES-128-CBC
port 1194
proto tcp-client
dev tap
ifconfig 172.16.1.40 255.255.255.0
dev-node "Connessione alla rete locale (LAN) 3"
secret a_file_containing_my_preshared_key.key
ping 10
comp-lzo
verb 4
mute 10
```
Edit 2, details on my server configuration
==========================================
Here is the "backup" of my (pfsense) server configuration.
As you can see the configuration is at the minimum possible.
```
<openvpn>
<openvpn-server>
<vpnid>2</vpnid>
<mode>p2p_shared_key</mode>
<protocol>TCP</protocol>
<dev_mode>tap</dev_mode>
<ipaddr />
<interface>wan</interface>
<local_port>1194</local_port>
<description><![CDATA[ test tap OpenVPN server]]>
</description>
<custom_options />
<shared_key>... my shared key, omitted ...</shared_key>
<crypto>AES-128-CBC</crypto>
<engine>none</engine>
<tunnel_network />
<tunnel_networkv6 />
<remote_network />
<remote_networkv6 />
<gwredir />
<local_network />
<local_networkv6 />
<maxclients />
<compression>yes</compression>
<passtos />
<client2client />
<dynamic_ip />
<pool_enable>yes</pool_enable>
<topology_subnet />
<serverbridge_dhcp />
<serverbridge_interface />
<serverbridge_dhcp_start />
<serverbridge_dhcp_end />
<netbios_enable />
<netbios_ntype>0</netbios_ntype>
<netbios_scope />
</openvpn-server>
</openvpn>
```
Edit 3, output of ipconfig /all
===============================
When the tunnel is up, this is the output of
```
ipconfig /all
```
```
Scheda Ethernet TAP-Interface:
Suffisso DNS specifico per connessione:
Descrizione . . . . . . . . . . . . . : TAP-Windows Adapter V9
Indirizzo fisico. . . . . . . . . . . : 00-FF-7B-FB-32-C0
DHCP abilitato. . . . . . . . . . . . : Sì
Configurazione automatica abilitata : Sì
Indirizzo IPv6 locale rispetto al collegamento . : fe80::3838:3c0c:c3c6:fcca%35(Preferenziale)
Indirizzo IPv4. . . . . . . . . . . . : 172.16.1.40(Preferenziale)
Subnet mask . . . . . . . . . . . . . : 255.255.255.0
Lease ottenuto. . . . . . . . . . . . : giovedì 16 aprile 2015 09:57:32
Scadenza lease . . . . . . . . . . . : venerdì 15 aprile 2016 09:57:32
Gateway predefinito . . . . . . . . . : fe80::20c:29ff:fe92:2272%35
Server DHCP . . . . . . . . . . . . . : 172.16.1.0
IAID DHCPv6 . . . . . . . . . . . : 1107361659
DUID Client DHCPv6. . . . . . . . : 00-01-00-01-14-AE-89-EA-F0-4D-A2-63-11-97
Server DNS . . . . . . . . . . . . . : fec0:0:0:ffff::1%1
fec0:0:0:ffff::2%1
fec0:0:0:ffff::3%1
NetBIOS su TCP/IP . . . . . . . . . . : Attivato
```
|
2015/04/12
|
[
"https://serverfault.com/questions/682123",
"https://serverfault.com",
"https://serverfault.com/users/87002/"
] |
Not being too Windows savvy wrt. OpenVPN, FWIW, here is my bid on what the culprit might be here:
* Looking at the output from your Windows route command, it seems you are missing a gateway entry for the OpenVPN network. True, you have an address on the VPN net (the 172.16.1.40 address), but no gw is defined for that net. On my box, I have access to several networks, each with its own GW like so:
```
0.0.0.0 0.0.0.0 172.20.68.2 172.20.69.3 20
10.0.3.0 255.255.255.0 172.20.68.5 172.20.69.3 21
```
To fix this, open your openvpn server config and add a line like this:
```
push "route 172.16.1.0 255.255.255.0"
```
to it. This ensures that a proper route is pushed to the client whenever the connection to the server is up.
* You may also be missing the return route - sometimes (not always for reasons I don't quite get) you need to add an `iroute` to the config entry you have for a given client in the server `ccd` directory (`/etc/openvpn/ccd/<vpn>/<client-id>`). This brings up the reverse route when a client connects to the server. the contents of one of my `ccd` files looks like this:
```
iroute 192.168.87.0 255.255.255.0
```
This ensures the OpenVPN server can correctly route stuff back to the client
* I think you can also just add `iroute`s to the main server config, but then they will be defined even if the client is not connected. That would look like this:
```
route 192.168.87.0 255.255.255.0 192.168.11.1
```
* **EDIT:** Also note that running OpenVPN clients on Windows requires administrative privileges. Otherwise, OpenVPN will not be able to add routes and such (as noted in the comments to your question). Best thing is to run it as a service so connections come up automatically on boot. At least, that works out really well in my scenarios.
I think that might get you going again. OpenVPN is really great and I have used it successfully for both business and gaming purposes for some time now :-)
|
1,273 |
I can get the link to a **question** by hovering the cursor over its title. What's the smart way to get a direct link to one of the **answers**? The only way I know is to go to the user's page and hunt for it there. So I am clearly missing something.
|
2019/05/09
|
[
"https://space.meta.stackexchange.com/questions/1273",
"https://space.meta.stackexchange.com",
"https://space.meta.stackexchange.com/users/6944/"
] |
All posts (questions and answers) have a "share" link beneath them, in the same area where the "edit" link is. This brings up a pop-up with a short URL that links directly to the question or answer.
|
58,262,036 |
I'm trying to add columns (or delete them if the number is reduced) between where "ID" and "Total" are based on the cell value in B1.

How could this be done automatically every time the cell is updated?
Code I have so far
```
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("B1")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
Dim i As Integer
For i = 1 To Range("B1").Value
Columns("C:C").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Next i
End If
End Sub
```
|
2019/10/06
|
[
"https://Stackoverflow.com/questions/58262036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3573760/"
] |
There's a setting in interface builder for estimated size - set it to None.
[](https://i.stack.imgur.com/LvYQx.png)
Change to None:
[](https://i.stack.imgur.com/4kMTf.png)
|
12,531,333 |
I'm looking for a way to send a user a regular file (mp3s or pictures), and keeping count of how many times this file was accessed **without going through an HTML/PHP page**.
For example, the user will point his browser to bla.com/file.mp3 and start downloading it, while a server-side script will do something like saving data to a database.
Any idea where should I get started?
Thanks!
|
2012/09/21
|
[
"https://Stackoverflow.com/questions/12531333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1688892/"
] |
You will need to go through a php script, what you could do is rewrite the extensions you want to track, preferably at the folder level, to a php script which then does the calculations you need and serves the file to the user.
For Example:
If you want to track the /downloads/ folder you would create a rewrite on your webserver to rewrite all or just specific extensions to a php file we'll call proxy.php for this example.
An example uri would be proxy.php?file=file.mp3 the proxy.php script sanitizes the file parameter, checks if the user has permission to download if applicable, checks if the file exists, serves the file to the client and perform any operations needed on the backend like database updates etc..
|
38,449,255 |
I thought I knew a thing or two... then I met RegEx.
So what I am trying to do is a multistring negative look-ahead? Is that a thing?
Basically I want to find when a 3rd string exists BUT two precursory strings do NOT.
```
(?i:<!((yellow thing)\s(w+\s+){0,20}(blue thing))\s(\w+\s+){0,100}(green thing))
```
Target String:
* Here we have a yellow thing. Here we have a blue thing. Clearly the green thing is best though. (Should NOT match)
* You wanna buy some death sticks? I have a green thing. (MATCH)
* We are on a yellow thing submarine? Look at that green thing over there! (MATCH)
|
2016/07/19
|
[
"https://Stackoverflow.com/questions/38449255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1040450/"
] |
The error message is misleading. The problem is that the compiler has
no information what type the values `.Zero`, `.NotZero` refer to.
The problem is also unrelated to managed objects or the `valueForKey`
method, you would get the same error message for
```
func foo(value: Int) {
let eltType = value == 0 ? .Zero : .NotZero // Ambiguous reference to member '=='
// ...
}
```
The problem can be solved by specifying a fully typed value
```
let eltType = value == 0 ? MyEnum.Zero : .NotZero
```
or by providing a context from which the compiler can infer the type:
```
let eltType: MyEnum = value == 0 ? .Zero : .NotZero
```
|
375,793 |
I am studying mathematical modeling of a battery in simulink and for this it is necessary to determine some parameters. I'm stuck in the part where I need to determine an alpha parameter, which would be the relation between capacity and temperature. Not all battery manufacturers provide this parameter and would like to know with the author or how I could get to the value of it to proceed with the study of the model. Below the discussion that deals with the subject and attached the paper about it.
[](https://i.stack.imgur.com/hLorS.png)
Paper: <https://drive.google.com/file/d/1u__5DWaSZtZ60xpXi2b1eJa0bVuv8yyt/view?usp=sharing>
**UPDATE**
Looking for some manufactures data I found a data sheet with some informations I think can help me. So, with this specifications what is the value of alpha ?
[](https://i.stack.imgur.com/OEpSm.png)
|
2018/05/22
|
[
"https://electronics.stackexchange.com/questions/375793",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/186980/"
] |
Working with Li-ion or LiPo cells, I never heard of an *alpha* parameter in datasheets. But, usually you can easily find the discharge curves at various temperatures i.e. you can estimate a correlation coefficient between temperature and total capacity.
|
32,292,130 |
So I know what the `apply()` function does in javascript, but if you were to implement it on your own, how would you do that? Preferably don't use bind, since that's pretty dependent on apply.
NOTE: I'm asking out of curiosity, I don't want to actually do this.
|
2015/08/30
|
[
"https://Stackoverflow.com/questions/32292130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3082194/"
] |
You're basically asking how to apply different transformations to an array depending on the index of the specific item. With Ruby you can chain `with_index` onto enumerators and then use the index inside your enumerator block as you loop through each array item. In order to transform an array into a new one, you will need to use `map`.
```
transformed_tests = tests.map.with_index do |test, index|
if index.even?
test.upcase
else
test.downcase
end
end
```
or, a more compact version:
```
transformed_tests = tests.map.with_index do |test, index|
test.send(index.even? ? :upcase : :downcase)
end
```
If you want to make the transform whilst collecting the input:
```
tests = 5.times.map do |index|
input = gets.chomp
input.send index.even? ? :upcase : :downcase
end
```
|
63,779,680 |
I am implementing a library following a template method design pattern. It involves creating costly IO connection. To avoid any resource leaks, i want to enforce singleton instance on abstract class level. client just need to override the method which involves logic.
how can i do with kotlin?
```
abstract class SingletonConnection{
fun start(){ /* code */ }
fun connect(){ /* code */ }
abstract fun clientLogic()
}
```
If class A extends this, it should be singleton class. not allowed to initialise multiple times. how to do in kotlin?
|
2020/09/07
|
[
"https://Stackoverflow.com/questions/63779680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1554241/"
] |
Unfortunately, there is no way to enforce that only objects (singletons in Kotlin) can inherit from a certain abstract/open class or interface in Kotlin. `object` declaration is just syntactic sugar for a regular class with a Singleton pattern.
I know it's not much, but I guess you can achieve this to a certain degree by adding documentation, asking users to implement this class by Singletons alone.
By the way, I would use an interface instead of an abstract class for this purpose.
|
3,686,846 |
I have to solve this integral but I don't understand which substitution I have to use. I've tried with $\sqrt{v^2+w^2}=t$, $v^2+w^2=t$, adding and subtracting $1$ in the numerator, adding and subtracting $2w$ under square root, but no dice.
|
2020/05/22
|
[
"https://math.stackexchange.com/questions/3686846",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/518653/"
] |
we have:
$$I=\int\_0^{\sqrt{1-v^2}}\frac 1{\sqrt{v^2+w^2}}dw=\frac 1v\int\_0^{\sqrt{1-v^2}}\frac 1{\sqrt{1+(w/v)^2}}dw$$
now if we let $x=\frac wv\Rightarrow dw=vdx$ and so:
$$I=\int\_0^{\frac{\sqrt{1-v^2}}{v}}\frac 1{\sqrt{1+x^2}}dx$$
which is now a standard integral that can be computed by letting $x=\sinh(y)$ and remembering that $$\cosh^2y-\sinh^2y=1$$
|
14,112,927 |
I've got an installation of Plone 4.2.1 running nicely, but visitors to the site can click on the Users tab in the main menu and go straight to a search of all my registered users. Certainly, anonymous visitors are unable to actually list anyone, but I don't want this functionality at all.
What's the Plone way of:
* removing the Users tab from the main menu?
* stopping the URL /Members returning anything except 404?
Are there other effects of this functionality I should be aware of?
|
2013/01/01
|
[
"https://Stackoverflow.com/questions/14112927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/520763/"
] |
The `Users` tab is only shown because there is a `Members` folder (with the title `Users`) in the root that is publicly visibile.
You have three options to deal with the default; make the `Members` folder private, delete it altogether, or remove the `index_html` default view.
Unpublish
---------
You can 'unpublish', retract, the folder workflow to make it private, and anonymous users are then redirected to the login form instead of seeing the user search form:

Simply go to the folder, click on the workflow state (`Published`) and choose `Retract`.
Delete
------
If you do not need to have per-user folders, you can remove the `Members` folder altogether. You do need to make sure that user folder creation is not enabled first. Go to the Control Panel (click on your username, top right, select `Site Setup`):

select `Security`:

and make sure that `Enable User Folders` is not checked. If it is, uncheck it and save the settings.
Now just delete the `Members` folder; click `Users`, find the `Actions` menu on the right, then select `Delete`:

then confirm the deletion in the popup:

Deletion means *all* users will get a 404 when visiting `/Members` in your site.
Delete the default view
-----------------------
The `Members` folder contains a `index_html` object that provides the user form search. If all you want to get rid of is this view, you can delete it. If your `Members` folder is still public, visitors *can* see any userfolders that have been created though.
Deleting this view requires going to the ZMI, the Zope Management Interface, navigating to the `Members` folder and deleting the `index_html` object there.
Since this is not really the recommended course of action I'm leaving out the screenshots for this part.
|
11,820,142 |
>
> **Possible Duplicate:**
>
> [Android - How to determine the Absolute path for specific file from Assets?](https://stackoverflow.com/questions/4744169/android-how-to-determine-the-absolute-path-for-specific-file-from-assets)
>
>
>
I am trying to pass a file to File(String path) class. Is there a way to find absolute path of the file in assets folder and pass it to File(). I tried `file:///android_asset/myfoldername/myfilename` as path string but it didnt work. Any idea?
|
2012/08/05
|
[
"https://Stackoverflow.com/questions/11820142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/875708/"
] |
AFAIK, you can't create a `File` from an assets file because these are stored in the apk, that means there is no path to an assets folder.
But, you can try to create that `File` using a buffer and the [`AssetManager`](http://developer.android.com/reference/android/content/res/AssetManager.html) (it provides access to an application's raw asset files).
Try to do something like:
```java
AssetManager am = getAssets();
InputStream inputStream = am.open("myfoldername/myfilename");
File file = createFileFromInputStream(inputStream);
private File createFileFromInputStream(InputStream inputStream) {
try{
File f = new File(my_file_name);
OutputStream outputStream = new FileOutputStream(f);
byte buffer[] = new byte[1024];
int length = 0;
while((length=inputStream.read(buffer)) > 0) {
outputStream.write(buffer,0,length);
}
outputStream.close();
inputStream.close();
return f;
}catch (IOException e) {
//Logging exception
}
return null;
}
```
Let me know about your progress.
|
39,576,750 |
I have the following project structure `settings.gradle`:
```
include 'B'
include 'C'
rootProject.name = 'A'
```
How add gradle to subproject root project as dependency?
|
2016/09/19
|
[
"https://Stackoverflow.com/questions/39576750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6464377/"
] |
As far as the `project` method is concerned, the root project has no name. So this is the syntax in project B's build.gradle:
```
dependencies {
compile project(':')
}
```
However, it is rarely a good idea to do this. It is too easy to end up with circular dependencies. Most multi-module projects have a separate "main" projects (called something like "main", "core" or "base"), and other modules can easily depend on that using `compile project(':core')` or whatever.
|
47,636,430 |
I'm struggling to setup nginx inside a docker container. I basically have two containers:
* a php:7-apache container that serves a dynamic website, including its static contents.
* a nginx container, with a volume mounted inside it as a **/home/www-data/static-content** folder (I do this in my docker-compose.yml), to try to serve a static website (unrelated to the one served by the apache container).
I want to use the domain **dynamic.localhost** to serve my dynamic website, and **static.localhost** to serve my static website only made up of static files.
I have the following Dockerfile for my nginx container:
```
########## BASE #########
FROM nginx:stable
########## CONFIGURATION ##########
ARG DEBIAN_FRONTEND=noninteractive
ENV user www-data
COPY ./nginx.conf /etc/nginx/nginx.conf
COPY ./site.conf /etc/nginx/conf.d/default.conf
RUN touch /var/run/nginx.pid && \
chown -R ${user}:${user} /var/run/nginx.pid && \
chown -R www-data:www-data /var/cache/nginx
RUN chown -R ${user} /home/${user}/ && \
chgrp -R ${user} /home/${user}/
USER ${user}
```
As you see I'm using two configuration files for nginx: nginx.conf and site.conf.
Here is nginx.conf (it's not important because there is nothing special in it but if I'm doing something wrong just let me know):
```
worker_processes auto;
error_log /var/log/nginx/error.log debug;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
}
```
And here is the file site.conf that I have been failing miserably at writing correctly for days now:
```
server {
listen 8080;
server_name static.localhost;
root /home/www-data/static-content;
location / {
try_files $uri =404;
}
}
server {
listen 8080;
server_name dynamic.localhost;
location / {
proxy_pass http://dynamic;
proxy_redirect off;
proxy_set_header Host $host:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Port 8080;
proxy_set_header X-Forwarded-Host $host:8080;
}
}
```
(<http://dynamic> passes the request to the apache container that I name "dynamic").
So basically I keep getting 404 for whatever file I try to access in my static-content directory. E.g.:
* static.localhost:8080/index.html should serve /home/www-data/static-content/index.html but I get 404 instead.
* static.localhost:8080/css/style.css should serve /home/www-data/static-content/css/style.css but I get 404 too.
I tried various things, like writing *try\_files /home/www-data/static-content/$uri*, but I didn't get any result. I read some parts of nginx documentation and searched on Stack Overflow but nothing that I found helped me. If I made a stupid mistake I apologize, but the only thing that I care about now is to get this to work, and to understand what I'm doing wrong.
Thanks
|
2017/12/04
|
[
"https://Stackoverflow.com/questions/47636430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
It looks like you'd do well to take advantage of ImageMagick's "-gravity" setting here. This might not be exactly what you're looking for, but notice how "-gravity" works to locate the overlay image with "-composite", and the text is located with "-annotate" using a command like this...
```
convert foo.png -resize 572x572 \
-size 612x792 xc:white +swap -gravity center -composite \
-gravity north -pointsize 24 -annotate +0+100 "Title Text" laid-out.png
```
That starts by reading in "foo.png" and resizing it. Then it sets the size of the desired canvas, creates a white canvas of that size, sets the gravity to center, swaps the overlay image with the canvas to get them in the correct order, and composites "foo.png" centered on the canvas.
Then it changes the gravity setting to north, sets the pointsize of the text, and annotates the image with the text located "+0+100". That's zero pixels from center left to right, and 100 pixels down from the top.
A couple experiments should help you find settings to suit your need.
|
2,917,916 |
I was trying to use generating functions to get a closed form for the sum of first $n$ positive integers.
So far I got to $G(x) = \frac{1}{(1-x)^3}$ but I don't know how to convert this back to the coefficient on power series.
|
2018/09/15
|
[
"https://math.stackexchange.com/questions/2917916",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/525966/"
] |
You can use $\frac 1{1-x}=\sum\_{i=0}^\infty x^i$ and take two derivatives
$$\frac {d^2}{dx^2}\frac 1{1-x}=\frac 2{(1-x)^3}=\frac {d^2}{dx^2}\sum\_{i=0}^\infty x^i=\sum\_{i=0}^\infty(i+2)(i+1)x^i\\=1+3x+6x^2+10x^3+\ldots$$
which is off by $1$ in the index.
|
25,826,293 |
Why two different strings of literals can't be replaced with = operator?
i thought maybe it's because that they are an array of literals and two different arrays cant be replaced
wondered if there is another reason and if what i said is nonsense
example:
```
char s1[] = "ABCDEFG";
char s2[] = "XYZ";
s1=s2; ERROR
```
i know how to replace them but don't know why cant be replaced in that way
|
2014/09/13
|
[
"https://Stackoverflow.com/questions/25826293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3783574/"
] |
Arrays have no the assignment operator and may not be used as initializers for other arrays because they are converted to pointers to their first elements when are used in expressions.
Use standard C function `strcpy` declared in header `<cstring>` if you want "to assign" one character array to other that contain strings. For example
```
#include <cstring>
//...
char s1[] = "ABCDEFG";
char s2[] = "XYZ";
//...
std::strcpy( s1, s2 );
```
Take into account that in general case s1 must be large enough to accomodate all characters of s2 including the treminating zero.
|
33,900,657 |
I am interested to know if anyone has built a javascript websocket listener for a browser. Basically the server side of a websocket that runs in a client. This would allow messages to be sent to the client directly. Why? Because instead of having a Node.js, python, java, etc, server process sitting on or near the client/browser, I can just use a thread in the browser as a listening server thread. I don't think that any browsers support this currently.
I've run across answers like this: <https://news.ycombinator.com/item?id=2316132>
Just curious if anyone has done this. I believe that the current Websockets spec does not support listeners on the browser. It would make the deployment of various peer-to-peer applications a bit easier to deploy.
|
2015/11/24
|
[
"https://Stackoverflow.com/questions/33900657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3426462/"
] |
[WebRTC](https://webrtc.org/getting-started/overview) allows for peer-to-peer connections to be made between browsers.
You would still need a server in order for individual users to discover each other but then they could connect directly to each other rather than having to pass all their traffic via a central server.
|
45,267,955 |
```
from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup
my_url = 'http://www.csgoanalyst.win'
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
page_soup = soup(page_html, "html.parser")
page_soup.body
```
I am trying to scrape hltv.org in order to find out what maps each team bans and picks. However, I keep getting the following error:
```
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/anaconda/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/anaconda/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/anaconda/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/anaconda/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/anaconda/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/anaconda/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden
>>> page_html = uClient.read()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'uClient' is not defined
>>> uClient.close()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'uClient' is not defined
```
I tried the script on another website so I know it works. I assume hltv has blocked bots or whatever from doing this and I know I shouldn't particularly be doing it if they don't want people to but I would love to get the data.
Any help will be super helpful.
Thank you.
|
2017/07/23
|
[
"https://Stackoverflow.com/questions/45267955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8353998/"
] |
Try to remove
>
> android:fitsSystemWindows="true"
>
>
>
on your CollapsingToolbarLayout.
|
138,924 |
Anyone around coy with being Mr. Fixit? (Ms. Fixit would be even better, but either will do nicely.) I can't absorb dragon souls, and yes, I've been through almost every thread there is here on the answer. (So please, do not duplicate me. Pretty please?)
Mind you, I got a *TRUCKLOAD* of mods installed... *(ducks in preparation for the coming brick)* Odd thing is, I was playing with a very similar list before installing Dragon Combat Overhaul and Succubus Race, but deactivating either won't get me anywhere.
Done some digging on the Nexus and Steam forums... I read somewhere that No Spinning Death overwrites a script related to dragon death. It *might* be mucking up things some, but I can't tell. Disabling that mod didn't get me anywhere, but scripts are baked into saves (right?), so in theory I have to *(cringes)* restart the game to be absolutely sure...
Other bits worth (?) knowing:
* Running SKSE
* Running ENB
* Using ModOrganizer
UPDATE: There is something seriously broken with my game itself. Tried the following:
* Disabled ALL the mods, save for Alternate Start for quicker starts (and yes, this includes USKP, UDGP and UDBP)
* Started a new game, created a vanilla Nord character
* Toggled godmode on
* Given the PC Lightning Storm
* Spawned Mirmulnir
* Turned the overgrown lizard into charred meat
And STILL I'm not absorbing its soul!
UPDATE 2: Verifying the game cache integrity turned up 3 corrupted files. Wish I knew which those were, but I had cleaned my master files using TES5Edit, so I thought I had screwed up something there. Created a new barebones game, and at last, I'm having some dragon spirit chow. Then, created a new fully modded game, and no soul chow for me... For a moment I wanted to pin the blame on TES5Edit but now I know that's not the cause. The culprit's still at large.
UPDATE 3: After having no luck with a fully modded game, started to gradually activate mods again... eventually I realized that the truckload of mods I had activated on my previous attempt broke something **again** on my vanilla installation, for even another barebones try was plagued with this issue. Re-check integrity, and bam, another file -a very small one, not even 1k in size- was corrupted. (Again, I wish there was a way to know which!)
UPDATE 4: Tried a new game with just these on:
* USKP
* UDGP
* UDBP
* Alternate Start
Guess what. AGAIN the corrupted file issue.
Tried again with only Alternate Start active, and still cannot absorb dragon souls. Even while today I could on a similar setup. (I don't understand anything anymore here...) Anyone knows of a way to skip the intro without installing this mod?
(Could it be that ModOrganizer is somehow mucking things up?)
UPDATE 5: *Probably* ModOrganizer has something to do with this. However insane it sounds. Instead of manually disabling ESPs, I right-clicked on the mod list, selected 'Disable all visible mods', manually re-activated Alternate Start, and *this time* I could dine on dragon essence. Read again: a near-completely barebones setup, without even the unofficial patches.
UPDATE 6: Disregard what I said about MO screwing up things. One of the unofficial patches is misbehaving. Even with a truckload of mods on, I can still eat dragonstuff--right until activating all three of them. Which one is to blame I don't yet know.
**UPDATE 7 AND FINAL:** Finally, finally figured what's going on.
USKP has a problem with the dragonactorscript.pex file.
Found and installed a fix available here: <http://www.nexusmods.com/skyrim/mods/31685>
Personally, I went and overwrote the file from USKP itself instead of treating this fix as a separate mod, keeping a backup available just in case.
|
2013/11/06
|
[
"https://gaming.stackexchange.com/questions/138924",
"https://gaming.stackexchange.com",
"https://gaming.stackexchange.com/users/59017/"
] |
Make sure that the mods' load order is correct (as explained in an [answer by DouglasLeeder](https://gaming.stackexchange.com/a/138952/4797)). If you're unsure on how to do this, just let [BOSS](https://github.com/boss-developers/boss/releases/) take care of the mods' load order. BOSS has a database of mods and their proper load order, and can automatically decide optimal load order of mods, provided they are listed in that database.
Also, see the troubleshooting steps for the 'cannot absorb dragon souls' issue listed at the [Unofficial Dragonborn Patch Nexus forums sticky post by Arthmoor](http://forums.nexusmods.com/index.php?/topic/907274-unofficial-dragonborn-patch/page-169#entry8357442), one of the UDGP developers:
>
> Check for: `dragonactorscript.pex` and/or `mqkilldragonscript.pex`. Remove them if present. They are from dragon mods that came as loose files.
>
>
> DSAMG - Dragon Soul Absorb More Glorious, and Diversified Dragons are known to cause this. Those mods need to be updated with a Dragonborn patch that incorporates the fixes from the UDBP.
>
>
> [Skyrim Unbound](http://steamcommunity.com/sharedfiles/filedetails/?id=16937212) will cause this as well due to the script being unaware of the changes for Dragonborn.
>
>
> Others may be a factor as well.
>
>
> Note too that the offending mod may have the script packaged inside a BSA. That will need to be handled by that mod's author.
>
>
> If you are using Mod Organizer and are here to report issues with dragon souls, sorry, but you're on your own as we do not support issues caused by incorrectly letting that program modify the BSA load order system the game has. Your post is likely to just be ignored. We don't have time to keep fending off false bug reports caused by people who insist on unpacking their BSA files using the program and thus subverting the entire system the game relies on for proper behavior.
>
>
>
---
>
> ...scripts are baked into saves (right?), so in theory I have to (cringes) restart the game to be absolutely sure...
>
>
>
Yes, scripts are baked into saves. However, there is a way to remove scripts left by uninstalled mods in savefiles. You need to configure [Skyrim Script Extender (SKSE)](http://skse.silverlock.org/) to use its `ClearInvalidRegistrations` console command. It removes invalid scripts left running by uninstalled mods. This feature was introduced in [v1.6.7 of SKSE](http://skse.silverlock.org/skse_whatsnew.txt):
>
> add console command `ClearInvalidRegistrations` to remove invalid
> OnUpdate() registrations
>
>
> This prevents orphaned OnUpdate() events and
> the resulting bloated/broken saves when removing certain mods. When
> applied to an already bloated save, it will stop growing further and
> instead shrink over time as the game processes all queued events. This
> may take hours depending on the amount of bloat.
>
>
> To execute automatically after each reload, add this to `\Data\SKSE\skse.ini`:
>
>
> `[General]`
>
> `ClearInvalidRegistrations=1`
>
>
>
Use the skse.ini method to automatically remove invalid scripts left by uninstalled mods.
>
> I read somewhere that No Spinning Death overwrites a script related to dragon death. It might be mucking up things some, but I can't tell.
>
>
>
After configuring SKSE to use the `ClearInvalidRegistrations` command, try uninstalling the 'No Spinning Death' mod and then see if the issue is fixed. Otherwise, you'll have to disable half your mods and then test again. Rinse and repeat until you find the offending mod.
|
58,197,804 |
I have recently started using Ant Deisgn and really enjoyed working with it.
However I seem to have stumble upon an issue that I am having a hard time solving.
Using react-testing-library for tests, I am having troubles with testing some Ant Design component.
One of the reason is that for some unknown reason some components (e.g. Menu, Menu.Item, Dropdown, etc) do not render the custom attribute `data-testid` thus making impossible to target a specific element of the DOM.
This makes the tests less performant and accurate.
Did some else stumble upon the same issue ?
How did you go about solving this ?
Is there something that can be done by the Ant Design team about this issue ?
|
2019/10/02
|
[
"https://Stackoverflow.com/questions/58197804",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/909822/"
] |
The `data-testid` attribute is configurable to whatever attribute you want.
<https://testing-library.com/docs/dom-testing-library/api-configuration>
Also, as long as the library you choose, has ID attribute, you çan do following :
```js
const {container} = render(<Foo />) ;
const button = container.querySelector('#idValue'); // returns react element
fireEvent.click(button);
```
P. S: mobile edit. Pls ignore formats
|
71,841,110 |
I created my page routing with react-router v5 and everything works well. If I click on the link, it takes me to the page, but when I reload the page I get a "404 | Page Not Found" error on the page.
```
import React, { useEffect, useState } from 'react'
import Home from './dexpages/Home'
import {
BrowserRouter,
Routes,
Route
} from "react-router-dom";
import Dashboard from './dexpages/dashboard';
import Swapping from './dexpages/swapping'
import Send from './dexpages/send';
import Airdrops from './dexpages/airdrops'
function Main() {
const [mounted, setMounted] = useState(false)
useEffect(() => {
if (typeof window !== "undefined") {
setMounted(true)
}
}, [])
return (
<>
{mounted &&
<BrowserRouter>
<div className="min-h-screen" style={{ overflowX: 'hidden' }}>
<Routes>
<Route path="/airdrops" element={<Airdrops />} />
<Route path="/send" element={<Send />} />
<Route path="/swap" element={<Swapping />} />
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/" element={<Home />} />
</Routes>
</div>
</BrowserRouter>
}
</>
)
}
export default Main;
```
This is my Main Component where I create all the routing.
[This is the error I'm getting when I reload the page](https://i.stack.imgur.com/zGX9p.png)
|
2022/04/12
|
[
"https://Stackoverflow.com/questions/71841110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11185816/"
] |
Don't use React Router with next.js.
[Next.js has its own routing mechanism](https://nextjs.org/docs/basic-features/pages) which is used for both client-side routing and server-side routing.
By using React Router, you're bypassing that with your own client-side routing so when you request the page directly (and depend on server-side routing) you get a 404 Not Found.
Next.js has [a migration guide](https://nextjs.org/docs/migrating/from-react-router).
|
54,244,797 |
I am trying to perform a CountIfs function where two criteria are met. First a line is "Approved" and second the Appv Date is within the reporting month. The CountIfs works find when only the first criteria exists but when I add the second I get a Type Mismatch error and I am not sure why.
Code:
```
' Declarations
Dim sRoutine As String 'Routine’s Name
Dim lngStatus As Long
Dim lngLastRow As Long
Dim intRptMnth As Integer
Dim intRptYr As Integer
Dim lngAppvDate As Long
' Initialize Variables
lngLastRow = FindLastRow(strPSR_File, strCCL, 1)
lngStatus = Worksheets(strCCL).Range(FindLoc(strPSR_File, strCCL,"status")).Column
lngAppvDate = Worksheets(strCCL).Range(FindLoc(strPSR_File, strCCL,"Approved Date")).Column
intRptMnth = CInt(CalcRptMnthNum)
intRptYr = CalcRptYr
' Procedure
With Worksheets(strCCL)
CalcPCR_MTD_Cnt = Application.WorksheetFunction.CountIfs( _
Worksheets(strCCL).Range(Cells(2, lngStatus), Cells(lngLastRow,
lngStatus)), _
"=Approved", _
'********ERRORS HERE*****
Month(Worksheets(strCCL).Range("n2:n3")), _
intRptMnth)
'************************
End With
```
|
2019/01/17
|
[
"https://Stackoverflow.com/questions/54244797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10344640/"
] |
You can grab the selected item using `lb2.SelectedItem` and split it as you are doing, then take the rest of the items (filtering out the item with an index of `lb2.SelectedIndex` by using a `Where` clause) and then do a `SelectMany` on the results, splitting each on a space character:
```
var nonSelected = lb2.Items.OfType<string>()
.Where((item, index) => index != lb2.SelectedIndex);
var first = lb2.SelectedItem.ToString().Split(' ');
var rest = nonSelected.SelectMany(others => others.Split(' ')).ToArray();
```
|
69,113,035 |
I have the following data:
```
data_list = ["\"TOTO TITI TATA,TAGADA\"", "\"\"\"TUTU,ROOT\"\"\""]
```
It is transformed into a pandas dataframe:
```
df = pandas.DataFrame(data_list)
print(df)
0
0 "TOTO TITI TATA,TAGADA"
1 """TUTU,ROOT""
```
When writing the dataframe as a csv, without any quoting configuration, I get the following result:
```
with open("test_quote_normal", "w") as w:
df.to_csv(w, index=False, header=False)
```
-> result output
```
"""TOTO TITI TATA,TAGADA"""
"""""""TUTU,ROOT"""""""
```
Every quotes have been quoted, which is not something I want.
So i tried to prevent this with the following configuration:
```
with open("test_quote_none", "w") as w:
df.to_csv(w, index=False, header=False,
quoting=csv.QUOTE_NONE, escapechar=',')
```
-> result output
```
"TOTO TITI TATA,,TAGADA"
"""TUTU,,ROOT"""
```
The quotes are correct, but for a reason I do not understand, the escape char has been inserted in the data itself.
Specifying the sep value has no effect:
```
with open("test_quote_none", "w") as w:
df.to_csv(w, index=False, header=False,
quoting=csv.QUOTE_NONE, escapechar=',', sep= ",")
```
Why does pandas inserts the escape char in the data ?
|
2021/09/09
|
[
"https://Stackoverflow.com/questions/69113035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6213883/"
] |
`"` and `,` are both special characters by default in csv format
`"` is used when `,` is there between a data. That time the data is escaped by quotes to tell that it should be a single data.
whereas, `,` is the default seperator for distinguishing between data.
Since you are using both of them in your data, that's why you are having such a hard time debugging it
**First snippet**
```
with open("test_quote_normal", "w") as w:
df.to_csv(w, index=False, header=False)
```
If the data still has `"`, as per csv conventions, it should also be escaped which was causing multiple `"` in your first scenario
**Second snippet**
```
with open("test_quote_none", "w") as w:
df.to_csv(w, index=False, header=False,
quoting=csv.QUOTE_NONE, escapechar=',')
```
Using the `quoting` parameter, you are telling that you don't indent quotes to protect the `,` character. So the `,` inside your data is being treated as a separator causing the escape character to come between them
For more clarity, you can see the output of these snippets
```
with open("temp.csv", "w") as w:
...: df.to_csv(w, index=False, header=False, quotechar='@')
```
Output
```
@"TOTO TITI TATA,TAGADA"@
@"""TUTU,ROOT"""@
```
In this, we are changing the `quotechar` to become `@`, that's why, instead of using `"` for protecting `,`, this time `@` is being used to escape data with `,` inside them
```
with open("temp.csv", "w") as w:
...: df.to_csv(w, index=False, header=False, escapechar='@', doublequote=False)
```
Output
```
"@"TOTO TITI TATA,TAGADA@""
"@"@"@"TUTU,ROOT@"@"@""
```
In this, the quotechar is still the same, but for escaping them, we are changing it to `@` for clarity, this time you can see the difference on `quotechar` and `escapechar`
I hope this helps your question
|
5,634,845 |
When i implement dealloc method i used to write:
```
[preopertyX release];
```
Today i found this code:
```
[self.propertyX release];
```
I'm not sure that this method is completely correct. What do you think about ?
(we can take as assumption that propertyX is a retained and synthesized property).
|
2011/04/12
|
[
"https://Stackoverflow.com/questions/5634845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/499990/"
] |
You can write [self.propertyX release] if you have set propertyX retained and synthesized otherwise not
|
50,917,419 |
I'd like to send request using python and requests library.
I have checked this request in web browser inspector and form data looks like that:
```
data[foo]: bar
data[numbers][]: 1
data[numbers][]: 2
data[numbers][]: 3
data[numbers][]: 4
data[numbers][]: 5
csrf_hash: 12345
```
This is my code:
```
payload = {'data[foo]': 'bar', 'csrf_hash': 12345,
'data[numbers]': [1, 2, 3, 4, 5]}
r = s.post('https://www.foo.com/bar/', payload)
```
It doesn't work. I'm getting error because of invalid post data
|
2018/06/18
|
[
"https://Stackoverflow.com/questions/50917419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5369663/"
] |
I resolve problem with this code:
```
payload = {'data[foo]': 'bar', 'csrf_hash': 12345,
'data[numbers][0]': 1, 'data[numbers][1]': 2, 'data[numbers][2]': 3, 'data[numbers][3]': 4, 'data[numbers][4]': 5}
r = s.post('https://www.foo.com/bar/', payload)
```
It's not very beautiful, but works.
|
6,024,494 |
So I'd like to have a gradient that fills 100% of the background of a webpage. For browsers that can't handle it, a solid color is fine.
here is my current css:
```
html {
height: 100%;
}
body {
height: 100%;
margin: 0;
padding: 0;
background-repeat: no-repeat;
background: #afb1b4; /* Old browsers */
background: -moz-linear-gradient(top, #afb1b4 0%, #696a6d 100%) no-repeat; /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#afb1b4), color-stop(100%,#696a6d)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #afb1b4 0%,#696a6d 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #afb1b4 0%,#696a6d 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #afb1b4 0%,#696a6d 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#AFB1B4', endColorstr='#696A6D',GradientType=0 ); /* IE6-9 */
background: linear-gradient(top, #afb1b4 0%,#696a6d 100%); /* W3C */
}
```
It seemed to work out while the page had little content, but as I've filled out the page with more content, navigation, etcetera, there is now some white at the bottom. maybe 100px or so. Am I doing this wrong? Do I need to be offsetting some padding somewhere?
|
2011/05/16
|
[
"https://Stackoverflow.com/questions/6024494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/412485/"
] |
Get rid of your `height: 100%` declarations. It seems like setting the height to 100% just sets it to 100% of the viewport, not actually 100% of the page itself.
|
56,447,602 |
I have a batch file and I want to call a powershell script that returns several values to the batch file.
I've tried to do it by setting environment variables, but that does not work.
This is the batch file:
```
::C:\temp\TestPScall.bat
@echo off
powershell -executionpolicy Bypass -file "c:\temp\PStest.ps1"
@echo [%psreturncode%]
@echo [%uservar%]
@echo [%processvar%]
```
This is the powershell script:
```
# c:\temp\PStest.ps1
$env:psreturncode = "9990"
[Environment]::SetEnvironmentVariable("UserVar", "Test value.", "User")
[Environment]::SetEnvironmentVariable("ProcessVar", "Test value.", "Process")
```
WHen I run it, the environment variables are not populated.
How can I get this to work?
|
2019/06/04
|
[
"https://Stackoverflow.com/questions/56447602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10161783/"
] |
You don't need an else on the statement. check to see if your variable is false and if it is it will return if not the rest of your function will run automatically.
```
function function1() {
function2(); // call function2
// after called function (here I need true or false, to decide if the function should stop or continue)
}
function function2() {
if (condition === false) {
return;
}
```
}
|
6,403,038 |
I have an array called followers and I would like to know how I could get the objectAtIndex $a of the array in PHP.
My current code is this, but it doesn't work:
```
$followers = anArray....
$returns = array();
for ($a = 1; $a <= $numberOfFollowers; $a++) {
$follower = $followers[$a];
echo $follower;
$query = mysql_query("query....");
if (!$query) {}
while ($row = mysql_fetch_assoc($query)) {
}
}
```
edit--- This is how I get the followers:
```
$followers = array();
while ($row = mysql_fetch_array($querys)) {
$followers[] = $row['followingUserID'];
}
$numberOfFollowers = count($followers);
```
|
2011/06/19
|
[
"https://Stackoverflow.com/questions/6403038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/804782/"
] |
Why not do a `foreach()`, like this?
```
$followers = array();
$returns = array();
foreach($followers as $index => $follower){
echo $follower;
$query = mysql_query("query....");
if (!$query) {}
while ($row = mysql_fetch_assoc($query)) {
}
}
```
I don't know what you are cooking with this, but to me, this is a huge cannon shooting towards the DB. Try to optimize your queries into a single one. Don't ever imagine DB fetches with a loop in your mind.
|
71,332,057 |
I'm new to react native and I'm not able to consume this api, when I start this app in the browser, it works fine, but when I go to the expo app it doesn't display the pokemon image, could someone help me?
```tsx
import { StatusBar } from 'expo-status-bar';
import React, { useEffect, useState } from 'react';
import { StyleSheet, Text, View, Button, Alert, TextInput, Image } from 'react-native';
interface PokeInterface {
sprites : {
back_default : string;
}
}
export default function App() {
const [text, setText] = useState<string>("")
const [response, setResponse] = useState<PokeInterface | any>()
const [image, setImage] = useState<string>()
const handleText = (text : string) => {
setText(text)
}
const searchApi = (pokemonName : string) => {
fetch(`https://pokeapi.co/api/v2/pokemon/${pokemonName}/`, { method: 'GET'})
.then((response) => response.json())
.then((response) => setResponse(response))
}
useEffect(() => {
if(text){
searchApi(text)
}
if(response){
const {sprites} = response
setImage(sprites.front_default)
}
return () => {
if(image){
setImage("")
}
}
},[text, response])
return (
<View style={styles.container}>
<View style={styles.topbar}>
<Text style={styles.title}>Pokedex Mobile</Text>
<TextInput
style={styles.input}
onChangeText={(value: any) => handleText(value)}
value={text}
placeholder="Search Pokemon"
keyboardType="default"
/>
<Text style={styles.text}>{text}</Text>
</View>
{image && (
<Image
style={styles.logo}
source={{uri : `${image}`}}
/>
)}
</View>
);
}
const styles = StyleSheet.create({
text : {
fontSize: 30,
color : "red"
},
input: {
height: 40,
margin: 12,
borderWidth: 1,
padding: 10,
},
container : {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
},
title: {
fontSize: 30,
color: '#000'
},
topbar: {
},
logo : {
width: 200,
height: 200
}
});
```
|
2022/03/03
|
[
"https://Stackoverflow.com/questions/71332057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13966942/"
] |
On MySQL, you could use aggregation:
```sql
SELECT id
FROM yourTable
GROUP BY id
HAVING SUM(name = 'Gaurav') = COUNT(*);
```
On all databases:
```sql
SELECT id
FROM yourTable
GROUP BY id
HAVING COUNT(CASE WHEN name = 'Gaurav' THEN 1 END) = COUNT(*);
```
|
22,198,001 |
I'm using Qt Creator running with the mingw C++ compiler to compile some C sources I obtained from an institution known as the NBIS.
I'm trying to extract just the code that will allow me to decode images encoded in the WSQ image format.
Unfortunately I'm getting messages that I have "multiple definitions" of certain functions
which is contradicted by a grep search, as well as complaints of undefined functions which are indeed defined in a single C file in each case.
I looked at the include files and these functions do have the word extern before them in the declarations.
As for the error messages of "multiple definitions" the linker says "first defined here" and only gives one object file in each case.
All C files have a C extension.
I should add that I'm getting strange messages when I look at the compiler outout like this:
Makefile.Debug:427: warning: overriding recipe for target 'debug/huff.o'
(it is true that I have two files called huff.c,but in different directories)
|
2014/03/05
|
[
"https://Stackoverflow.com/questions/22198001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1741137/"
] |
There's no automatic function that I know, but it can be easily done manually.
1. Remove `Pods` folder near your `Podfile`
2. Remove next files: `Podfile` and `Podfile.lock`
3. Remove generated `<Project_Name>.workspace` file
4. Open your `xcodeproj` file and in `Xcode`:
* Remove reference to `Pods-<YOUR_TARGET>.xcconfig` file at the end of root folder 
* Open project setting and choose `Build Phases` tab in your target setting:
Remove here two phases: `Check Pods Manifest.lock` and `Copy Pods Resources`
* Open 'Build Phases' - > `Link Binary With Libraries` and remove all links that starts from `libPods...` 
* Switch to project settings and deselect (must be `None` everywhere if you haven't created before) configuration sets if there are any at `Info` tab.
|
206,579 |
Bits Back coding is a scheme to transmit an observation $x$.
You can read about it [here](http://www.cs.toronto.edu/~fritz/absps/freybitsback.pdf)[1]. To my understanding, it works like this:
1. The encoder samples a message $z$ from a distribution $Q(z|x)$ that it computed.
2. The encoder sends $z$ to decoder, using a code based on $P(z)$, known to both.
3. The decoder recovers $z$ and computes $P(x|z)$.
4. The encoder sends $x$ to the decoder using a code based on $P(x|z)$.
5. The decoder recovers $x$.
In reality, the messages in steps 2 and 4 can be combined. Naively, the cost of this protocol would be the expected number of bits in these messages.
However, the trick is that once the decoder recovered $x$, it can compute $Q(z|x)$ using the same algorithm the encoder used, and then recover all the auxiliary bits it had to use internally in order to sample $z$ from $Q$. The expected number of these bits is then subtracted from the total cost. Those are "the bits you get back".
What I don't understand is what is the decoder going to do with these bits? How does knowing these bits reduces the overall transmission cost? Yes, the decoder is now aware of some bits that the encoder withdrew from a random-stream of bits, but how is this knowledge going to help in compressing the next observations?
[1]: [Frey and Hinton. Efficient Stochastic Source Coding and an Application to a Bayesian Network Source Model](http://www.cs.toronto.edu/~fritz/absps/freybitsback.pdf)
|
2015/05/14
|
[
"https://mathoverflow.net/questions/206579",
"https://mathoverflow.net",
"https://mathoverflow.net/users/2873/"
] |
I was wondering the same! But this is the answer I came up with (although I am not entirely sure if this reasoning is correct).
Since after the decoding process the decoder knows the distribution $Q(z|x)$ AND $P(x)$, he could then come up with an encoding that follows the distribution $P(z)/Q(z|x)$ and thus, represents each sample value $z$ with $-log\_2(P(z)/Q(z|x))$ bits. Apparently, this representation of the sample values (and thus, of the model) would lead to maximal compression of the data values if the approximate variational posterior equals the actual posterior, thus $Q(z|x) = P(z|x)$.
|
35,048,571 |
Hey all I am trying to get the previous button so that I can change its text to something else once someone selects a value from a select box.
```
<div class="input-group">
<div class="input-group-btn search-panel">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span id="search_concept">Type</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu" id="dd1" role="menu">
<li><a href="#" data-info="blah1">For Sale</a></li>
<li><a href="#" data-info="blah1">Wanted</a></li>
</ul>
</div>
<div class="input-group-btn search-panel">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span id="search_concept">Location</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu" id="dd2" role="menu">
<li><a href="#" data-info="somewhere">Somewhere</a></li>
<li><a href="#" data-info="elsewhere">Elsewhere</a></li>
</ul>
</div>
<input type="text" class="form-control" name="x" placeholder="Search term...">
</div>
$('.search-panel #dd1, .search-panel #dd2').find('a').click(function(e) {
e.preventDefault();
var param = $(this).data("info");
$(this).prev().find('#search_concept').text($(this).text());
});
```
So the click event starts from **THIS** which is the **a href="#" data-info="blah1">[value here]< /a>** tag. So I am trying to go back to the **< button>** tag so that I can change the text **Type** to whatever was selected.
I've tried:
```
$(this).prev().find('#search_concept').text($(this).text());
and
$(this).prev().prev().find('#search_concept').text($(this).text());
and
$(this).prev().prev().children().find('#search_concept').text($(this).text());
and
$(this).prev().children().find('#search_concept').text($(this).text());
```
And I can't seem to find it....
**fixed**
```
$('.search-panel #dd1, .search-panel #dd2').find('a').click(function(e) {
e.preventDefault();
var param = $(this).data("info");
$(this).parents('.search-panel').find('button').html($(this).text() + ' <span class="caret"></span>');
});
```
|
2016/01/27
|
[
"https://Stackoverflow.com/questions/35048571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/277480/"
] |
After installing the latest preview release, v0.6.5.0 as of writing this, I ran into the same issue. It appears that Xamarin Android Player is expecting VirtualBox to be registered with the `%PATH%` environment variable, but it doesn't happen during the install process by default.
In this case, you just add `C:\Program Files\Oracle\VirtualBox` to PATH and you should be able to restart the Android Player just fine to begin downloading emulator images.
Here is a command-line approach to append this location to the existing PATH variable.
```
setx PATH "%PATH%;C:\Program Files\Oracle\VirtualBox"
```
You can also do the same edit through the Environment Variables screen found under the System Properties screen.
|
308,895 |
I'm trying to plot the Wien and Rayleigh-Jeans laws in a graph of `$I \times \nu$`.
```
Wien Law:
\[ I=\frac{2h\nu^3}{c^2}e^{-\textstyle\frac{h\nu}{kT}}\]
Rayleigh-Jeans Law:
\[I=\frac{2k\nu^2T}{c^2}\]
```
But PGFPlot always crashes because the constants (in SI units) are way too small!
Whats the best way to do this?
Thanks!
Edit: My actual code with just Wien's Law is:
```
\begin{tikzpicture}
\begin{axis}[
axis lines = left,
xlabel = $\nu$,
ylabel = {$I(\nu,T)$ em $T=8.10^{-3}K$},
]
\addplot [
domain=0:10,
samples=100,
color=red,
]
{(1.48*10^(-50))*(x^3)*exp((-6*10^(-9))x)};
\addlegendentry{Lei de Wien}
\end{axis}
\end{tikzpicture}
```
I don't know what the best domain is.
|
2016/05/10
|
[
"https://tex.stackexchange.com/questions/308895",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/102658/"
] |
```
\documentclass{article}
\newcounter{emphlevel}
\renewcommand\emph[1]{\stepcounter{emphlevel}%
\ifnum\value{emphlevel}=1`#1'\else
\ifnum\value{emphlevel}=2\textsc{#1}\else
\ifnum\value{emphlevel}=3\textit{#1}\else
\fi\fi\fi\addtocounter{emphlevel}{-1}%
}
\begin{document}
\emph{Single quotes within \emph{Small Caps within \emph{more italics} and} so on}.
\end{document}
```
[](https://i.stack.imgur.com/it5wB.jpg)
The above ORIGINAL answer truncates levels beyond the third. This below variation repeats the cycles repeatedly through the specified emphases.
```
\documentclass{article}
\newcounter{emphlevel}
\renewcommand\emph[1]{\stepcounter{emphlevel}%
\ifnum\value{emphlevel}=1\textup{`#1'}\else
\ifnum\value{emphlevel}=2\textsc{#1}\else
\ifnum\value{emphlevel}=3\textit{#1}\else
\addtocounter{emphlevel}{-4}\emph{#1}\addtocounter{emphlevel}{4}%
\fi\fi\fi\addtocounter{emphlevel}{-1}%
}
\begin{document}
\emph{Single quotes within \emph{Small Caps within \emph{more italics
within \emph{Single quotes within \emph{Small Caps within \emph{more italics}
and} so on}} and} so on}.
\emph{Aa \emph{Bb \emph{Cc \emph{Dd \emph{Ee \emph{Ff \emph{Gg}}}}}}}
\end{document}
```
[](https://i.stack.imgur.com/yl5Ai.jpg)
|
445,848 |
About changing lightdm unity greeter background image, most answers are to change /usr/share/glib2.0/schemas/com.canonical.unity-greeter.gschema.xml. Is there any way to change the default wallpaper in lightdm unity greeter without changing the file? Like an override file.
I'm making a debian package that would apply our own artwork after installing. I can't changing the file content in my maintainer script, which would violate debian packaging policy. I can change the unity desktop background by adding a schema override file in the same folder, but I couldn't find a way to change the lightdm background with similar way.
|
2014/04/10
|
[
"https://askubuntu.com/questions/445848",
"https://askubuntu.com",
"https://askubuntu.com/users/172185/"
] |
Look in master.cf for a transport named "f" there must be a typo there.
The master.cf you pasted don't have it tho. Have you pasted the right one?
|
55,135,777 |
Can anybody help in knowing whether IFC entity type names are case sensitive or case insensitive.
For example: Can we replace `IFCPERSON` with `IfcPerson` (camel case) or `ifcperson` (small) in an \*.ifc file?
|
2019/03/13
|
[
"https://Stackoverflow.com/questions/55135777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11195292/"
] |
How about applying the following convention in every single context:
Simply assume that they are case sensitive and work accordingly.
If you always do that, you will never have a problem.
If you see different casing examples, and all of them work, you can assume it is not case sensitive.
Otherwise, you will always be on the safe side if you simply follow the case conventions that you see and are proven.
Furthermore, you should always implement unit tests for every piece of functionality.
If you have questions about case sensitivity, implement unit tests to prove your assumptions right.
|
41,535,837 |
I want to build a website that allows the user to convert `Hz` to `bpm` (note however that my question concerns all sort of unit conversion). I am using PHP and am hosting my website on Apache.
So, I was wondering if it was possible to "bind" an input field to an HTML element, like we do in WPF developement where you can bind an input area to a WPF element, and apply some sort of data conversion so if the user types `12 bpm`, the bound element will automaticly and immediately display `0.2 Hz`. If the user then adds a "0" so `120 bpm` will be automaticly and immediately converted to `2 Hz`.
The effect I am trying to describe can also be noted on this very forum : as I type my question, I can see a "real-time" final version of my text.
How is this achieved? Is there any way to do it with PHP? I know of AJAX but I would really prefer to avoid using Javascript to hold my math functions. Correct me if I am wrong but I think this could be accomplished with Node.js? Should I consider migrating to Node?
|
2017/01/08
|
[
"https://Stackoverflow.com/questions/41535837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6622623/"
] |
With just the DOM and JavaScript, you can use the [`input` event](https://developer.mozilla.org/en-US/docs/Web/Events/input) on a text field to receive an immediate callback when its value changes as the result of user action:
```
document.querySelector("selector-for-the-field").addEventListener("input", function() {
// Code here to do and display conversion
}, false);
```
Example (centigrade/Celsuis to Fahrenheit):
```js
var f = document.getElementById("f");
document.querySelector("#c").addEventListener("input", function() {
var value = +this.value;
if (!isNaN(value)) {
value = (value * 9) / 5 + 32;
f.innerHTML = value;
}
}, false);
```
```html
<div>
<label>
Enter centigrade:
<input type="text" id="c">
</label>
</div>
<div>
Fahrenheit: <span id="f"></span>
</div>
```
Stepping back, yes, there are dozens of libraries and frameworks that provide MVC/MVVM/MVM/whatever-the-acronym-is-this-week in the browser. A short list of current popular ones: React, Angular, Vue, Knockout, ... Note that these are not magic, they're just code written in JavaScript (or something like TypeScript or Dart or CoffeeScript that compiles to JavaScript) that use the DOM the covers.
|
45,933,651 |
I have a column named ***weight*** in my table **accounts**. i need to fetch the values from this column like,
when the user clicks weight from 40 - 100, It need to display all the persons with weight in between 40 and 100.
This is my html code,
```
<div class="float-right span35">
<form class="list-wrapper search-form" method="get" action="{{CONFIG_SITE_URL}}/index.php">
<div class="list-header">
Talent Search
</div>
<h4 style="margin-left: 10px; color: gray;">Weight</h4>
<fieldset id="weight">
<input type="checkbox" name="weight" value="1" {{WEIGHT_1}}/>Below 40<br>
<input type="checkbox" name="weight" value="2" {{WEIGHT_2}}/>40-70<br>
<input type="checkbox" name="weight" value="3" {{WEIGHT_3}}/>70-100<br>
<input type="checkbox" name="weight" value="4" {{WEIGHT_4}}/>Above 100<br>
</fieldset>
<br/>
<input style="margin-left: 10px" type="submit" name="submit" value="search"/><br><br>
<input type="hidden" name="tab1" value="search">
</form>
</div>
```
This is my php code,
```
if(isset($_GET['submit'])){
$weight = ($_GET['weight'])? $escapeObj->stringEscape($_GET['weight']): NULL;
$sql = "SELECT id FROM `".DB_ACCOUNTS."` WHERE `id` IS NOT NULL ";
if(is_numeric($weight) && $weight != NULL){
$sql .= "AND `weight` IN (".$weight.")";
$is_weight = true;
}
$sql .= " ORDER BY `id` ASC";
}
if($is_weight){
$themeData['weight_'.$weight] = 'checked';
}
$query = $conn->query($sql);
if($query->num_rows > 0){
while($fetch = $query->fetch_array(MYSQLI_ASSOC)){
$get[] = $fetch['id'];
}
$i = 0;
$listResults = '';
$themeData['page_title'] = "Advanced Search - ".$lang['search_result_header_label'];
foreach($get as $row){
$timelineObj = new \SocialKit\User();
$timelineObj->setId($row);
$timeline = $timelineObj->getRows();
$themeData['list_search_id'] = $timeline['id'];
$themeData['list_search_url'] = $timeline['url'];
$themeData['list_search_username'] = $timeline['username'];
$themeData['list_search_name'] = $timeline['name'];
$themeData['list_search_thumbnail_url'] = $timeline['thumbnail_url'];
$themeData['list_search_button'] = $timelineObj->getFollowButton();
$listResults .= \SocialKit\UI::view('search/list-each');
$i++;
}
$themeData['list_search_results'] = $listResults;
}
}
```
This code is almost working for an single weight from table. But I need to create a range in between the checkbox values as i mentioned in the code. Do i need to update the code.
|
2017/08/29
|
[
"https://Stackoverflow.com/questions/45933651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7057771/"
] |
Simpliest way: administrator credentials should be predefined via some config file on server side. As additional protection you may force user to change password on first log in. Another way: a lot of CMS provides a full access + installation steps to first loggined user.
|
81,961 |
I'm trying to attach programmatically an Image with caption to my node.
I'm using [image\_field\_caption](https://drupal.org/project/image_field_caption) module.
```
$node = node_load($nid);
$path = "images/gallery_articolo/".$value['foto'];
$filetitle = $value['desc'];
$filename = $value['foto'];
$file_temp = file_get_contents($path);
$file_temp = file_save_data($file_temp, 'public://' . $filename, FILE_EXISTS_RENAME);
$node->field_steps['und'][($value['order'] - 1)] = array(
'image_field_caption' => array( 'value' => $value['desc'], 'format' => 'full_html'),
'fid' => $file_temp->fid,
'filename' => $file_temp->filename,
'filemime' => $file_temp->filemime,
'uid' => 1,
'uri' => $file_temp->uri,
'status' => 1
);
node_save($node);
```
I followed the stucture seen in devel, but I have a lot of issues..
This is the recent log entry:
```
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'caption' cannot be null:
INSERT INTO {field_image_field_caption_revision} (field_name, entity_type, entity_id, revision_id, bundle, delta, language, caption, caption_format)
VALUES (
:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8), (:db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17);
Array ( [:db_insert_placeholder_0] => field_steps [:db_insert_placeholder_1] => node [:db_insert_placeholder_2] => 455 [:db_insert_placeholder_3] => 863 [:db_insert_placeholder_4] => article [:db_insert_placeholder_5] => 0 [:db_insert_placeholder_6] => und [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => [:db_insert_placeholder_9] => field_steps [:db_insert_placeholder_10] => node [:db_insert_placeholder_11] => 455 [:db_insert_placeholder_12] => 863 [:db_insert_placeholder_13] => article [:db_insert_placeholder_14] => 2 [:db_insert_placeholder_15] => und
[:db_insert_placeholder_16] => Wild Roses: fiori che sembrano appena sbocciati, che sottolineano ancora una volta la sua grande cifra stilistica, composizioni perfette per ogni dolce e speciale occasione.
[:db_insert_placeholder_17] => full_html ) in image_field_caption_field_attach_update() (line 234 of /sites/all/modules/image_field_caption/image_field_caption.module).
```
But, as you can see, the :db\_insert\_placeholder\_16 is valorized.
Can someone locate where the error is?
I can't find it..
Thank you ^^
|
2013/08/08
|
[
"https://drupal.stackexchange.com/questions/81961",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/6984/"
] |
in the log entry it shows that `[:db_insert_placeholder_7]` and `[:db_insert_placeholder_8]` elements of the Array were empty - that might be the reason why **Insert** statement failed for the `caption` field:
```
Array
(
[:db_insert_placeholder_0] => field_steps
[:db_insert_placeholder_1] => node
[:db_insert_placeholder_2] => 455
[:db_insert_placeholder_3] => 863
[:db_insert_placeholder_4] => article
[:db_insert_placeholder_5] => 0
[:db_insert_placeholder_6] => und
[:db_insert_placeholder_7] =>
[:db_insert_placeholder_8] =>
[:db_insert_placeholder_9] => field_steps
[:db_insert_placeholder_10] => node
[:db_insert_placeholder_11] => 455
[:db_insert_placeholder_12] => 863
[:db_insert_placeholder_13] => article
[:db_insert_placeholder_14] => 2
[:db_insert_placeholder_15] => und
[:db_insert_placeholder_16] => Wild Roses: fiori che sembrano appena sbocciati, che sottolineano ancora una volta la sua grande cifra stilistica, composizioni perfette per ogni dolce e speciale occasione.
[:db_insert_placeholder_17] => full_html
)
in image_field_caption_field_attach_update() (line 234 of /sites/all/modules/image_field_caption/image_field_caption.module).
```
also, [:db\_insert\_placeholder\_16] - contains a string with 173 characters - is the `caption` field big enough?
hope this helps
|
28,600 |
I have plotted a figure of MoS2 crytal structure. But the actual output looks like the spheres are not in the correct position due to the perspective effect.
I obtained the correct position figure by setting the `ViewPoint` to `Infinity`. But when I rotate the figure, the infinity effect fails and the perspective effect takes place again.

I was wondering if there is a way to get rid of the perspective effect when you draw a graphic?
Thank you.
Here is my code
```
a0 = 1; ceng = 1; znn =3*ceng; ynn = 5; xnn = 5; a1 = 2; cznn = 3; hh = 2;
p1[θ_] := RotationTransform[θ, {0, 0, 1}];
posx1 = (nx1 - 1) a0 + ((ny1 - 1) a0)/2 + (Mod[nz1 - 1, 3] a0)/2;
posy1 = Sqrt[3]/2 (ny1 - 1) a0 + (Sqrt[3] Mod[nz1 - 1, 3] a0)/6;
posz1 = Sqrt[3]/2 (nz1 - 1) a0 + Floor[(nz1 - 1)/3] a0;
sinpq2 = Transpose[Table[{posx1, posy1, posz1}, {ny1, ynn}, {nz1, znn}, {nx1, -xnn, 0}]];
rr = 0.3 a0;
tom2 =
Table[
Graphics3D[{If[Mod[cc, 3] == 2, Pink, Yellow], Sphere[sinpq2[[cc, bb, aa]], rr]}],
{aa, xnn}, {bb, ynn}, {cc,znn}];
Show[tom2,
Axes -> False,
BoxStyle -> Directive[Orange, Opacity[0]],
BoxRatios -> Automatic,
PlotRange -> All,
Background -> Black,
ViewPoint -> {0, 0, ∞}]
```
|
2013/07/15
|
[
"https://mathematica.stackexchange.com/questions/28600",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/8200/"
] |
Maybe this will help a little (adapting documentation exaple for `Slider2D`):
```
DynamicModule[{p = {2 π, 0}},
Row @ {Slider2D[Dynamic[p], {{2 Pi, 0}, {0, Pi}}],
Plot3D[Exp[-(x^2 + y^2)], {x, -3, 3}, {y, -3, 3},
ImageSize -> {700, 700}, PlotRange -> All, ViewAngle -> .0015,
ViewPoint -> Dynamic[1200 {Cos[p[[1]]] Sin[p[[2]]],
Sin[p[[1]]] Sin[p[[2]]],
Cos[p[[2]]]}
]
]
}]
```

Notice that for parallel projection (like here) box edges **do not seem to be parallel but they are** and for default *Mathematica* display they **are not but they look parallel**
|
349,678 |
I've seen Facebook's APIs that will sometimes start with resource id. Also, if the URI is for a business process as opposed to a fine grained resource, would it be acceptable to start the endpoint with an ID, e.g.
```
/{fine-grained-id}/businessProcess
```
So the ID does not represent an item in a list of business processes, but is the key resource ID needed for the process.
|
2017/05/26
|
[
"https://softwareengineering.stackexchange.com/questions/349678",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/273555/"
] |
Roy Fielding introduced REST - <https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm> - and I don't believe there's anything in his dissertation prescribing a particular URI scheme. As long as your scheme is consistent it should be fine. It would also be advisable if it makes some kind of sense to users why the structure exists, even if it's not a public API.
|
8,779,929 |
I want my app to have an activity that shows instruction on how to use the app. However, this "instruction" screen shall only be showed once after an install, how do you do this?
|
2012/01/08
|
[
"https://Stackoverflow.com/questions/8779929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/871956/"
] |
You can test wether a special flag (let's call it `firstRun`) is set in your application `SharedPreferences`. If not, it's the first run, so show your activity/popup/whatever with the instructions and then set the `firstRun` in the preference.
```
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences settings = getSharedPreferences("prefs", 0);
boolean firstRun = settings.getBoolean("firstRun", true);
if ( firstRun )
{
// here run your first-time instructions, for example :
startActivityForResult(
new Intent(context, InstructionsActivity.class),
INSTRUCTIONS_CODE);
}
}
// when your InstructionsActivity ends, do not forget to set the firstRun boolean
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == INSTRUCTIONS_CODE) {
SharedPreferences settings = getSharedPreferences("prefs", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("firstRun", false);
editor.commit();
}
}
```
|
7,495,922 |
protecting a page for Read and/or Write access is possible as there are bits in the page table entry that can be turned on and off at kernel level. Is there a way in which certain region of memory be protected from write access, lets say in a C structure there are certain variable(s) which need to be write protected and any write access to them triggers a segfault and a core dump. Its something like the scaled down functionality of mprotect (), as that works at page level, is there a mechanism to similar kind of thing at byte level in user space.
thanks, Kapil Upadhayay.
|
2011/09/21
|
[
"https://Stackoverflow.com/questions/7495922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/940022/"
] |
No, there is no such facility. If you need per-data-object protections, you'll have to allocate at least a page per object (using `mmap`). If you also want to have some protection against access beyond the end of the object (for arrays) you might allocate at least one more page than what you need, align the object so it ends right at a page boundary, and use `mprotect` to protect the one or more additional pages you allocated.
Of course this kind of approach will result in programs that are very slow and waste lots of resources. It's probably not viable except as a debugging technique, and valgrind can meet that need much more effectively without having to modify your program...
|
10,473,661 |
Recently I've decided to move from Common DBCP to Tomcat JDBC Connection Pool. I changed bean description (using spring 3.1 + hibernate 4 + tomcat) and was faced with the next issue on my web app start up:
**HHH000342: Could not obtain connection to query metadata : com.mysql.jdbc.Driver**
and then when I try to query db from my app I am getting:
**23:04:40,021 WARN [http-bio-8080-exec-10] spi.SqlExceptionHelper:(SqlExceptionHelper.java:143) - SQL Error: 0, SQLState: null**
**23:04:40,022 ERROR [http-bio-8080-exec-10] spi.SqlExceptionHelper:(SqlExceptionHelper.java:144) - com.mysql.jdbc.Driver**
I must have done something wrong with configuration so hibernate cannot obtain connection but do not see it. really appreciate if you can point me to the right direction.
here is piece of my datasource bean definition
```
<bean id="jdbcDataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy- method="close"
p:driverClassName="com.mysql.jdbc.Driver"
p:url="jdbc:mysql://127.0.0.1:3306/test"
p:username="root"
p:password="test"
p:defaultAutoCommit="false"
p:maxActive="100"
p:maxIdle="100"
p:minIdle="10"
p:initialSize="10"
p:maxWait="30000"
p:testWhileIdle="true"
p:validationInterval="60000"
p:validationQuery="SELECT 1"
p:timeBetweenEvictionRunsMillis="60000"
p:minEvictableIdleTimeMillis="600000"
p:maxAge="360000"
/>
```
and here is how I tie it with spring's session factory
```
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="jdbcDataSource" />...
```
|
2012/05/06
|
[
"https://Stackoverflow.com/questions/10473661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1340495/"
] |
First of all it seems that you are creating lots of string objects in the inner loop. You could try to build list of prefixes first:
```
linker = 'CTGTAGGCACCATCAAT'
prefixes = []
for i in range(len(linker)):
prefixes.append(linker[:i])
```
Additionally you could use `string`'s method `endswith` instead of creating new object in the condition in the inner loop:
```
while True:
line=f.readilne()
if not line:
break
for prefix in prefixes:
if line_1.endswith(prefix):
new_line='>\n%s\n' % line_1[:-len(prefix)]
seq_1.append(new_line_1)
if seq_2.count(line)==0:
seq_2.append(line)
```
I am not sure about indexes there (like `len(prefix)`). Also don't know how much faster it could be.
|
28,728,398 |
I have 2 arrays :
1. $valid\_sku\_array
2. $qb\_sku\_array
I want to `intersect` them, and print out the `bad` one (diff)
Then I do this :
```
// Case Sensitive
$intersect_sku_array_s = array_intersect( $valid_sku_array, $qb_sku_array );
dd($intersect_sku_array_s); ... array (size=17238)
```
Then I also tried with the Case Insensitive by doing this :
```
// Case Insensitive
$intersect_sku_array_is = array_intersect(array_map('strtolower', $valid_sku_array), array_map('strtolower', $qb_sku_array ));
dd($intersect_sku_array_is); ... array (size=18795)
```
As you can see the diff of both array = 18795 - 17238 = 1557.
I want to see what are they. Then I tried this :
`$diff = array_diff( $intersect_sku_array_is , $intersect_sku_array_s );`
and when do `dd($diff);` I got `array (size=18795)`
I just couldn't figure it out how to get to print out those **1557**.
Can someone please explain what is going on here ?
|
2015/02/25
|
[
"https://Stackoverflow.com/questions/28728398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
You're problem already begins with your intersect call! There you will lose your "real" array data, because you compare everything in lowercase and assign it also in lowercase.
So your array\_diff won't find anything, because it's case sensitive and if you make it case insensitive you still doesn't have the real data.
You already have to change your intersect. So your code should look something like this:
```
$intersect_sku_array_s = array_intersect($valid_sku_array, $qb_sku_array);
$intersect_sku_array_is = array_uintersect($valid_sku_array, $qb_sku_array, "strcasecmp");
//^^^^^^^^^^^^^^^^ See here I used 'array_uintersect' with 'strcasecmp', so that you don't lose your case
```
After this you can do your array\_diff normal like this:
```
$diff = array_diff($intersect_sku_array_is, $intersect_sku_array_s);
```
|
220,741 |
I have a file share, and I want a process which enumerates files on that share and automatically creates a 7z self-extracting exe of *files* over 1 month old. On a different share, I want to create a 7z self-extracting exe of *directories* that are over 1 month old. Any idea if there is a program which can do this? I already have
```
7z a -t7z -mx9 -sfx filename.exe filename.txt
```
Portion of it, just need more of the auto-management portion.
Running on Windows Server 2008, yes, PowerShell is available. Cygwin would not be an option.
|
2011/01/10
|
[
"https://serverfault.com/questions/220741",
"https://serverfault.com",
"https://serverfault.com/users/3479/"
] |
I ended up doing this with a batch file, and setting it to run via Task Scheduler. Here is the batch file if anyone is interested:
```
@echo off
set RETENTION_PERIOD_DAYS=30
set FILE_BASED_ARCHIVES=g:\shares\public\crashes
set DIRECTORY_BASED_ARCHIVES=g:\shares\results
set MINIMUM_FILESIZE=1000000
set ZIP_PATH="c:\Program Files\7-Zip\7z.exe"
if not {%1}=={} call :archive %1 %2 %3 %4&exit /b 0
echo Archiving files older than %RETENTION_PERIOD_DAYS% days.
echo File Based: %FILE_BASED_ARCHIVES%
echo Directory Based: %DIRECTORY_BASED_ARCHIVES%
for %%a in (%FILE_BASED_ARCHIVES%) do (
echo ********* Archiving %%a
du /s "%%a"
echo -----------------------
forfiles /p %%a /s /m *.* /d -%RETENTION_PERIOD_DAYS% /c "cmd /c call ^0x22%~dpnx0^0x22 ^0x22FILE^0x22 ^0x22@isdir^0x22 ^0x22@fsize^0x22 @path"
echo -----------------------
du /s "%%a"
echo ****************************************************
)
for %%a in (%DIRECTORY_BASED_ARCHIVES%) do (
echo ********* Archiving %%a
du /s "%%a"
echo -----------------------
forfiles /p %%a /d -%RETENTION_PERIOD_DAYS% /c "cmd /c call ^0x22%~dpnx0^0x22 ^0x22DIR^0x22 ^0x22@isdir^0x22 ^0x22@fsize^0x22 @path"
echo -----------------------
du /s "%%a"
echo ****************************************************
)
exit /b 0
:archive
if /i "%~1"=="FILE" (
if /i "%~2"=="FALSE" (call :archive_file %3 %4) else (echo Skipping %~4 as it is not a file.)
)
if /i "%~1"=="DIR" (
if /i "%~2"=="TRUE" (call :archive_dir %4) else (echo Skipping %~4 as it is not a directory.)
)
exit /b 0
:archive_file
set FILESIZE=%~1
if %FILESIZE% GEQ %MINIMUM_FILESIZE% (
call :7zip %2 && del /q /f %2
) else (
echo Skipping %~2 as it is smaller than %MINIMUM_FILESIZE% bytes.
)
exit /b 0
:archive_dir
call :7zip %1 && rd /q /s %1
exit /b 0
:7zip
%ZIP_PATH% t "%~1">nul || (
%ZIP_PATH% a -t7z -mx9 -sfx "%~dp1%~n1.exe" "%~dpnx1" || exit /b 1
)
exit /b 0
```
|
18,008 |
Что-то меня вчера заклинило. Можно ли сказать "оказывать консультацию" или только "давать"?
|
2013/04/02
|
[
"https://rus.stackexchange.com/questions/18008",
"https://rus.stackexchange.com",
"https://rus.stackexchange.com/users/3/"
] |
Давать консультацию, совет, а оказывать помощь и т.п. Возможно, но менее употребительно - предоставить консультацию.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.