INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Can I use games already installed on Xbox 360 hard drive?
I just bought an Xbox 360 hard disk, with previously installed games. Inspecting it with FatXplorer, I can see a list; some games are shown as "Console Signed" and others as "PIRS Signed"
, and logging into my own XBox account? Or do I need something else? Can the previous owner "reclaim" the property over these games using his own gamertag? | Games installed via disk still require the disk to be inserted to run them. Downloaded content from the marketplace requires the buyer to still be signed into the system or have the system be set as the buyer's home system.
You shouldn't be able to play any of the games previously installed. | stackexchange-gaming | {
"answer_score": 1,
"question_score": 0,
"tags": "xbox 360"
} |
Precompute points in Manipulate
I wish to carry out a parameter sweep for a certain function in Manipulate, and create a plot for each parameter set.
Each plot of the function takes ~ 10 seconds, so I would like to precompute the plots for a table of parameter sets, then use manipulate to rapidly move between them. The Advanced Manipulate Functionality documentation has suggestions for slow computations, but does not say how to carry out this functionality.
Could you please help me figure out how to do this? | Working off the comment from @MarcoB, a working answer is as follows: If you wanted to plot $x^2+b$ and manipulate b while following the above, you could use this:
listOfPlots = Table[Plot[x^2 + b, {x, -1, 1}], {b, 1, 9}]
Manipulate[listOfPlots[[i]], {i, 1, Length@listOfPlots, 1}] | stackexchange-mathematica | {
"answer_score": 3,
"question_score": 3,
"tags": "manipulate"
} |
Add array with the same value
I need help or advice on how to add or combine the value of array with same key.
For example:
Array(
[price] => 123
[category] => Fiction
[bookname] => Any-Book
[type] => Futuristic
)
Array (
[price] => 145
[category] => Fantasy
[bookname] => Any-Book
[type] => Futuristic
)
Through many attempt I was not able to achieve the result I wanted it should be:
Array (
[price] => 268
[category] => Fantasy/Fiction
[bookname] => Any-book
[type] => Futuristic
)
I just need to combine the two they are essentially the same thing or needed to be bundled. | Here's my contribution, using `array_walk`, and making a few assumptions about the rules for the merge:
$a = Array(
'price' => 123,
'category' => 'Fiction',
'bookname' => 'Any-Book',
'type' => 'Futuristic'
);
$b = Array (
'price' => 145,
'category' => 'Fantasy',
'bookname' => 'Any-Book',
'type' => 'Futuristic'
);
array_walk ($a,
function (&$v, $k, $comp) {
if (is_int($v)) {
$v = $v + $comp[$k];
} else {
if ($comp[$k] != $v) {
$v = "$v/" . $comp[$k];
}
}
}, $b);
var_dump($a);
The assumptions are: if the value in array `$a` is `int`, then sum it with the equivalent in `$b`. If the value is not `int`, compare it with the equivalent in `$b`, and if it matches leave it alone; otherwise concatenate wtih `/`. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "php, arrays"
} |
Rails.root showing correct path but Rails.root.join is not showing correct path
`Rails.root` work but `Rails.root.join` is not working as expected.
puts Rails.root # /work/project
src_dir = "/public/files"
puts Rails.root.join(src_dir)
# expected: /work/project/public/files
# showing: /public/files | The problem is that with the first slash in `public` you're making a reference to the folder `public` located in `/`, not in the relative path where your project is.
Removing that first slash might give you the expected output:
Rails.root.join('public/files') | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "ruby on rails, ruby"
} |
getting empty value from this.props.match.params while it is showing in the react dev tools
Hi I am trying to access my params from my react router but it always shows me an empty object.
this is my code:
<Switch>
<Route exact path='/' render={(props) => (<PhotoWall {...this.props}/>)}/>
<Route path='/single/:id' render={(props) => (<Single {...this.props}/>)}/>
</Switch>
I can see the value of my params in react dev tools. but i can't access it in this.props.match.params.. ? | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "reactjs, react router, react redux, react router redux"
} |
Excel formula to calculate percentage with 3 options
I have a sales person on variable commission depending on amount sold. So basically I'm trying to put in a formula that gives me the answer to this all in one cell -
Sum of 1570 or under = nil
between 1571 - 4600 = x 6.5 %
above 4601 = x 7.5%
I have been trying myself but I'm getting nowhere. How can I accomplish this? It is a tiered solution they don't get single percentage on the whole amount.
Thanks Anne | Here's the tiered formula:
=IF(SUM(A1:A10)>4600,(SUM(A1:A10)-4600)*0.075 + 3029*0.065, IF(SUM(A1:A10)>1570,(SUM(A1:A10)-1570)*0.065, 0))
Some explanations:
1. First, check if sum is 4600 or above. If yes, the amount above 4600 is paid at 7.5% rate. And since the sum is above 4600, the middle criteria must apply as well, so 3029*6.5% is also added.
2. If the first step isn't true, we check if the sum is above 1570. If yes, the amount above 1570 is paid at 6.5% rate.
3. Finally, nil if 1570 or under | stackexchange-superuser | {
"answer_score": 0,
"question_score": -1,
"tags": "microsoft excel, worksheet function"
} |
This webpage has a redirect loop issue
I want to redirect non logged in users to page id = 2 which have registration form.
function checkLogged()
{
$pg = get_permalink();
if (!is_user_logged_in() && !is_front_page() && $pg != home_url('/?page_id=2'))
{
wp_redirect(home_url('/?page_id=2'));
exit;
}
}
add_action('wp_head', 'checkLogged');
Is this code correct ? I am getting
> This webpage has a redirect loop The webpage at < has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer. | Use following code instead of above code :
function checkLogged()
{
if (!is_user_logged_in() && !is_front_page() && 2 != get_queried_object_id())
{
wp_redirect(home_url('/?page_id=2'));
exit;
}
}
add_action('wp_head', 'checkLogged'); | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "login, wp redirect"
} |
How can I retrieve the values from textboxes and use them in JSP?
How can I retrieve the values from textboxes and use them in JSP? | in the next jsp? (the one thats in the form action) then your answer is `${nameOfTextboxHere}`
or if you mean in the same page, you will have to use javascript. - See w3schools javascript tutorial | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "jsp"
} |
How to compare pointer to strings in C
how to compare two strings in C? Help me, I am beginner@@
char *str1 = "hello";
char *str2 = "world";
//compare str1 and str2 ? | You may want to use `strcmp`:
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
int v;
const char *str1 = "hello";
const char *str2 = "world";
v = strcmp(str1, str2);
if (v < 0)
printf("'%s' is less than '%s'.\n", str1, str2);
else if (v == 0)
printf("'%s' equals '%s'.\n", str1, str2);
else if (v > 0)
printf("'%s' is greater than '%s'.\n", str1, str2);
return 0;
}
Result:
'hello' is less than 'world'. | stackexchange-stackoverflow | {
"answer_score": 13,
"question_score": 9,
"tags": "c"
} |
Remove all http and https from HTML but exclude placeholder
I want to remove all `http:` and `https:` in the HTML files but exclude `placeholder="http:` and `placeholder="https:`. I have tried the following example but every http: and https: will be removed:
/(?!placeholder=")(http:|https:)/ | You need to replace the lookahead with a lookbehind. Besides, you may reduce the alternation to a mere `https?:` pattern, where `s?` means _1 or 0`s`_:
'/(?<!placeholder=")https?:/'
^ ^^
If you want to make sure the `placeholder` is matched as a whole word, add a word boundary:
'/(?<!\bplaceholder=")https?:/'
^^
If there must be a whitespace before `placeholder`, replace `\b` with `\s`.
**Details**
* `(?<!\bplaceholder=")` \- a location inside a string that is immediately preceded with a whole word `placeholder` and then `="`
* `http` \- a `http` substring
* `s?` \- an optional `s`
* `:` \- a colon. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "php, regex, preg replace"
} |
Failed to listen on localhost:8000 (reason: Cannot assign requested address)
When I run `php artisan serve` on Ubuntu, the Laravel development server tries to start on < but fails with this error:
> [Mon Apr 25 10:28:08 2016] Failed to listen on localhost:8000 (reason: Cannot assign requested address)
My hosts file (`/etc/hosts/`):
1 27.0.0.1 localhost
How can this be fixed? | That's usually because the port is in already in use, or not available on the current host.
You can use this command to run **php artisan serve --port=8080** | stackexchange-stackoverflow | {
"answer_score": 9,
"question_score": 4,
"tags": "laravel, laravel 5"
} |
What happens when assigning an equal value to an existing variable?
Basically the question is what happens if you try to assign the same value to the(state) variable:
address someAddress = 0x...abcdef;
function setSomeAddress(address _input) public {
//What happens if someAddress already equals to _input?
someAddress = _input;
}
What happens if you then call `setSomeAddress(0x...abcdef); `
Does the transaction go through and nothing changes or...? | That's a perfectly valid assignment, so the transaction will go through. Simply nothing changes in the contract state.
The only small question is whether you need to pay gas for storing the value. I guess the optimizer may be smart enough to optimize that line out if the value doesn't change, but I really don't know. My guess is that at least at the bytecode level you would need to pay for the assignment, even if you set the same value. | stackexchange-ethereum | {
"answer_score": 1,
"question_score": 0,
"tags": "state variable"
} |
How do I configure Couchbase full text search index to sort on full property
We are using Couchbase 4.6.2 and trying to use the full text search feature. Our attempt is to search, sort, and paginate.
Currently, we have it indexed using the default index settings.
The issue we are running into is, when the FTS feature sorts the records, it sorts based on a single word in the field. Based on the documentation, it seems this is because of how full text search indexing works (and the analyzer that is chosen in the index). It takes each word and creates an index on that. Then when sorting is performed, it chooses either min or max values for that field and sorts on that value.
Is it possible to have the FTS index the fields on the per-word basis as it does now, but have the sort operate on the entire content of the property? | The sorting operates using the terms in the index for the specified field. So, in order to sort on the entire value, you must use the keyword analyzer , since that keeps an entire field value as a single term. By using the keyword analyzer on that field, values like "Video Games" will be indexed as a single term.
Then if you specify that field for sorting, it will order by the entire value. Also, contrary to one of the other answers, the sorting operates on the indexed value, and does not require a stored value.
A related issue is that sometimes you want to search on the field as well as sort on it, and in this case you want to use an analyzer other than keyword. To accommodate both use cases, you simply have to index the field twice, once for searching and once for sorting. To do this, you simply have to give them different names. Something like 'category' for searching and 'category.sort' for sorting. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "sorting, couchbase"
} |
How is it possible that 127==127 while 128!=128?
Integer v1_1 = 127;
Integer v1_2 = 127;
Integer v2_1 = 128;
Integer v2_2 = 128;
System.out.println(v1_1 == v1_2);//true
System.out.println(v2_1 == v2_2);//false
Why second expression is **false**?
I couldn't figure it out how the value affect the comparison result. | Because the `Integer` type **interns** the values (by the static class `IntegerCache`) from -128 to 127. | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": -2,
"tags": "java"
} |
Run local script in other machine using ssh
I have a script in my local machine and i want to run it in remote machines without copy this script in each machines by using ssh.
currently I use scp to copy this script in remote machine and then run the command :
ssh @ip:"./script" | There is such a solution: `ssh user@host 'bash -s' < local_script.sh`. Other examples can be found on this page. | stackexchange-askubuntu | {
"answer_score": 5,
"question_score": 0,
"tags": "ssh, remote, remote access"
} |
How to import csv files as data for bootstrapping
I'm trying to import a csv file to my grails project, what I'm trying to do is to build a map based on that csv file which is a list of countries (countries.csv) and use the map as a bootstrap data.
any ideas would be much appreciated | I am assuming (perhaps incorrectly!) that you mean that you once you have the csv file in your project, you want your program to read it and use the data contained in it.
There are a number of OSS CSV parsers out there. For starters:
* OpenCSV
* Ostermiller CSV
* Commons CSV
* SuperCSV
Find one that does what you need. It'll be easier than rolling your own, especially if your input file can have commas within strings, etc. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "java"
} |
Use same variable multiple times in print
In Python if I want to use a variable in string while printing I do the following:
name = "newbie"
site = "Stack Overflow"
print("I, a %s, find %s very useful" % (name, site))
If I want to print `"I, a newbie, find Stack Overflow to be very very very useful'` and substitute `'very'` by a variable name, how can I do that, while still using the `name` and `site` variables? | >>> print("I a {0} find {1} {2} {2} {2} {2} useful".format(name, site, 'very'))
I a newbie find stackoverflow very very very very useful
Or, using names:
>>> a='very'
>>> print("I a {name} find {site} {a} {a} {a} {a} useful".format(name=name, site=site, a=a))
I a newbie find stackoverflow very very very very useful
Or, using the local dictionary:
>>> print("I a {name} find {site} {a} {a} {a} {a} useful".format(**locals()))
I a newbie find stackoverflow very very very very useful | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 4,
"tags": "python"
} |
Swift - adding values captured in two textfields
I seem to have a problem with a very simple scenario.
I'm trying to add values captured by two text fields (called T1 and T2) and display their total upon pressing a button (GoButton) on a label (Label1).
I tried wording the syntax in multiple ways and it still doesn't work. I feel that some of the syntax I found on the web didn't work for me. I use Xcode 6.3 on Yosemite.
Screenshot: !enter image description here
Is there a chance that there is something I'm missing with my Xcode to accept swift syntax? Please help. | Dante- There's still a chance the values could be nil. You've correctly !'ed the TextFields so they unwrap automatically, but the Int conversion is also Optional (the Int still thinks it may get a nil value).
Label1.text = "\(T1.text.toInt()! + T2.text.toInt()!)"
Helpful Hint- If you paste your code in here (rather than a screenshot) it's much easier for folks to copy and paste your code into their IDE and test it out.
For those here smarter than me (everyone) I'm curious why Xcode doesn't complain about a single Int conversion:
Label1.text = "\(T1.text.toInt())" // no complaint from the compiler | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "swift, xcode6"
} |
Visio 2003: relationship arrow to connect 2 tables in Database ER diagrams
I am trying to model relationship between 2 tables Orders and OrderDetails. I draw "relationship" arrow from OrderDetails to Orders table with Foreign key OrderID. But in DatabaseProperties for relationship arrow, I get unknown parent and unknown child. How do I connect the 2 tables with relationship arrow properly. | 1. Make sure you are picking the relationship arrow from the Entity Relationship stencil.
2. Drop the connector (arrow) on the surface.
3. Pick the top of the arrow and drag into middle of the `Orders` table
4. Pick the other end and drag into middle of the `OrderDetails` table.
You can also select fields to connect in "Arrow definition tab". No need to specify foreign key in advance, it will auto-add once you make connection with the arrow. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "database, visio, entity relationship"
} |
Feature to Line on feature selections with ArcPy
I'm trying to collapse parallel polylines (dual carriageways in a shapefile of roads) to single centrelines. I'm aware of cartography's dual lines to centerline tool, but I find Feature To Line (Data Management) slightly more reliable. The challenge is that whichever function is used requires a large tolerance (e.g. 10m+) so must be applied to custom selections of data in order to avoid creating new artifacts between unrelated pairs - hence the need for custom selections, which as far as I can tell these functions can't handle.
Grateful for any advice from high ArcPy wizards on how best to approach this. I'm pretty new to ArcPy so any advice on e.g. creating temporary layers to work with would be very helpful. As a starting point please just assume a polylines shapefile. The planned workflow is to rejoin these with the other road data once they've been collapsed. Many thanks in advance. | Perhaps not the most elegant solution (based on advice from ArcGIS Forums), but it works for me:
fieldNames = getValueList("shapefile", "FIELD")
fieldNames = map(str, fieldNames)
# blank layer for results called 'merged'
arcpy.CreateFeatureclass_management("C:\\PATH", "merged.shp", "POLYLINE", "shapefile.shp", "SAME_AS_TEMPLATE", "SAME_AS_TEMPLATE", "shapefile.shp")
for each in fieldNames:
defQuery = "\"FIELD\" = '%s'" % (each)
# create temporary layer of DCs with same official road identifier
arcpy.MakeFeatureLayer_management("shapefile", "selectn", defQuery)
# run centre-line function on the selection and assign to new layer
arcpy.FeatureToLine_management("selectn", "newSelectn", "20.0 Meters", "ATTRIBUTES")
arcpy.Append_management("newSelectn", "merged", "NO_TEST")
arcpy.Delete_management("newSelectn.shp")
arcpy.Delete_management('selectn') | stackexchange-gis | {
"answer_score": 0,
"question_score": 1,
"tags": "arcmap, arcpy"
} |
Opening a JDialog on the click of a button
I am trying to open a `JDialog` when a button in a `JFrame` is pressed and that dialog should contain a `JTable`.
Where should I create the dialog (inside the frame or should a new class be created)? | If your dialog is rather complex use a new class for it. Do something like
public class OtherDialog extends JDialog {
// ...
public OtherDialog(){
// build dialog
}
}
and open it in your JFrame-Button-Actionhandler like this:
protected void btnOpenotherdialogActionPerformed(ActionEvent e) {
try {
OtherDialog dialog = new OtherDialog();
dialog.setModalityType(ModalityType.APPLICATION_MODAL);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
} catch (Exception ex) {
ex.printStackTrace();
}
} | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "java, swing, jdialog"
} |
Executing cmd commands in Windows from PHP Issue
Is it possible to execute cmd commands in Windows OS with PHP exec() function?
I tried this:
<?php
try {
echo exec(
'O:\test\pdftk.exe O:\test\outputs\OPP\out.pdf O:\test\outputs\OPP\out2.pdf cat output O:\test\123.pdf'
);
} catch (Exception $e) {
echo $e->getMessage();
}
Basically, I'm trying to merge two pdf files with the pdftk program. If I just write the same exact command to the cmd by hand, it works and the O:\test\123.pdf file is created. But when I execute the above PHP file, nothing happens (blank page, the file is not created). | Can your PHP user access cmd.exe? You might find the tools at Microsoft's Sysinternals very useful; particularly the process monitor. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "php, windows, command line"
} |
Paperjs division with arrays?
In < at source code line 16 you can see this:
var start = view.center / [10, 1];
I assume that this is some kind of 2D vector division. But how can someone define the type conversions at certain operations in javascript?
Or is this string parsed and translated into some other javascript code? | Quoting from the Paper.js Website:
> **What is PaperScript?**
>
> PaperScript is the plain old JavaScript that you are used to, with added support of mathematical operators (+ - * / %) for Point and Size objects. PaperScript code is automatically executed in its own scope that without polluting with the global scope still has access to all the global browser objects and functions, such as document or window.
>
> By default, the Paper.js library only exports one object into the global scope: the paper object. It contains all the classes and objects that the library defines. When working with PaperScript, the user does not need to care about this though, because inside PaperScript code, through the use of clever scoping, all of paper's objects and functions seem global. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "javascript, type conversion, paperjs"
} |
How to find integer solutions for indeterminate equations in $Ax + By = C$
I would like to find some positive integer solutions to an equation in the form $Ax + By = C.$ I have already seen some methods for doing this, such as the one outlined in this Math.SE post.
What I am interested in is the method shown here. The first example is the one I was looking at. I can follow it up to fig [1.2]. I don't understand what the author means by "Reducing the right-hand side to integers and fractions." I would greatly appreciate some help in understanding this process. Also, is there a name that I can Google for the method used in this article? Thanks. | It's just a funny way to call a pretty elementary arithmetic operation: $$\frac{4238-97y}{95}=\frac{44\cdot 95+58-(95y)-2y}{95}=\frac{44\cdot 95}{95}-\frac{95y}{95}+\frac{58-2y}{95}=$$ $$=44-y+\frac{58-2y}{95}$$ | stackexchange-math | {
"answer_score": 1,
"question_score": 2,
"tags": "elementary number theory, diophantine equations"
} |
MySQL LEFT JOIN with WHERE
Ive got two tables company and process. Company has field company_id and others. Process has fields company_id and status. I want all the fields of the company table only without those in the process table that have a status 0. Ive come sofar with the following but that gives me all the values of company even with the one of process table that has status 0.
SELECT c.company_id
FROM company c
LEFT JOIN
process p
ON c.company_id = p.company_id
AND p.status != '0' | SELECT c.company_id
FROM company c
LEFT JOIN process p
ON c.company_id = p.company_id
WHERE p.status != '0'
OR p.status IS NULL
;
2nd solution (edited and simplified): This doesn't look like "hack", does it?
SELECT c.company_id
FROM company c
WHERE c.company_id NOT IN
( SELECT company_id
FROM process
WHERE status = '0'
)
;
The problem with second solution is that if you want fields from table `process` to be shown, one more join will be needed (this query with `process`).
In the first solution, you can safely change first line to `SELECT c.company_id, c.company_title, p.status` or , `SELECT c.*, p.*`. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "mysql, left join"
} |
How to set hostname of an instance in azure scale set?
I have a scale set with 1 VM. I want to set the hostname of the VM to a static-hostname. I have tried to change the hostname using a custom extension. The hostname is changed, but it is not reachable from other VMs, unless it is rebooted.
Can the hostname be changed and be reachable without a reboot? | I added the following command and the end of my custom extension script and it worked.
'dhclient' | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "azure, hostname, azure vm scale set"
} |
Frameworks for optimizing performance with Javascript
This is kind of an unusual situation so forgive me for the odd title. I've been looking at optimizing an HTML interface for manipulating server data. All data is passed over a REST service and there are existing jQuery methods for pulling and submitting the data.
The problem is that all this runs very slowly due to the large amount of Javascript code used for animating and manipulating the screen. Obviously I can optimize the javascript code to some extent, but the interface is so slow I'm wondering if there are other frameworks I should look at taking advantage of. I don't have the ability to leverage anything server side like PHP.
If there are no other frameworks, I'm planning to move most of the code to jQuery to improve readability and take advantage of the optimizations others have done there. | Please have a look at AngularJS. It is a framework (by Google) specifically designed for data driven websites. It is built on jQuery. It provides a $resource service which can be used to develop your own REST client for your website. The purpose of which is to enhance code readability and performance by abstracting the lower-level HTTP calls.
You can also have a look at Dojo but it has a huge learning curve. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -2,
"tags": "javascript, performance"
} |
Create a class diagram without using doxygen
Is there a way to create a class diagram without using doxygen? | you can obviously create class diagrams and any other UML diagrams by means of any UML editor. There are many available, for instance Papyrus is provided in the latest Eclipse Modeling distribution. Otherwise TopCased is a very good one ( | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "iphone, c++"
} |
Are read replicas heavy reading in affect masterDB?
We have a very heavy load in Read side with large DB tables in 2 hours per day that affect to Db so as solutions I have created read replica for it.
If application fetches large heavy data on read replica, is MasterDB affect with that havy load or it will work as it is. | From your tags, I guess its for AWS RDS Aurora. Generally, Aurora's design differs from native databases. It has a distributed storage system.
Of course, if you huge select will affect the master when you have MyISAM in place. But Aurora completely designed with InnoDB. So it won't.
Not sure whether your replica and master are in the same AZ. Its a good practice to use different AZ in Aurora.
Due to its PIOPS, your massive select load will not affect your master anyway. If you have a predictable load on a particular time, use Aurora autoscaling to share the loads between multiple read replica. | stackexchange-dba | {
"answer_score": 1,
"question_score": 1,
"tags": "amazon rds, aws, aws aurora"
} |
Posting information input to form to another page?
I am working with wordpress and I want to figure out a way to have a form on one page, and then have the information post to a separate page on the site. I only know html so I don't know how to work through the php at all nor do I know where to put the code to do this. I already have a generic form set up, I just can't connect the dots with this and figure out how to display the information back. I have looked through a dozen or so similar posts, but all of the answers would require that I know more about php. Any help or advice would be appreciated, thank you in advance. | You use PHP's `$_POST` to get the values submitted by the form. Set the `action` attribute of your form to the php page.
If this is your form:
<form action="second-page.php" method="post">
<input name="field_01">
<button type="submit">Submit</button>
</form>
You access the value of `field_01` in the php like this:
$_POST["field_01"];
Where `field_01` can be the name of any relevant field that was in the form.
To simplify things, collect all the fields in variables at the top, and `echo` them when you want to put them in your html:
<?php
$field_01 = $_POST["field_01"];
?>
<!-- your html -->
<p><?php echo $field_01; ?></p>
You can do this for as many fields as you have. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "php, html, wordpress, forms, post"
} |
Junction Object to create many to many relationship between Tasks and Accounts?
I need to create a many to many relationship between Tasks and Accounts. The goal here is to relate many Accounts to a single Task - and also be able to report on this cleanly - ex: "User(assignedTo) met with Contact(WhoId) and discussed Account1, Account2, Account3 and Account4."
I understand the Activities object cannot be related to via lookup or master detail relationship, so instead as a workaround would I be able to use the Contact object? So, Contact being the parent and Account being the child on my Junction object?
Am I thinking about this approach correctly and would it still allow for me to use standard reporting with the example I mentioned above?
Please let me know if I can provide any more information, Thanks! | Your question seeks to relate a task/event to ONE Contact and MANY Accounts... and this is currently not possible.
Many Contacts (and, by extension, each of their Accounts) is possible, but to relate it to one Contact and to many non-Contact objects is not available. | stackexchange-salesforce | {
"answer_score": 5,
"question_score": 4,
"tags": "reporting, activities, architecture, junction object"
} |
Removing <div>'s from text file?
Ive made a small program in C#.net which doesnt really serve much of a purpose, its tells you the chance of your DOOM based on todays news lol. It takes an RSS on load from the BBC website and will then look for key words which either increment of decrease the percentage chance of DOOM.
Crazy little project which maybe one day the classes will come uin handy to use again for something more important.
I recieve the RSS in an xml format but it contains alot of div tags and formatting characters which i dont really want to be in the database of keywords,
What is the best way of removing these unwanted characters and div's?
Thanks,
Ash | If you want to remove the DIV tags WITH content as well:
string start = "<div>";
string end = "</div>";
string txt = Regex.Replace(htmlString, Regex.Escape(start) + "(?<data>[^" + Regex.Escape(end) + "]*)" + Regex.Escape(end), string.Empty);
Input: `<xml><div>junk</div>XXX<div>junk2</div></xml>`
Output: `<xml>XXX</xml>` | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "c#, xml, html"
} |
BigQuery client python get column based partitioning column name
I am looking to include a where clause to an existing query to exclude data in the BigQuery streaming buffer.
To do this I would like to get the Partition column name so I can add
WHERE partition_column IS NOT NULL;
to my existing query.
I have been looking at the CLI and the get_table method however that just returns the value of the column not the column name. I get the same when searching on `.INFORMATION_SCHEMA.PARTITIONS` this returns a field for partition_id but I would prefer the column name itself, is there away to get this ?
Additionally the table is setup with column based partitioning. | Based on python BigQuery client documentation, use the attribute `time_partitioning`:
from google.cloud import bigquery
bq_table = client.get_table('my_partioned_table')
bq_table.time_partitioning # TimePartitioning(field='column_name',type_='DAY')
bq_table.time_partitioning.field # column_name
Small tips, if you don't know where to search, print the API repr:
bq_table.to_api_repr() | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "python, google cloud platform, google bigquery, partitioning"
} |
What is the format for piping a message into sendmail?
I am using the following command to create messages on the fly, and send them:
echo "Subject:Hello \n\n I would like to buy a hamburger\n" | sendmail [email protected]
It seems that when you send the information from a file, by doing something like:
sendmail [email protected] mail.txt
Then sendmail sees each line as a header, and parses it. But the way I sent it above, everything ends up in the subject line.
If one wants to echo a message complete with headers, into sendmail, then what is the format ? How does one do it ? | Your `echo` statement should really output newlines not the sequence `\` followed by `n`. You can do that by providing the `-e` option:
echo -e "Subject:Hello \n\n I would like to buy a hamburger\n" | sendmail [email protected]
To understand what is the difference have a look at the output from the following two commands:
echo "Subject:Hello \n\n I would like to buy a hamburger\n"
echo -e "Subject:Hello \n\n I would like to buy a hamburger\n" | stackexchange-unix | {
"answer_score": 29,
"question_score": 26,
"tags": "shell, email, sendmail, echo"
} |
Responsive page: make the right column stay on top when in one column
I have the following html:
<div class="left">
this is left side. it should go to the bottom when in one column
</div>
<div class="right">
this is right side. it should go to the top when in one column
</div>
css:
.left {
width: 70%;
float: left;
background-color: red;
}
.right {
width: 30%;
float: left;
background-color: yellow;
}
@media only screen and (max-width : 768px) {
.left, .right {
width: 100%;
}
}
I am hoping to make the right column stay on top when the display is one column.
Here is the jsfiddle link: <
What should I do, including changes to my current CSS? | Change the order of the divs so that right comes first in the html, and update the `class="right"` div to `float:right;`
< | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 6,
"tags": "css"
} |
How to detec face, eyes, lips in flash as3
Pls help me, I want demo detec face, eyes, lips on image but i research not found.
Thank all!!!!!enter image description here | You could try a library like the Oddcast Face Detection API, which tracks points like the eyes, the nose and the chin. <
You need to buy a license for this API.
There are a couple of other libraries for face detection with Flash, but this is the only one so far that tracks different features, like the eyes. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -3,
"tags": "actionscript 3, flash, actionscript, detection"
} |
How can I know if two tabs share the same renderer process?
Despite sandboxing, two different tabs in Chrome can share the same renderer process, for example when they share the same JavaScript environment.
Given two Chrome tabs, how can I know if they share the same process? | In Chrome, press `Shift`+`Esc` to open Chrome's task manager.
!Task manager
Then, right click on the column headings in the task manager. Enable the "Process ID" column.
!Process ID check box
Now, you can check the Process IDs next to each tab. If they are the same for two tabs, then the tabs are open in the same process.
!Process ID column | stackexchange-superuser | {
"answer_score": 4,
"question_score": 2,
"tags": "google chrome"
} |
What are CLOCK, RESET and ENABLE signals collectively called?
I want to add a comment before CLOCK, RESET and ENABLE signals. Is there a good collective term for these signals?
(
// ???
input CLOCK,
input RESET,
input ENABLE,
// Interconnect
output [15:0] ADDR,
...
); | With CPUs, we tend to describe there being 3 buses between the CPU and other components - the Address Bus, Data Bus and Control Bus.
Here, these seem to be Control signals, so that's what I'd go for. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "verilog"
} |
Get the count of rows in a stored procedure result regardless of number/type of columns
I have developed the following code:
CREATE PROCEDURE [dbo].[Test01]
AS
BEGIN
SELECT * FROM TestTable
END
CREATE PROCEDURE [dbo].[Test02]
AS
BEGIN
DECLARE @tmp TABLE
(
TestID int,
Test nvarchar(100),
)
INSERT INTO @tmp
EXEC Test01
SELECT COUNT(*) FROM @tmp
END
But if I add or remove a column on `TestTable` I must to modify `@tmp` otherwise the result is:
> _Column name or number of supplied values does not match table definition_
How can I solve this problem? | Try specify the columns manually:
SELECT a, b FROM TestTable
and
INSERT INTO @tmp (a, b)
This should fix the error you've mentioned. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "sql, sql server, tsql, stored procedures, dynamic sql"
} |
Rademacher‘s Theorem and Baire category
Is there a variant of Rademacher‘s Theorem where the smallness of the points of non-differentiability is measured in terms of Baire category instead of measure?
More precisely, let X be a separable Banach space and Y be a space with the RNP. Moreover, let $U\subset X$ be an open set and $f\colon U\to Y$ be a Lipschitz mapping. Is the set of points where $f$ is not differentiable a meager set?
As a partial question: Is something known about the above in finite dimensions? | No, not even in one dimension. Googling "not differentiable on a residual set" yields a citation of the paper F. Mignot, Contrôle dans les inéquations variationelles elliptiques, _J. Functional Analysis_ **22** (1976), 130–185. | stackexchange-mathoverflow_net_7z | {
"answer_score": 5,
"question_score": 2,
"tags": "fa.functional analysis, real analysis"
} |
Matlab 2D plot — display axis in binary
I have a positive natural number vector which I am plotting in Matlab using the typical plot() function. Here is a sample plot:
!Plotting a natural number vector, axis in radix-10, need to display them in radix-2
However, I need to see the vector (y axis) displayed in binary. Is there a way to change the axis display in binary (radix-2) ? I tried using dec2bin, but it only converts the integers to strings which can not be plotted. | How about this:
L = get(gca,'YTickLabel');
set(gca,'YTickLabel',cellfun(@(x) dec2bin(str2num(x)),L,'UniformOutput',false));
**edit** : Since you wanted the ability to zoom, here is a way to make the axis zoomable:
zh = zoom(gcf);
set(zh,'ActionPreCallBack',@(source,event,s) set(gca,'YTickLabelMode','auto'))
set(zh,'ActionPostCallBack',@(source,event,s) set(gca,'YTickLabel',cellfun(@(x) dec2bin(str2num(x)),get(gca,'YTickLabel'),'UniformOutput',false)));
It resets the axis to decimal before the zoom and then converts back to binary after the zoom. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "matlab, plot, binary, 2d, matlab figure"
} |
Convert Unicode to ASCII in .NET from MATHEMATICAL SANS-SERIF BOLD CAPITAL I
I have this string below that needs to be convered to ASCII.
I tried to see if it was already ASCII and it seems to be this encoding below. Is there a way to do this in .NET?
The strings first character is symbol: , code point: 1d5dc, position: 1, so non ASCII, but Unicode Character 'MATHEMATICAL SANS-SERIF BOLD CAPITAL I' (U+1D5DC) | Apply .NET String.Normalize Method using _Compatibility Decomposition_ , see Unicode normalization forms.
If your string is in variable `s2` then use something like (an example from the former link):
s2.IsNormalized(NormalizationForm.FormKD)
Here's PowerShell equivalent:
' '.Normalize('FormKD')
INDOOR SOFTBALL TOURNAMENT DIAMOND JAXX AND HITZ | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "c#, .net, encoding, character encoding, ascii"
} |
Code is breaking after I clicked Ctrl+S in VSCode
If I'm clicking CTRL + S in VSCode, the code is breaking. Please see the screenshots
**Before**
 is on the line L, which is perpendicular to the plane with equation $x + y + z - 1 = 0$
The point A is reflected in the plane. Find the coordinates of the image A?
I have already determined the coordinates of the foot of the normal, which is at $(\frac 1 3, \frac {-2}3,\frac 2 3)$
Many thanks for your help! | The normal vector to the plane is
$n=(1,1,1)$
the parametric equations of the line are
$$x=2+t,\;y=5+t,\;z=-1+t$$
the symetric $S(x,y,z)$ is such that the middle is in the plane;
$$\frac{2+2+t}{2}+\frac{5+5+t}{2}+\frac{-1-1+t}{2}-1=0$$
which gives $3t=2-4-10+2=-10$
and $$S(-\frac{4}{3},\frac{5}{3},-\frac{13}{3})$$ | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "geometry, vectors, plane geometry"
} |
Freezing Python 3.6
To utilize the inherent UTF-8 support for windows console, I wanted to freeze my script in python 3.6, but I'm unable to find any. Am I missing something, or none of the freezing modules updated for 3.6 yet?
Otherwise I'll just keep a 3.5.2 frozen version and a 3.6 script version for computers with English consoles.
Thanks. | The bytecode format changed for Python 3.6 but I just pushed a change to cx_Freeze that adds support for it. You can compile it yourself or wait for the next release -- which should be sometime this week. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "pyinstaller, cx freeze, python 3.6"
} |
Get domain name of incoming connection
I don't find any information on this topic on the internet and asked here. For example I have server with IP 1.1.1.1 and 2.2.2.2 and two domain names pointing to it one.example.com and example2.net, and socke listening on port 1234 for incoming connections.
For example:
C/C++:
listenfd=socket(AF_INET, SOCK_STREAM, 0);
bind(...);
listen(...);
while(...) accept(...);
or Java:
ServerSocket socket = new ServerSocket(1234);
while(...) {
Socket connectionSocket = welcomeSocket.accept();
...
}
When client accepted on my socket I need to know what domain name/IP is used by the client to connect. It may be one.example.com or example2.net and/or IP 1.1.1.1 or 2.2.2.2 (if connected using IP only).
Apache somehow determined ip/domain of incoming reques, and I need to do such thing in pure socket code. C++ (main) or Java (or any other) accepted, I need to know mechaniics of this. | The IP is stored inside the IP packet header and you can read it from there. In order to get the host, you'll probably have to ask a DNS server by sending a request (or use a function which does it for you). You can find examples for both of the problems, even on this site | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "java, c++, sockets, domain name"
} |
android multiple screen sizes
I have 3 activity_main.xml files in a folder a normal, large and xlarge file each, when I run the app on the Android Studio emulator on the Nexus 4, Nexus 7 and Nexus 10 they all have the regular main file showing not the large or xlarge. Am I missing something?.
As requested here's some screenshots of the files:
Full res folder in Windows Explorer
res folder in Android Studio | The correct folders to limit between phone, 7" tablet and 10" tablet are:
layout/ (default)
layout-sw600dp/ (7")
layout-sw720dp/ (10")
`sw` is: "smallest available width"
you can read more about it here: <
> Beginning with Android 3.2 (API level 13), the above size groups are deprecated and you should instead use the swdp configuration qualifier to define the smallest available width required by your layout resources | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "java, android, xml, android activity"
} |
How can I add parameters with unwrapped name of struct SoapHeader in C#
If I use object SoapHeader a have I a struct with name of SoapHeader (xml element MySoapHeaderName):
<Envelope>
<Header>
<MySoapHeaderName>
<param1>111</param1>
<param2>222</param2>
</MySoapHeaderName>
</Header>
<Body>
.....SomeBody.....
</Body>
And I want to remove tags MySoapHeaderName
<Envelope>
<Header>
<param1>111</param1>
<param2>222</param2>
</Header>
<Body>
.....SomeBody.....
</Body>
</Envelope>
How Can I do this? | I use **XmlTextAttribute** for param in soapheader. I added so many soapheaders classes as i need and the result is what i'm waiting for:
public class param1 : SoapHeader
{
[XmlTextAttribute()]
public string MyParam1;
}
public class param2 : SoapHeader
{
[XmlTextAttribute()]
public string MyParam2;
}
And set property to the method:
[SoapHeader("param1",Direction=SoapHeaderDirection.InOut)]
[SoapHeader("param2",Direction=SoapHeaderDirection.InOut)]
public someresult MyMethod
Header is:
<Header>
<param1>111</param1>
<param2>222</param2>
</Header> | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "c#, soap, header"
} |
JSON decode (JQuery and JavaScript and little PHP)
Ho ho ho, i can't decode response from php.
Json file:
{
"tableWidth":80,
"thColor": "51, 157, 221"
}
This is my awesome php function:
public function lg_getJsonSettings(){
$file = file_get_contents("settings.json",true);
$file = json_encode($file);
echo $file;
}
And JavaScript:
function lg_veriflyChanges(){
result = $.getJSON("/Controller/lg_getJsonSettings");
console.log(result);
}
On click, i call JS function. After i get response, firebug talking with me :) And what he saying ? "Zhu-zhu-zhu" :)
Seriously:
response
object console log
I try use JSON.parse(result) and $.parseJSON, but it didn't work.
Error " JSON.parse: unexpected character at line 1"
I hope, you help. | Your `JSON` is valid but i doubt the usage of `getJSON` doesn't work that way.
So, As jQuery.getJSON() documentation suggest you should use `getJSON` method like this ,
$.getJSON( "/Controller/lg_getJsonSettings", function(json) {
console.log(result);
});
Hope this helps.
And moreover using `$.getJSON("/Controller/lg_getJsonSettings");` returns the AJAX state which is an invalid **JSON** ,
{
readyState: 1
}
Thus causing the issue
> SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "json, decode"
} |
Avoid spilling of text to margin when using R markdown and knitr
While generating a pdf file using `rmarkdown` and `knitr`, how to avoid spilling of text of `R` console output to the margins? For example,
---
title: "Illustration"
author: "Temp"
date: "Monday, April 06, 2015"
output: pdf_document
---
Spilling of R output.
```{r}
library("tm")
data("acq")
str(acq)
``` | I have found the most consistent way for me to deal with this is to use the `width` and `strict.width` options to the `str()` function. The `width` option specifies the page width to be used and is supposed to inherit from the active options() setting for width. But, I haven't always found this consistent. The `strict.width` allows you to control how the excess text is handled (cut, wrapped).
---
title: "Illustration"
author: "Temp"
date: "Monday, April 06, 2015"
output: pdf_document
---
Spilling of R output.
```{r}
library("tm")
data("acq")
str(acq,width=80,strict.width="cut")
``` | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "r, latex, knitr, r markdown"
} |
Android drawable resources for different aspect ratio
Screen with resolution 240x320, 480x640, 1536x1152 ... has aspect ratio 0.75, screen with resolutions 480*800 has aspect ratio 0.6 etc.
I need use different resources for different aspect ratio.
Can I specify configuration folder to Android take an image by screen aspect ratio? | You can specify `long` and `notlong` for resources.
Refer to Providing Resources
> long: Long screens, such as WQVGA, WVGA, FWVGA
>
> notlong: Not long screens, such as QVGA, HVGA, and VG | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 4,
"tags": "android, drawable, android resources, aspect ratio"
} |
Check file integrity while writing
I'm doing backup with the command like following:
ionice -c3 tar -ch data | lbzip2 -n 4 | ionice -c3 tee /mnt/smb/out.tar.bz2 > /dev/null
and after that I'm trying to restore data from backup:
lbzip2 -cd -n 10 /mnt/smb/out.tar.bz2 | tar -x
In a hour after start lbzip2 fails due to file integrity error.
/mnt/smb is RAID 1 device on windows machine accessed with SMB protocol.
I suspect errors while writing on disk or sending data with smb but not sure.
So, I've got 2 questions:
1. Is it any way to check archive integrity during writing on disk and retry to write block if check fails?
2. Any ideas how to find out actual reason of the fail? | tar -c ... \
| tee >(md5sum >/tmp/tar.md5) \
| lbzip2 \
| tee >(md5sum >/tmp/bz2.md5) \
> /mnt/smb/out.tar.bz2
Then you can check
md5sum /mnt/smb/out.tar.bz2
and see if it returns the same as what was saved in /tmp/bz2.md5. If so, then you should have no storage problem, and I'd be interested in the exact lbzip2 error message, and whether the saved file can be decompressed by official bzip2. Thanks. (Feel free to contact me in email.) | stackexchange-serverfault | {
"answer_score": 2,
"question_score": 1,
"tags": "linux, backup, samba"
} |
Working out the length of the 3rd side of an isosceles triangle- Pythagoras' theorem
I have been revising some maths equations and see that you can work out the third side of an isosceles triangle using the formula $\sqrt2 x$
$x$ being one of the equal sides.
Could someone explain how this works?
I understand the theorem:
$$a^2+b^2=c^2$$
But, I am struggling to understand the relationship between the two formulas.
Thank you in advance :) | If $$a^2 + b^2 = c^2$$
and $a=b$:
$$a^2 + a^2 = 2 a^2 = c^2$$
You can indeed find the third side of the right triangle with the following formula:
$$\sqrt{2 a^2} = \sqrt{c^2}$$ $$\sqrt{2} a = c$$
Both sides having the same length allows you to turn the sum into a product, which you can partially calculate the square root of. (or at least calculate the root and be able to write down the result in a finite amount of time)
If the angle between the 2 sides of equal length is not 90°, you can start from the general formula for the third side, which also includes the angle $\alpha$ between them:
$$a^2 + b^2 -2ab\cos (\alpha)= c^2$$
again $a=b$:
$$a^2 + a^2 -2aa\cos (\alpha)=2a^2(1-\cos (\alpha))= c^2$$
unfortunately, the angle is still there and the formula does not simplify as much as it does for the special case of 90°. | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "trigonometry"
} |
How can I create a field for code entering with automatic advancing in iOS?
Title might be confusing so: I want to create an input for a 6-Digit code with automatic advancing like apple has on its website for 2FA. So you have 6 Input boxes, click in one enter a number and it automatically advances into the next field, the last field presses the enter button. I am using Swift 3. | You can use the UITextFieldDelegate methods with a set of 6 UITextField controls
Use `shouldChangeCharactersIn` to see that a character has been entered, and move firstResponder to the next field, and finally to the `UIButton`
Alternatively, you could use a `UIPickerView` with 6 wheels, or 6 `UIPickerViews` with a single section, and move on to the next when a value is selected | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "ios, swift, input"
} |
How to create repository on BitBucket remotely?
I want to create a repository from my local machine using hg commands on Bitbucket instead of creating a repo manually on Bitbucket. Is it possible? | I believe the only way to make a BitBucket repo is on BitBucket, either through their web interface, or their API.
This question has details of how to create an empty repo on BitBucket then push local content to it. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 8,
"tags": "mercurial"
} |
Page Load on Refresh in IE8
I'm developing a website and I'm getting a lot of inconsistencies with loading when refreshing a page. Clicking on links functions as expected; no issues there. The problem only occurs when REFRESHING a page. You will notice how it takes forever to load, and in some instances, refuses to load at all.
<
The site was built using WordPress 3.5.1 (< and Foundation 3.2.5 (<
Any assistance on this matter would be greatly appreciated. I'm out of ideas.
Thanks.
**Update:** This may not be IE related. The problem seems to exist in other browsers as well. | I replaced Respond.js with the following script and the problem resolved itself. < | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 5,
"tags": "wordpress, internet explorer, internet explorer 8, responsive design, zurb foundation"
} |
How can you obtain debugging info from private beta apps?
I'm developing an app which I will give to a selected number of people prior to publishing on the android market, for them to play with and see if all is well.
If they encounter exceptions, it would normally be raised on the marketplace console, but the app will not come from the market place, I will send them the APK manually.
My question is, if they encounter exceptions, or I decide I'll stick a load of debugging in so I can work out what they're doing (which activities they access, what input params they use etc), how can I feed that information back to myself for analysis?
First glance idea :
* Write all output to a log, then email that log back to myself when they exit application
This does rely on them actually sending it, and sounds incredibly cowboy, surely there is an easier way of getting a view on how they use it? (exceptions and general usage)
Any suggestions? | You can use Acra library which provides exception handling. You can configure it out of the box to log all exceptions to Google docs spreadsheet file or to your custom script. Lib will do everything for you (like saving log to send only when connection is available). | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "android, functional testing, beta, beta testing"
} |
Random forest on survival data
I should make prediction on survival data, using the random Forest method. My question is: should I follow the same approach as in logistic regression? taking into account only the status variable or whether I should take into account the delay to the event? Are there any specific R functions for survival analysis other than `randomForest`? Or could I use this function for survival analysis as well? I've seen a function called `ranger()` that seems to do random forest on survival data, but I haven't understood much of it. | The phrase "survival analysis" is usually taken to involve time-to-event data, not just event outcomes at a certain time. Otherwise, you're just throwing away potentially important time-to-event data. Also, survival analysis is well equipped to handle censored event times, for example individuals who still haven't experienced the event by the end of data collection. Depending on the study design, that might not be handled well by logistic regression.
If you have time-to-event data, use proper survival analysis. The CRAN survival task view points out some implementations of random-forest survival analysis. | stackexchange-stats | {
"answer_score": 3,
"question_score": 1,
"tags": "survival, random forest, prediction"
} |
Javascript Wrapping Contents of Brackets in quotes
I want to wrap the contents of some brackets in quotes. I have `test(ab)` as an input (in a string) and I want the output to be `test('ab')`, with the addition of the quotes around the `ab`.
I have looked at several answers to similar questions, but cannot get any to wrap the string correctly,
input = input.replace(/\([^\)]*?\)/g, "'$&'");
Wraps the input like so `test'(ab)'`
Demo in action: <
Does anyone have any ideas. Thanks. | \(([^)]+)\)
Try this.Replace by `('$1')`.See demo.
<
var re = /\(([^)]+)\)/gm;
var str = 'test(ab)';
var subst = '(\'$1\')';
var result = str.replace(re, subst); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "javascript, jquery, regex"
} |
Shrinking the boundary of a Riemann surface
Let $X$ be a compact Riemann surface with boundary. Let us shrink each connected component of the boundary into a point. We get a closed topological surface $Z$ with several marked points (which came from the components of the boundary of $X$) such that the complement $Z_0$ of these points carries a complex structure.
> Does there exist a complex structure on $Z$ such that it induces on $Z_0$ its original complex structure?
Rmk. I think that if such a complex structure exists, it is unique. | No. Complex structure on $X$ "knows" whether an end is a hole or a puncture. The conformal invariant responsible for this is called the extremal length of the family of closed curves surrounding the hole/puncture. See Ahlfors, Lectures on quasiconformal mappings.
The simplest case is a sphere with a puncture (conformally equivalent to the plane) vs sphere with a hole (conformally equivalent to a disk). These two things are conformally not equivalent. This is essentially Anton Petrunin's remark. | stackexchange-mathoverflow_net_7z | {
"answer_score": 4,
"question_score": 4,
"tags": "cv.complex variables, complex geometry, riemann surfaces, complex manifolds, teichmuller theory"
} |
Error generating route "/": HTML minification failed. Nuxt js
I developed a nuxt app and it works perfectly when run with "npm run dev". But when I generating the site with "npx nuxt generate" console shows following error. I cant find the error. Please help me.  &, {{a, a}, {b, b}, {c, c}}]
(* {{1 + a, 1 + a}, {1 + b, 1 + b}, {1 + c, 1 + c}} *) | stackexchange-mathematica | {
"answer_score": 2,
"question_score": 2,
"tags": "list manipulation"
} |
Scroll linear layout beyond the content
I think that this is a simple question but I can't figure it out, I have a Scroll View with some text inside and it works perfectly, it only enables scrolling when the content doesn't fit into the screen. The thing is that I want to scroll the content no matter if it fits or not until the last line of the text reach the top of the view leaving blank space below and obviously "hiding" the content above it. I don't know if I'm explaining myself very well, thanks in advance! | Add a dummy view with height equal to the height of device's screen beneath your textview in scrollView. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "android, scroll"
} |
Add reference when creating node Sensenet
I'm working with sensenet and I have something confusing when I create a node in code behind on server side, I need to add a reference field to my node but I don't know how to do that.
I tried some thing like `node["user"] = node1`
but it doesn't work. | you should read it's document I find to add a reference field, you should use some thing like this
node.Addreferences("User", user1);
user1 is one node represent for a user that you need to reference n your field | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "sensenet"
} |
Python - big list issue
I need to create and search a big list, for example list of 3.9594086612e+65 arrays of 10x10 (or bigger list of bigger arrays).
I need to create list of combinations. After I need to filter out some combinations according to some rule. This process should be repeated till only one combination is left.
If I try to create this list it crashes because of the memory after few minutes.
I can imagine, that solution should be to store the data in different way than list in memory.
What is possible, correct and easy way? SQL database? NoSQL database? Or just multiple text files opened and closed one after one? I need to run through this list multiple times. | Hy:
`3.9594086612e+65`
It's more than all computer memory in the world.
(And I do not multiply by 10)! | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "python, bigdata"
} |
Determining the best way to break up code into different folders and namespaces
i have the following directories:
-UI
-BusinessLogic
-DataAccess
-BusinessObjects
if i have a class that is a client stub to a server side service that changes state on a server system, where would that go . . | this code belongs in the recycle bin ;-)
seriously, if you wrote it and don't know where it goes, then either the code is questionable or your partitioning is questionable; how are we supposed to have more information about your system than you have?
now if you just want some uninformed opinions, those we've got by the petabyte:
1. it goes in the UI because you said it's a client stub
2. it goes in the business logic because it implements the effect of a business rule
3. it goes in the data access layer because it is accessing a state-changing service
4. it goes in the business object layer because it results in a state change on the server
it would be more helpful if you told us what the stub actually does; without specifics it is hard to know where it belongs, and/or it is easy to argue in a vacuum about where it "should" belong | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "c#, directory structure"
} |
Wicket TextField with default value
What is an elegant way to create a TextField in wicket which is rendered with a default value besides manually setting the "value" attribute of the component using SimpleAttributeModifier?
For instance, this works:
TextField<String> headline = new TextField<String>("headline", new PropertyModel(backingObject, "headline"));
headline.add(new SimpleAttributeModifier("value", "default value"));
add(headline);
But is there a better way? | `PropertyModel` works both ways. Instead of using the attribute modifier, just change the headline like so:
backingObject.setHeadline("[desired initial text]");
You can do this anywhere, it doesn't have to be after the `TextField` declaration. Of course, if you don't want to touch `backingObject` beforehand, this won't work, but I'm going to assume that's not an issue since you didn't mention it. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 1,
"tags": "java, wicket"
} |
Copy From One Range, Paste To The Same Row But Columns To The Left
My below code is not running? Can't seem to figure out why...
I'm attempting to copy a named range 22 columns to the left of it using the following code, can someone steer me in the right direction?
Thanks!
Sub ApplyFutureYears()
Dim wb As Workbook
Dim ws0 As Worksheet
Dim ws1 As Worksheet
Dim destRng1 As String
Dim sorceRng1 As String
Set wb = ThisWorkbook
Set ws0 = wb.Sheets("Selection")
Set ws1 = wb.Sheets("Non-Union Empl HC")
Select Case ws0.Range("G3")
Case "2015LRP"
sorceRng1 = "Copy1": destRng1 = Range("Copy1").Offset(0, -22)
Case Else
Exit Sub
End Select
ws1.Range(sorceRng1).Copy
ws1.Range(destRng1).PasteSpecial Paste:=xlPasteValues, SkipBlanks:=True
End Sub | here are some changes I would suggest:
Set ws0 = wb.ActiveSheet
and
Select Case ws0.Range("G3").name
and also instead of using the copy command why not just assign values directly, for example:
ws1.range(ws1.cells(1, 20), ws1.cells(10, 2)).value= ws0.range(ws0.cells(1, 1), ws0.cells(10, 1)).value | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "vba, excel, copy paste"
} |
PuttyTray won't reconnect after dropped connections
According to this questions:
PuTTY - Automatic Reconnect After Internet Interruption?
"Tunnelier" is the answer, but I'm wondering if anyone could expound on why Putty/PuttyTray/WhateverPuttyMods don't keep the connection alive/restart when it drops? Or perhaps point me to a working solution that they have personal experience with?
WinSCP has no problem doing this using an SSH connection, so it's gotta be possible. | Well, I just used Tunnelier instead, since no one responded and I can't find anything on the Interwebs. Too bad. Tunnelier's shell is far worse, and I still use plink for some Logstalgia magic. Oh well. | stackexchange-superuser | {
"answer_score": 0,
"question_score": 0,
"tags": "ssh, shell"
} |
Use Lagrange multiplier to find the distance between the point $(3,4,0)$ and the surface of the cone $z^2=x^2+y^2$
> Use Lagrange multiplier to find the distance between the point $(3,4,0)$ and the surface of the cone $$ z^2=x^2+y^2 $$
I wrote the equation of the distance: $$f(x,y,z)=(x-3)^2+(y-4)^2+z^2$$
and ended up with the following equations: \begin{align} 2(x-3)&=2x \lambda,\\\ 2(y-4)&=\lambda2y,\\\2z&= -2z \lambda, \\\z^2&= x^2 + y^2. \end{align} Solving the equations I get $x=\frac{3}{2}$ , $y=2$ and $z=\pm \frac{5}{2}$. Can you help me solve this, because I am confused, I don't know if I should solve the case where $z=0$ and $z \neq 0$? | Look at the third equation $2z=-2z\lambda$. If $z\ne 0$ we get $\lambda=-1$, and that quickly leads to your solutions.
We _do have to consider_ the possibility $z=0$. If $z=0$, that tells us nothing about $\lambda$, but it forces $x=y=0$, because of $x^2+y^2=z^2$. Now check whether $x=0$, $y=0$ satisfies your first two equations. It doesn't. So the only remaining candidates are the ones that you found. | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "multivariable calculus, optimization, lagrange multiplier"
} |
Fix Hardcoded Windows Paths in Java so that it works in linux also
I have a java file that has some hard-coded path something like:
public class ReportBuilder
{
private static final String DIRECTORY = "META-INF";
private static final String REPORT_HTML = "report.html";
public static void createHTMLReport(String projectPath, String artifactName, ValidationResult result) throws MojoExecutionException {
String directoryPath = projectPath + "\\" + "META-INF";
String filePath = directoryPath + "\\" + "report.html";
}
}
Linux its creating `META-INF` with a `\` and that is causing the build to fail.
How can I switch this to OS independent so that when the same is run on Linux it creates `META-INF` with correct path? | Instead of hardcoding separator `\` or `/`, use `File.separator`
String filePath = directoryPath + File.separator + "report.html";
or event better do not use path literals at all but create `Path` object like
Path filePath = Paths.get(directoryPath, "report.html");
such `Path` object you can pass to the `File` constructor/utils but also you can always take String value of the path by calling `toString()` on the instance | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "java, linux, operating system"
} |
UINavigationbar tintcolor not changed in detailviewcontroller
When i am trying to change the navigation bar tintcolor in split view the masterviewcontroller's navigationbarcolor chenged but detailviewcontroller navigation bar color not chenged. here is my code :
[[UINavigationBar appearance] setBarTintColor:[UIColor blueColor]];
[self.navigationController popViewControllerAnimated:YES];
i want to change the navigation bar color throughout the application in iOS7 by clicking on a button can any one help me? | You can simply do it by:
yourDetailViewController.navigationBar.barTintColor = [UIColor blueColor]; | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "ipad, ios7, uinavigationbar, uisplitviewcontroller"
} |
Value of $f'(0)$ if $f(1/x)=0,\ \forall x \in \mathbb{N}$?
> If there exists a continuous and differentiable $(\forall x \in \mathbb{R} )$ function $f:\mathbb{R} \rightarrow \mathbb{R}$ such that $f\left ( \frac{1}{n} \right )=0$ for every _integer_ n not zero, then prove that $f'(0)=0$. [Here $f'(x)$ stands for derivative of $f(x)$ with respect to $x$]
**An Attempt:** Intuitive - In the neighbourhood of 0, there are (nearly infinite) dense numbers of the form $\frac{1}{n}$ and hence since the plot of $f(x)$ should pass through every zero like a wave or so, it seems to have intuitively concluded $f'(0)=0$.
But I fail to draw a good 'mathematical' proof in a formal way. Any such formal explanation? | By continuity $f(0)=\lim_{n\to\infty}f(1/n)=0$. Let $a=f'(0)$. Then $\lim_{h\to0}\frac{f(h)-f(0)}{h}=a$. So for $\epsilon>0$ we find $\delta>0$ such that $|h|<\delta$ implies $\left|\frac{f(h)-f(0)}{h}-a\right|<\epsilon$. If we assume $a\ne 0$, we can let $\epsilon=|a|$ and conclude that in particular $\frac{f(h)-f(0)}{h}\ne0$ for all $|h|<\delta$. But we can certainly let $h=\frac 1n$ for some $n>\frac1\delta$; this leads to a contradiction as $\frac{f(1/n)-f(0)}{1/n}=0$. We conclude that $a=0$. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "functions, derivatives"
} |
How to change scientific outcome in "normal" number?
When I was making my first exercises in PASCAL I came across a very large (scientific) outcome. I asked my coach from course how to fix this. He didn't know the answer.
I searched on Google how to convert this, but no luck finding the right answer. So I thought lets ask here.
The outcome is "2.150000000E+02". Anyone knows how to convert this into normal number like 2150 (or something like that)
PS: The code as requested:
//
program LOON;
var uren,overuren,bruto: integer;
begin
//
writeln('Geef uren, uurloon en overuren in');
//
readln(UREN,OVERUREN,BRUTO);
//
writeln('Het effectieve loon bedraagt' ,(UREN+OVERUREN*1.5)*BRUTO);
//
writeln();
//
writeln('Druk op <ENTER> om het programma te verlaten');
//
readln();
writeln();
writeln('Druk op <ENTER> om het programma te verlaten');
readln():;
end. | If you are using FreePascal, you can use FormatFloat function: `FormatFloat('0.00', Val);`. If you are using old TP use formatting with Write/WriteLn like this: `WriteLn(Val:0:2);`. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "pascal, normalize"
} |
regex optional using allowTypes in primefaces
here is my regex, in local java, it works, but when im trying to put it on p:fileUpload allowTypes it doesn't work.
my goals are 1) "itrs" or "ITRS" is a must 2) "-draft" or "-DRAFT" is optional 3) ".csv" or ".CSV" is a must
i want to filter the filename and file extension as much as possible
this is working on my local: **(itrs|ITRS)((-draft|-DRAFT)?)(\\.|\/)(csv|CSV)$** | You may use either
allowTypes="/^(?:itrs|ITRS)(?:-draft|-DRAFT)?\.(?:csv|CSV)$/"
or, if `dRaFt` and `ItRS` are also accepted, you may shorten the pattern a bit using `i` case insensitive modifier:
allowTypes="/^itrs(?:-draft)?\.csv$/i"
Note the use of `/` regex delimiters here. Also, see an example in PrimeFaces _"FileUpload - Single"_ docs illustrating the use of regex delimiters.
**NOTE** : If you really need to match `.` or `/` before `csv`, replace `\.` with `[.\/]`. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "java, regex, primefaces"
} |
Setup devise with custom registration controller
I'm working on a rails site using devise, where we do not want user sign ups just yet. User authentication is so we can login to access restricted parts of the site and add/edit things as we see fit. So for now, I created the following controller:
class Users::RegistrationController < Devise::SessionsController
def new
end
end
And setup my routes in this fashion:
devise_for :users, :controllers => { :registration => "users/registration" }
However, when I run rake routes, I still see a returned value for the create action on the registration controller. Any ideas on how to get rid of it? | Try using `:registrations` instead of `:registration`. Also, it seems like your custom controller class should be defined via:
class Users::RegistrationsController < Devise::RegistrationsController | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 5,
"tags": "ruby on rails, devise"
} |
Check new variable reduced cost with CPLEX
I am working on a Column Generation algorithm. After pricing the new variables and calculating the reduced cost, how can I add the new variable and check if my calculated reduced cost is correct according to CPLEX?
When I add the new variable to the model and reoptimize the RMP (Reduced Master Problem), the new variable enters basis, so its reduced cost is 0, which is ok. However, I would like to check the reduced cost calculated by CPLEX before adding the variable. | I'm not sure which of CPLEX's many APIs you are using, but I think the approach you should use is more or less the same. Namely, before reoptimizing the RMP, set an iteration limit of 0 and optimize the RMP with the new columns you have added. Presumably you have the optimal basis from the previous RMP solve at that point. So, with an iteration limit of 0, CPLEX will not bring any of your new columns into the basis. Instead they will be nonbasic, but the optimization with the iteration limit of 0 will give you CPLEX's calculation of all nonbasic reduced costs, including the ones for your newly generated columns. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "optimization, mathematical optimization, linear programming, cplex"
} |
Better Way to Prevent IE Cache in AngularJS?
I currently use service/$resource to make ajax calls (GET in this case), and IE caches the calls so that fresh data cannot be retrieved from the server. I have used a technique I found by googling to create a random number and append it to the request, so that IE will not go to cache for the data.
Is there a better way than adding the cacheKill to every request?
factory code
.factory('UserDeviceService', function ($resource) {
return $resource('/users/:dest', {}, {
query: {method: 'GET', params: {dest: "getDevicesByUserID"}, isArray: true }
});
Call from the controller
$scope.getUserDevices = function () {
UserDeviceService.query({cacheKill: new Date().getTime()},function (data) {
//logic
});
} | As binarygiant requested I am posting my comment as an answer. I have solved this problem by adding No-Cache headers to the response on server side. Note that you have to do this for GET requests only, other requests seems to work fine.
binarygiant posted how you can do this on node/express. You can do it in ASP.NET MVC like this:
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "None")]
public ActionResult Get()
{
// return your response
} | stackexchange-stackoverflow | {
"answer_score": 36,
"question_score": 60,
"tags": "caching, angularjs"
} |
no mocha tests run or report when using npm with | xargs
I'm trying to use npm to run mocha tests like this:
scripts: {
test: "find ./src ./test -name *.js | xargs mocha --opts mocha.opts"
}
this works fine when I execute it straight from the CLI, but doesn't appear to execute any tests (or at least doesn't display any output from them) when I use npm run test.
FYI: I'm using xargs since mocha has no option to ignore files, and I use emacs, which generates temp files for linting in the same directory | You probably need to escape the `*.js`:
scripts: {
test: "find ./src ./test -name '*.js' | xargs mocha --opts mocha.opts"
} | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "javascript, npm, mocha.js"
} |
Configuration database changes while creating SharePoint web application
While creating a SharePoint web application
What is happening at the configuration database?
What are the files that will be created?
I want to know the background process?
Can you please any one help me? | * Creates a unique entry in SharePoint configuration DB for the Web App and assign GUID to that entry;
* Create and configures a Web application in IIS
* Creates a root folder to store the Web application pages and associated resources;
* Creates and configures an IIS application pool;
* Configures authentication protocol and encryption settings;
* Assign a Default alternate access mapping for the Web app;
* Creates the first content database for the Web application;
* Associate a search service with the Web application;
* Assign a name to the Web application that appears in the Web application list in SharePoint Central Administration;
* Assign general settings to the Web application, such as maximum file upload size and default time zone;
Reference: Link1 | stackexchange-sharepoint | {
"answer_score": 0,
"question_score": 0,
"tags": "sharepoint online, sharepoint server"
} |
How to see hidden or escape characters inside a varchar column?
Using MySQL 5.6.
I have a varchar column that stores addresses as text.
When they come through to my application into a text area box, they are spaced appropriately, like
123 Fake St.
Some City, NJ 12345
I tried inserting a new address directly into the database but it doesn't work correctly inside the GUI, it all came in as one line with no line break, like `123 Fake Str. Some City, NJ 12345`
I just want to be able to examine one of the addresses that does work to see how it was done (this was all done before my time at this company) so I can replicate it for the new address, as I have tried `\n`, `\r\n` to no success.
However, when I do `SELECT address FROM myTable` I just see it as plain text, no escaped characters. How can I view the "raw" form of the address so that I can see how the line breaks were implemented? | You could try copying the value with the letter before and after into the hex function to see which character is being used. In this example in DBfiddle we see that the newline is `0A` which is char(11).
Without having your character we can't examine it!
>
> SELECT HEX('
> ') newline
>
>
>
> | newline |
> | :------ |
> | 0A |
>
_db <>fiddle here_ | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "mysql, sql"
} |
Re-size all images in directory with PHP?
I'm doing some web development I would like to resize all images in a directory using PHP. The directory is public property, and anyone working on the site can insert images (to be used as a random background). Is there a way to check the size of the image that's selected from the array of filenames using PHP? And furthermore, could you cast the image to a particular size if the parameters are too large?
<?php
$bg = glob("imgfiles/*.*"); $add image names to array
$i = rand(0, count($bg)-1); // generate random number size of the array
$selectedBg = "$bg[$i]"; // set background equal to which random filename was chosen
?> | So I would suggest something like:
<?php
$maxw = 1024;
$maxh = 320;
$bg = glob("./imgfiles/*.*"); // add image names to array
$selectedBgPath = "./imgfiles/" . $bg[array_rand($bg)]; // set background path equal to which random filename was chosen
list($width, $height, $type, $attr) = getimagesize($selectedBgPath);
if($width > $maxw || $height > $maxh){
// Resize as needed
// $newSelectedBgPath
}
if(isset($newSelectedBgPath)){
$fp = fopen($newSelectedBgPath, "rb");
} else {
$fp = fopen($selectedBgPath, "rb");
}
header("Content-type: $type");
fpassthru($fp);
exit;
?> | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "php, glob"
} |
Downloading nested pdf files with wget
I am trying to download dozens of PDF files located on pages linked from here:
<
Each PDF is referred to by a URL ending with `/downloadable/download/sample/sample_id/[some three digit number]/`.
I have tried these:
wget -r -l2 -A.pdf
wget -r -l2 -np -A "*.pdf"
wget -r -l2 -np -A "*.###"
It doesn't get the PDFs.
Does it have something to do with the server not being indexed to allow me to access the URLs like a file hierarchy? Is there a way to make it work? | @rajaganesh87 you are guessing at the directory link numbers and are your code does not work for the actual links needed per the base link < and the (.pdf) files correlating to it.
The problem is your being blocked by the
> robots.txt file
>
and your using the dot (.) in
-A .pdf
Try the code below that I tested and it works.
wget -np -nd -r -l2 -A pdf -e robots=off | stackexchange-unix | {
"answer_score": 1,
"question_score": 1,
"tags": "linux, wget"
} |
cp -r * except dont copy any .pdf files - copy a directory subtree while excluding files with a given extension
Editor's note: In the original form of the question the aspect of copying an entire _subtree_ was not readily obvious.
How do I copy all the files from one directory subtree to another but omit all files of one type?
Does bash handle regex?
Something like: `cp -r !*.pdf /var/www/ .`?
**EDIT 1**
I have a find expression: `find /var/www/ -not -iname "*.pdf"`
This lists all the files that I want to copy. How do I pipe this to a copy command?
**EDIT 2**
This works so long as the argument list is not too long:
sudo cp `find /var/www/ -not -iname "*.pdf"` .
**EDIT 3**
One issue though is that I am running into issues with losing the directory structure. | Bash can't help here, unfortunately.
Many people use either `tar` or `rsync` for this type of task because each of them is capable of recursively copying files, and each provides an `--exclude` argument for excluding certain filename patterns. `tar` is more likely to be installed on a given machine, so I'll show you that.
**Assuming you are currently in the destination directory,** the shell command:
tar -cC /var/www . | tar -x
will copy all files from `/var/www` into the current directory recursively.
To filter out the PDF files, use:
tar -cC /var/www --exclude '*.pdf' . | tar -x
Multiple `--exclude` arguments can be given, so:
tar -cC /var/www --exclude '*.pdf' --exclude '*.txt' . | tar -x
would exclude .txt files as well. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "bash, sh, glob, cp"
} |
Block face with Adobe Lightroom
i'm new into Adobe Lightroom and don't have any basic skills with it. I want to ask a question that maybe this is very basic to you.
Please take a look on picture below, the object's face is blocked with black color, how to block face with Adobe Lightroom like this? Can i done this with brush/something else?
 | Yes, it's possible and very easy. Choose Adjustment Brush tool (`K` in Wiindows), set Exposure to the lowest level and paint on parts of the image you want to be black. If the "blackness" is transparent, just paint once again over it!
Here is an example:
 this is what i got so far:
KeyboardEvent keyEvent = new KeyboardEvent('keypress');
window.onKeyPress.listen((KeyboardEvent event){
KeyEvent keyEvent = new KeyEvent.wrap(event);
if(keyEvent.keyCode == KeyCode.ESC){
//do stuff
}
});
window.dispatchEvent(keyEvent);
This works as expected. The onKeyPress listener triggers.
But i didn't find out how to set a KeyCode for my KeyBoardEvent? | Can't use `dispatchEvent`. Try:
import 'dart:async';
import 'dart:html';
void main() {
Stream stream = KeyEvent.keyPressEvent.forTarget(document.body);
stream.listen((KeyEvent keyEvent){
if(keyEvent.keyCode == KeyCode.ESC) {
// do stuff
}
});
stream.add(new KeyEvent('keypress', keyCode: KeyCode.ESC));
}
as described in < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "events, keyboard, dart"
} |
How to define and run procedure/function using record?
I want to define record with procedure or function. Can you help with syntax?
Type TRec = record
s: string;
p: procedure;
end;
procedure run;
Const
Rec: TRec = ('',run);
procedure run;
begin
end;
It's possible to run later:
Rec[0].run;
? | This works (see syntax comments in code):
Type
TRec = record
s: string;
p: procedure; // As Ken pointed out, better define a procedural type:
// type TMyProc = procedure; and declare p : TMyProc;
end;
procedure run; forward; // The forward is needed here.
// If the procedure run was declared in the interface
// section of a unit, the forward directive should not be here.
Const
Rec: TRec = (s:''; p:run); // The const record is predefined by the compiler.
procedure run;
begin
WriteLn('Test');
end;
begin
Rec.p; // Rec.run will not work since run is not a declared member of TRec.
// The array index (Rec[0]) is not applicable here since Rec is not declared as an array.
ReadLn;
end. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "delphi, function, record, procedure"
} |
Choosing between command line or menu in bash script
I'm attempting to create a script that converts either a decimal, octal or hexadecimal number into binary.
I cannot use the bc command so I have create a function for each of these. I have a menu that allows you to select what number you wish the convert. e.g 1 for decimal, 2 for octal and 3 for hex.
I want to be able to also have a command line option so that: test.sh D 45 would convert 45 in decimal to binary, test.sh O 12 would convert 12 in octal to binary, test.sh H 0x1A would convert 0x1A in hexadecimal to binary
Is there a way to only use the menu if there are no command line arguments? | if [ $# -gt 0 ]
then
# Get parameters from arguments
else
# Get parameters with menu
fi
# Calculate the result | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -1,
"tags": "linux, bash, shell"
} |
fancybox: display long caption in multiple lines with the same width as the large image?
I am using Fancybox 2.1.5 to display a popup window with a large image. Here is the html:
<div class="webmedia">
<a href="my-large.jpg" class="click-magnify" title="A very long caption, wider than its image">
<img src="my-small.jpg" width="283">
</a>
</div>
Javascript:
$('.click-magnify').fancybox({
});
When the popup is displayed, the caption extends wider than the large image. I hope to display the caption in multiple lines with the same width of the large image.
Thanks and regards! | You may try changing the _title_ `type` like :
$(".click-magnify").fancybox({
helpers : {
title: {
type: 'inside'
}
}
});
**;
But I don't want to do that. I need to keep the same object reference.
The issue comes from the pipe in vital-value.component.html
{{ _vitalValue | vitalFormat }}
It works if I use instead
{{ _vitalValue.value }}
Is there a way to keep the pipe but to make the refresh happen?
Thanks! | Although this is not recommended, try making the pipe impure.
@Pipe({
name: 'vitalFormat',
pure: false
})
But beware of the consequences to your App's performance. It's not really recommended to use `impure` pipes.
Read through here:
> Angular executes an impure pipe during every component change detection cycle. An impure pipe is called often, as often as every keystroke or mouse-move.
>
> With that concern in mind, implement an impure pipe with great care. An expensive, long-running pipe could destroy the user experience. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 2,
"tags": "angular, angular pipe, angular2 changedetection"
} |
I wanna perform back & forth functionality animation, I've used odd & even click counts but it stops after 1st cycle
//Initializing clickCount
int clickCount = 0;
public void animateButton(View view) {
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clickCount++;
if(clickCount%2==0 && clickCount==0){ //clickCount=0 declared in global variable
button.animate().translationX(400);
}
else {
button.animate().translationX(-400);
}
}
});
Or you can suggest any other method too. | Your if statement is true only once, at initialization. Afterwards clickCount is 1,2,3,... which is `clickCount==0 : False` so the if statement is also false. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "java, android"
} |
Database design for a simple social site
I'm currently trying to design the database for a simple social site. I'm using MySQL for my database. Currently, I only have a users table. Basically, I want users to be able to add friends and be able to list their friends. I'm thinking of creating a friends table, something like:
friends table
user_id
friend_id
And whenever someone adds a friend, it will create an entry. I'm not exactly sure if I'm on the right direction. Another question, is there a way to retrieve all 2nd degree friends?(friends of friends) Any help would be appreciated. Thanks a lot in advance! | Yes, you're on the right path.
You can retrieve 2nd degree friends by joining the friends table to itself
select t2.friend_id
from friends t1
inner join friends t2 on t1.friend_id = t2.user_id
where t1.user_id = ...
One thing to consider is commutativity - if A is a friend of B, is B a friend of A ? | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "mysql, ruby on rails, database, database design, social networking"
} |
Wireless radio wave propagation and disappering
I apologise for my strange question :-) I suppose that when I turn on an wifi device it emit continuously radio wave. What happens when I turn off the device? The last wave emitted how long bounce in the room? Thanks | In a small room, say 3 m wide, with radio travelling very close to 300,000,000 m/s, it takes about 10 ns to cross the room. Each time it bounces off the wall it will be very much attenuated. Perhaps it takes five bounces before it's entirely insignificant, so that's about 50 ns. It's pretty brief. | stackexchange-networkengineering | {
"answer_score": 3,
"question_score": 1,
"tags": "wireless"
} |
What is the use of glMatrixMode(GL_MODELVIEW) in resize()?
static void resize(int width, int height)
{
const float ar = (float) width / (float) height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity() ;
}
viewport and projection matrix got resized,when we change the window size ,but what is the use of calling GL_MODELVIEW inside resize function. | `glMatrixMode` sets current matrix type. All matrix-modifying operations (`glLoadIdentity`, `glLoadMatrix`, `glTranslatef`, ...) using current matrix.
Given code sets current matrix type to projection, modifies it, then sets current matrix to modelview so subsequent code (outside of this function) will modify modelview and not projection, and resets it to identity matrix (which is probably unnecessary, depending on draw function). | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c++, opengl, graphics"
} |
Graphviz default label for edge
I am making graph using graph. Is there any way I can get default edge label ?
digraph G {
a -> b [label="a -> b" ];
b -> c [label=" b ->" ];
}
I want to get label default not manually. | You can read the Graphviz Document. Also I gave same kind of questions answer.
You can look at my answer here
If you can not get solution from my answer you can do comment here.. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "python, graphviz"
} |
Playframework generateSignedToken vs generateToken
i have used both methods generateSignedToken and generateToken but i don't fully understand the difference between both (besides the string length)...which one is better to generate a nonce token?
btw i read the api description for both methods but i find it confusing... | The `generateSignedToken` method uses the `signToken` method on a token generated by `generateToken` (as you can see in the source on github). The documentation says about the signToken method (Documentation of play.libs.Crypto):
> Sign a token. This produces a new token, that has this token signed with a nonce. This primarily exists to defeat the BREACH vulnerability, as it allows the token to effectively be random per request, without actually changing the value.
Wikipedia on the BREACH vulnerability | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "scala, playframework, playframework 2.1, playframework 2.2"
} |
Granting access to view but not the underlying tables
Lets say I have three schemas, `a`, `b` and `c` in an Oracle database.
I have a table, `a.t`.
I have a view, `b.v`, which is just view on `a.t` (in the real case there is actually `a.t1`, `a.t2` etc).
I want to grant `c` select access on `b.v` but not `a.t`.
What are the grants I have to issue for `a.t` and `b.v`? | You can achieve it by grant the `SELECT PRIVILEGE` to user `'a'` `WITH GRANT OPTION`
Grant user b to select a.t:
GRANT SELECT ON a.t TO b WITH GRANT OPTION;
Grant user c to select on b.v:
GRANT SELECT ON b.v TO c; | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "sql, oracle"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.