INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Selecting backpacking cooking pot – teflon, aluminum, steel, titanium, or cast iron?
What are the relative advantages / dangers of different cooking wear? I'm a one-pot gourmet that has been using the same stainless steel pot for 15 years, but am considering an upgrade.
Some things I have heard but not substantiated: teflon flakes off and you might ingest it. Aluminum can leech into acidic foods. Titanium shatters in cold? Cast iron makes the best flap-jacks...
|
The absolute best is going to be titanium, but it also happens to be the most expensive. I'm not sure where you heard that it shatters in the cold, but being a space age metal I would think it can handle cold Earth's temperatures just fine.
If you can't shell out the cash for titanium it's more or less a toss up between aluminum and stainless steel. Technically aluminum leaches, but so slowly that for just your backpacking gear it's not a problem. Stainless steel doesn't leach but also doesn't distribute heat as well, so you need to be sure to stir your food more, but that's not a big downside in my book. I use stainless steel myself.
One other recommendation I need to make is, no matter what the material, find a pot with a tight-fitting lid. Getting water to a boil with a tight-fitting lid is MUCH quicker and saves you fuel.
As for cast iron, it gives your food the best flavor but is extremely heavy. Use it for camping trips but not backpacking.
|
stackexchange-outdoors
|
{
"answer_score": 24,
"question_score": 22,
"tags": "gear, backpacking, cooking"
}
|
Shared drive option is missing
I'm trying to setup a shared drive using Google Workspace. I found the following page in the Learning Center:
Set up a shared drive
Here I see the following image:

> Supported editions for this feature: Business Standard and Plus; Enterprise; Education and Enterprise for Education; Nonprofits; G Suite Business; Essentials. Compare your edition
If your account edition supports this feature, report this issue to your admin. If you are the admin verify that it's enabled and turned on for you.
Resources
* Compare Google Workspace editions
* Manage shared drive users and activity
|
stackexchange-webapps
|
{
"answer_score": 3,
"question_score": 3,
"tags": "google drive, google workspace for business, google shared drive"
}
|
Can you make Golang drop packets on writes rather than block?
Given a channel of length N, I want to write to it only if it is not full. Else I will drop this packet and process the next one.
Is this possible in GOlang
|
You can use `select`. Example:
package main
func main() {
ch := make(chan int, 2)
for i := 0; i < 10; i++ {
select {
case ch <- i:
// process this packet
println(i)
default:
println("full")
// skip the packet and continue
}
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 18,
"question_score": 8,
"tags": "go"
}
|
Ambari redirects to NiFi automatically
I installed NiFi in my Hortonworks and whenever I start my session in Ambari I'm redirected to NiFi. Has anyone any idea how to change it so that my localhost:8080 does not automatically redirect to NiFi? I attached the image below.

|
You'll need to change the port that NiFi runs on since the default is 8080 which is also the port that Ambari runs on. The port is defined in nifi.properties with the property nifi.web.http.port=8080
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "apache nifi, hortonworks data platform, ambari, hortonworks dataflow"
}
|
Setting up AnkhSVN with Visual Studio 2010
I have created a repository in a server using VisualSVN server. I Installed AnkhSVN in my local machine and now i'm trying to add my local source to the repository. I right clicked on the Soulution and clicked on Add "Solution to Subversion" and the "Add to subversion " popup appear. Once i typed in the Repository Url, it doesn't show the repository down below and i cant add this to the repository.
The url is <
I tried with the port number as well <
I checked the server and the SVN server is running over there.
I have not installed TortoiseSVN or any other in my local machine other than AnkhSVN. Do i need to? What am i doing wrong?
Thanks.
|
Try opening View -> Repository Explorer. There use the + button to add a URL. This is just to confirm communication with the server.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 1,
"tags": "svn, visual studio 2010, tortoisesvn, ankhsvn, visualsvn server"
}
|
Merge Date and Time into one variable in php
I have got 2 variables like:
$date //2011-01-01
$full_old_date //1999-01-01 12:00:00
Now I want to combine the new date and the time of the $full_old_date together as a new variable like:
$full_new_date //2011-01-01 12:00:00
What should I do to extract only the time from the old one and combine them together as a new date variable?
|
Hope this helps (assuming you have these values as 'strings' and not date/timestamps):
$date = "2011-01-01";
$full_old_date = "1999-01-01 12:00:00"
$full_new_date = $date . ' ' . trim(substr($full_old_date,-8));
//substr() - This gets the last 8 characters of the $full_old_date variables
//trim() - This function removes any whitespace at the edges of the substring
There are many ways to do this, however this is one way of doing it.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "php, date"
}
|
Common syntax to specific stdout as "output file"
I have a mainly unixoid software that usually writes to a file that is specified as a parameter.
Now I want to add the ability to write to stdout instead. But to write to a file should still be the standard behavior.
I think I saw shell commands like
command --outfile -
or
command -
Is that a common practise? Unfortunately I do not recall the commands that worked like that.
|
A common method is to write to stdout when the last argument in the parameter list is a hyphen (or in some cases, a double-hyphen).
If you are creating a program, you can go an extra step and use an explicit `-stdout` parameter for printing to standard output. Since the `-` syntax is not an official standard, I would suggest that it is better to err on the side of readability.
|
stackexchange-superuser
|
{
"answer_score": 3,
"question_score": 1,
"tags": "shell"
}
|
Manually leave room after socket.disconnect()
I've seen this on the socketio wiki.
> Note that it is not necessary to call socket.leave() during the disconnect event. This will happen automatically. Empty rooms will be automatically pruned so there is no need to manually remove them.
But after some tests, it is not working. After disconnecting (server-side or client-side), the socket is not removed from his room. So my question is, the previous text is still relevant or not ? Because either i have a problem in my code or the wiki is not updated.
I've tried to check inside the socketio code to check this out but i couldn't track the code to see what happens.
If the text is still relevant, when is the room leaved, after or before the code that we put inside the on('disconnected') event ?
Thank you.
|
You could always delete the entry under `socket.namespace.manager.rooms` that contains your socket.
socket.join(socket.id);
console.log(socket.namespace.manager.rooms['/'+socket.id]);
socket.namespace.manager.rooms["/"+socket.id].splice(socket.namespace.manager.rooms["/"+socket.id].indexOf(socket.id),1);
console.log(socket.namespace.manager.rooms['/'+socket.id]);
This returns
[ '36_IcxqkWgBgLfC6p3Yj' ]
[]
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "socket.io"
}
|
What is the smallest distance between a decaying vertex and an interaction point a detector can measure?
A short lived particle is created at the interaction point and then decaying a distance $d$ away, in some detector. My question is what is the smallest distance $d$ that can be measured experimentally? Of course it will be different from a detector to another.
Any links that explain how this analysis, of discovering a particle, is done experimentally would be appreciated.
|
See Tao Han's _Collider Phenomenology: Basic Knowledge and Techniques_ , Page 22, and the referenced articles.
As a rough guide, for the ATLAS detector the resolution is of the order $10\mu m$. It's also possible to resolve the vertex displacement in the longtitudinal direction alone, in the case that there's only one charged particle track to extrapolate backwards. In this case the resolution is about an order of magnitude worse.
The full formula for the resultion also depends on the transverse momentum and the angle between the particle track and the beam line.
|
stackexchange-physics
|
{
"answer_score": 5,
"question_score": 6,
"tags": "experimental physics, particle physics, particle detectors"
}
|
Плавная прокрутка якорей
Всем привет, Я использую этот простенький код для плавного скролла по якорям и всё это чудесно работает:
function scrollNav() {
$('a[href*="#"]').click(function(){
$('html, body').stop().animate({
scrollTop: $( $(this).attr('href') ).offset().top - 73
}, 400);
return false;
});
}
scrollNav();
НО, на разрешениях 1023 - 1367 был применен медиа запрос для более читабельного вида сайта :
@media (min-width: 1023px) and (max-width: 1367px) {
body {
zoom: 0.8;
}
}
И вот как раз скролл по якорям на этих резолюциях работает некорректно.
Может кто подскажет как решить эту задачу?
Спасибо за любую помощь
|
умножать прокрутку тоже на 0.8 при этих разрешениях
function scrollNav() {
$('a[href*="#"]').click(function(){
let scrollTop = $( $(this).attr('href') ).offset().top;
if($(window).width() > 1023 && $(window).width() < 1376){
scrollTop = scrollTop*0.8;
}
$('html, body').stop().animate({
scrollTop: scrollTop - 73
}, 400);
return false;
});
}
scrollNav();
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "javascript, html, jquery, css, scroll"
}
|
Merging two dataFrames and drop one afterwards
I have two DataFrames `df_1` `df_2` and they have mutual colmms eg `'Name'`. how ever the names underneath the `'Name'` column may differ, so I merged them into `df` frame and created new several columns out of both of them.
Is it possible to drop `df_2` and keep all the newly created columns and df_1? in no step? one line ? Or `df_1` with the same columns than `df`
df_1 Name Age Sex Jop RoomID
df_1 Name Age Sex Jop address RoomID
df Name Age Sex Jop address Fmaily_size Floor_NR e.g
That df_1 looks like this `Name Age Sex Jop address Fmaily_size Floor_NR e.g` Same columns, type and order than `df`.
|
IIUC:
df_1.merge(
df_2, on='Name', how='outer',
suffixes=['', '_']
).reindex_axis(df_1.columns.tolist(), 1)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "python, pandas"
}
|
Disable Magnifying Glass in UITextField
Is there a way to prevent the user from moving the cursor in a UITextField? I'd like it to stay at the end of the string.
|
There's no way to prevent them from moving the cursor. You can, however, prevent them from editing the text except at the end by implementing the
`– textField:shouldChangeCharactersInRange:replacementString:`
method in your text field's delegate.
Edit: you can also set `userInteractionEnabled` to `NO` so that the user can't tap the field. Call `becomeFirstResponder` manually so that the field gets focus since the user can't tap to focus.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 8,
"tags": "iphone, cocoa touch, uitextfield"
}
|
partition function including multiplicities.
It could be ambiguous question.
Is there a notion for a partition function including "multiplicities"?
For example, the above "multiplicities" means that
$$3=1+1+1={\color{red}{1+2}}={\color{red}{2+1}}$$
counting $1+2$ and $2+1$ are distinguished.
If anyone knows the relevant concepts, can you give me a reference or a textbook?
Thank you!
|
When order matters, the term used is Compositions rather than Partitions. As a first step you could check out the Wikipedia entry for these.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "combinatorics, integer partitions"
}
|
How to get the vector between two vectors?
I have three points with x and y values to start with. What I actually want is the position where the actual vector would go (look at image provided). Can you help me ? I tried around a little bit with atan2 and parallelograms, but unfortunately without success.
!Image
|
Again, I'll remind that I might be missing something, but I _think_ this is pretty simple addition of vectors:
let point A be (700, 500)
let point B be (400, 400)
let point C be (650, 100)
let point D be (???, ???)
the vector from A to B is: (-300, -100) // i.e. x = B-A, 400 - 700, etc
the vector from A to C is: (-50, -400)
Adding these together yields the vector from A to D: (-350, -500).
Adding that vector to point A yields the coordinates of the point D: (350, 0)
|
stackexchange-stackoverflow
|
{
"answer_score": 10,
"question_score": 8,
"tags": "vector, position"
}
|
Back arrow missing in my Activity
I have created 2 activity in my android application. 2nd activity will launch from first activity button click. activity launches but I can not see back arrow. I have to use hardware button to go back to main activity.
This is my second activity xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.xxxxxxx.widget.MonthView
android:layout_width="300dp"
android:layout_weight="1"
android:paddingLeft="30dp"
android:layout_height="fill_parent" />
</LinearLayout>
How to get the back arrow button on header of second activity?
I am using java code to launch as follow
Intent intent = new Intent(getActivity(), CalendarActivity.class);
getActivity().startActivity(intent);
|
To display the "<" you should be using :
getActionBar().setDisplayHomeAsUpEnabled(true);
than, to intercept the "Home Button" press :
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
if(item.getItemId()==android.R.id.home){
finish();//finish your activity
}
return super.onMenuItemSelected(featureId, item);
}
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 3,
"tags": "android"
}
|
Square an array's size with the same pattern repeated
Given an array `int X[x_size]`, I'd like to make a new array `int Y[x_size * x_size]` and copy the values of `X` in order.
For example, given `X = {0, 1, 2}`, I'd like array `Y` to be `{0, 1, 2, 0, 1, 2, 0, 1, 2}`.
int main(int argc, const char * argv[]) {
int x[3] = [0,1,2];
int * y = makeY(a,3);
}
int * makeY(int x[], int size) {
int *y = new int[size * size];
for(int i = 0; i < size; size+=2)
for(int j = i; j < j + (size - 1); j++)
for (int i = 0; i < size; i++)
y[j+i] = x[i];
return y;
}
|
If you want to work with pointers, I suggest passing the pointer of y instead of returning it since it is a local variable.
void makeY(int * x, int * y, int size){
for(int i=0; i<size; i++){
for(int j = 0; j < (size); j++){
y[j*size + i] = x[i];
}
}
}
Now you can use it like this:
int main()
{
int size = 3;
int x[size] = {0, 1, 2};
int y[size * size];
makeY(x, y, size);
}
|
stackexchange-stackoverflow
|
{
"answer_score": -1,
"question_score": -1,
"tags": "c++, arrays"
}
|
Riemann-integration problem
## Here is the exercise
> Let $f:[a,b]\rightarrow \mathbb{R}$ be Riemann-integrable. Prove that $f^+$, $f^-$ and $|f|$ are also Riemann-integrable, when
>
> $$f^+=\begin{cases} f(x) & f(x)\geq 0 \\\ 0 & otherwise \end{cases}$$
>
> $$f^-=\begin{cases} -f(x) & f(x)\leq 0 \\\ 0 & otherwise \end{cases}$$
This problem seems so obvious. Why wouldn't $f^+$ be integrable? Anyway, I need to prove this using this hint:
"$f$ is Riemann-integrable if with every $\epsilon>0$ there exists step functions $h\leq f\leq g $ such that $\int h -\int g <\epsilon$."
I have no idea where to start...
|
We prove the Riemann integrability of $f^+$. A similar proof can be done for $f^-$.
As $f$ is Riemann-integrable, for all $\epsilon>0$ there exists step functions $h \leq f\leq g $ such that $\int h -\int g <\epsilon$.
Now define $h^+ = \max(h,0)$ and $g^+ = \max(g,0)$. You can verify that:
1. $h^+, g^+$ are step functions.
2. You have $h^+ \le f^+ \le g^+$ for all $x \in [a,b]$.
3. **And also $g^+ - h^+ \le g-h$ for all $x \in [a,b]$**. This implies $0 \le \int (g^+-h^+) \le \int (g-h) \le \epsilon$
And concludes the proof.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "proof writing, riemann integration"
}
|
How to Display image in <img> element using javascript?
I have an array:
[{
"img_ID": 1,
"ci_ID": 1,
"ciCode": "CI_00001ID",
"Title": "my_images_01",
"Image": "C:\\Users\\SMG48\\Downloads\\Images\\wp2448691-jihyo-twice-wallpapers.jpg"
}]
Is there anyway to show the `Image` on the array in the `<img>` tag using javascript?
|
Inside the function that make you get the array:
function displayImg(array) {
var img;
for (var i = 0; i < array.length; i++) {
img = document.createElement('img');
img.source(array[i]['Image']);
document.appendChild(img); // if you want just to append to parent
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript"
}
|
While loop with a certain amount of loops
repeat=0
echo "Please enter a number dividable by 5"
read input
loop= `expr $input / 5`
while [ $repeat -ne $loop ]
do
echo "repeat"
repeat= `expr $repeat + 1`
done
For this code, so if i enter 15, the code will repeat 3 times, it will echo 3 times of repeat, but from now i keep getting command not find from "repeat =`expr $repeat + 1`. not sure what is happening.
|
Spacing is important in bash. You need to remove the space after the `=`. i.e.
loop=`expr $input / 5`
and
repeat=`expr $repeat = 1`
With that space in place, it is trying to execute the result of the `expr` call, and complaining because there is no command called `3`
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "unix, while loop"
}
|
Swift 2.0 animating images
Trying animate series of images in swift 2.0 but following the video tutorials like < the method that this guy uses are no longer relevant and swift 2.0 no longer allows arrays to be setup in such means. The basic code this guy used is as follows:
class ViewController: UIViewController: {
@IBOutlet var myImageView: UIImageView
@IBOutlet var animationBtn: UIButton
var imageList = UIImage[]() // no longer valid?
@IBAction func animationBtnClicked(sender: AnyObject) {
startAnimation
}
override func viewDidLoad() {
for i in 1...13
{
let imageName = "\(1)"
imageList += UIImage(named: imageName) //line no longer works
}
}
func startAnimation() -> Void
{
myImageView.animationImages = imageList
myImageView.startAnimation()
}
Anyone know a better way in swift 2.0 to animate images or anyway in general how to do this?
|
I hope I will help you
@IBOutlet var myImageView: UIImageView!
@IBOutlet var animationBtn: UIButton!
`var imageList = [UIImage]()`
`imageList.append(UIImage(named: imageName))` or `imageList += [UIImage(named: imageName)]`
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "swift2"
}
|
Sharepoint + VSTO deployment
I've developed a Word template in VSTO. When published it consits of several files including a Setup.exe, several msi files etc.
Due to the fact that my company's security policy won't allow me to store dlls and exes on the server I need an alternative way to provide all the necessary stuff to the end user.
I thoght it would be enough if I:
> 1) execute the setup.exe file on each client machine (it says everything got properly installed)
>
> 2) upload the xxx.dotm file to sharepoint and register it
>
> 3) edit policy settings
but it doesn't. When a user creates a new Document inside sharepoint using "New"->"xxx" the requested document loads without any error message and show the document but Word won't load any extensions / ribbons etc.
What am I doing wrong? Any help would really be appreciated.
|
How are you hosting the assembly? from what you have said so far.. you are hosting the DOTM file on sharepoint, and the custom assembly/ies locally on each client machine. Not sure why you have chosen this approach, however to simply I would recommend you start by confirming your app works when all components are deployed locally. If that works (then your app is fine and its just a deployment issue), try setting up a UNC share and putting the assembly/app files on the share, and the DOTM hosted in sharepoint. check whether that works. if it doesn't your hitting an issue with CAS. refer to the MSDN document on network deployments of VSTO document apps.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "vb.net, sharepoint, vsto"
}
|
What is the point of Large Input?
In Google Code Jam, it gives you 2 or even 3 times the points solving for small input if you are able to solve the problem for large input.
But, I don't understand the point of this. If you make a program that can handle any positive number of cases, it could handle 10 as well as 10000 input cases.
So, when you solve the problem for the small input you should be able to solve for the large input as well, without any code changes.
Am I missing something?
|
> Am I missing something?
Yes - you are missing the time limits. Oftentimes, an algorithm that works fine for small inputs (say, an `O(n^2)` algorithm or even a `O(2^N)` algorithm) takes too long on larger inputs, requiring a substantially different approach.
For example, an `O(N^2)` approach of finding a longest ascending subsequence can be coded in four lines of code with a single array, and it would work fine for inputs of several hundred items. However, that approach would fail for hundreds of thousands of items, requiring an advanced approach that uses a tree or a binary search. Since that different approach takes a lot longer to code, it is natural to reward it with a lot more points.
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 6,
"tags": "algorithm, input"
}
|
Can I create my own command in python?
Suppose I have command like **cd abc/def** , So I want to create own command like ' **a** '.
If I run 'a' command it ,should run command cd abc/def
optiplex-3020:~$ a
So could it be possible and I want to use python as scripting language
|
`cd` is a built-in command and cannot be run by an external program, so you must use your shell:
alias a='cd abc/def'
If you want this to be permanent, put it in your `~/.bashrc` or `~/.zshrc` depending on your shell.
|
stackexchange-unix
|
{
"answer_score": 2,
"question_score": 0,
"tags": "linux, ubuntu, python"
}
|
Is there a way to exit a Greasemonkey script?
I know that you can use `return;` to return from a Greasemonkey script, but only if you aren't in another function. For example, this won't work:
// Begin greasemonkey script
function a(){
return; // Only returns from the function, not the script
}
// End greasemonkey script
Is there a built in Greasemonkey function that would allow me to halt execution of the script, from anywhere in the script?
Thank you,
|
Yeah, you can probably do something like:
(function loop(){
setTimeout(function(){
if(parameter === "abort") {
throw new Error("Stopped JavaScript.");
}
loop();
}, 1000);
})(parameter);
You can simply abort your script by setting the value of variable parameter to abort, this can either be a regular variable or a Greasemonkey variable. If it's a Greasemonkey variable, then you can modify it directly through the browser using about:config in Firefox.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "javascript, greasemonkey"
}
|
Adding image in an iOS Launch Screen - Xcode
This is my Xcode Launch Screen View:  on Android
When I click "add to home screen" from the Brave/Chrome menu, on some sites the icon that is added does not open website but instead opens a custom app created for the website (so called "PWA").
I want to create a simple website link that opens the website in a browser (so I can use search / see the url from the address bar and so on).
How can I do that with Brave or Chrome?
|
After tedious search I was finally able to do it.
Simply put - with Brave/Chrome it seems that it is not possible to add a non-PWA shortcut when PWA-version is defined at the web pages web manifest.
HOWEVER there are separate apps on the app store (I don't link to any specific one here but search for example "create shortcut launcher") that allow you to create "custom" shortcuts. With these apps you can create a simple URL shortcut and define which browser is used to open it.
This solves my problem and this question.
To get the corect icon you have to separately download and set the icon which is quite tedious so if anyone solves how to do this with chrome/chromium then please respond and I will change the accepted answer.
|
stackexchange-android
|
{
"answer_score": 2,
"question_score": 1,
"tags": "chrome for android"
}
|
How to trigger jQuery every second
Hello i have a problem regarding my Javascript code: i want my code to load every second but that won't work here's my Javascript:
$('#search_text').setInterval(function(){
var search = $(this).val();
if(search != '')
{
load_data(search);
}
else
{
load_data();
}
}, 100);
Does anybody know how to fix this problem?
thanks in advance.
|
this pointer here is not actually referring to the search-text element You might have to try below
$('#search_text').setInterval(function(){
var search = $('#search_text').val();
if(search != '')
{
load_data(search);
}
else
{
load_data();
}
}, 1000);
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "javascript, jquery"
}
|
Symfony2 create symbolic link to custom resources
On symfony2 install or update, there are symbolic links created for different bundles on web folder inside bundles folder.
I want to do same on symfony2 install/update command to create more symbolic links for different resources, there path is outside the bundles.
How can I do that without writing class or functions?
|
It's composer feature to execute scripts on some events. You might have a look to this article.
Example:
{
"scripts": {
"post-install-cmd": [
"script.sh --param=value"
],
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "php, symfony, composer php, assets"
}
|
why a non-dba user can log in as sysdba?
in my oracle instance, I have a user called `xxx`, I remembered I just grant `resource` and `connect` role to `xxx`, but now the user can log in as `sysdba`(via pl/sql developer), even after executing `revoke dba from xxx` through `sys` account, the user `xxx` can still log in as `sysdba`, so why? What should I do to revoke his `dba` role?
_PS_ : now I execute `revoke dba from xxx`, it reports an error: dba role is not granted to xxx
|
the `DBA` role and `SYSDBA` roles are different.
revoke sysdba from xxx;
Read here about Administrative Privileges
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "oracle, plsqldeveloper"
}
|
How To Crash An App
> **Possible Duplicate:**
> Proper way to exit iPhone application?
How can I Crash my app?
i want To crash the app if the user press close in this code
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Alert!"
message:@"What To Do To You App!"
delegate:self
cancelButtonTitle:@"Close"
otherButtonTitles:@"Open In Safari",nil];
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 1)
{
NSLog(@"Open in Safari");
}
else
{
NSLog(@"Close");
}
}
|
Use-
[[NSThread mainThread] exit];
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": -7,
"tags": "ios, crash"
}
|
Replace spaces in file names from cmd line unix
Hi I have a bunch of files with spaces in the name, is there a way to mv them to new files without spaces in. For example I have the file Hello World.pdf I want to move it to Hello_World.pdf. Obviously for the one file I can use the mv command but I want to do it to all files in a folder.
Thanks
|
You can use the **tr** or **sed** commands for this:
for file in *.pdf
do
newname=$(echo $file | tr ' ' _)
mv "$file" $newname
done
Note that this uses the newer POSIX syntax for command substitution: $( _command_ ).
If you're using a really old Bourne shell, you'll need to use backticks:
newname=`echo $file | tr ' ' _`
|
stackexchange-superuser
|
{
"answer_score": 10,
"question_score": 6,
"tags": "command line, unix, filenames"
}
|
using http package in flutter for networking APIs is a good practice OR its better to use Retrofit, chopper or dio?
Actually I want to know which package is more beneficial from the user perspective, if there are other advantage pls let know in the comments. THANK YOU
|
From the user's (consumer's) perspective, `http`/`dio`/etc doesn't matter at all.
From a developer's perspective (my experience), it has been easier to handle exceptions with the `dio` package than using `http`. I had a lot of frustration trying to catch HTTP Response 500 when I was using `http`, and my app keeps on crashing even though my code had a `try`/`catch`. Trying to add timeouts in my `http` code has been especially difficult. But with `dio`, they have a built-in solution (`connectTimeout`).
Also in general, writing networking code with `dio` (I haven't tried `Chopper` or `Retrofit`) is faster and easier than writing code using `http`.
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 2,
"tags": "flutter, retrofit, flutter dependencies"
}
|
How to reject all zeros in any format regex
I almost solve my problem, but I think I forgot or misplace one character. I want to reject zeros value, including this format 0.00.
^((?!0+$)\d+)(\.0{2})$
My Regex
At first I only wanted to reject zero value, then I wrote `^(?!0+$)\d+$` Then I have another requirement to only accept xxx.00 this format. two digits decimal. And ended up like `^((?!0+$)\d+)(\.0{2})$` It does reject number other than .00 format, but accepting 0.00. I did negate the zero at the first group, but why the regex accepting it?
0 //false
9 //false
1000.00 //true
.00 //false
10.00 //true
434543.12 //false
324.00 //true
40000 //false
0.00 //should be false but mine is true
000.00 //should be false but mine is true
I tried to regroup and reposition but nothing work.
|
Sounds like you could simply use
^[1-9]\d*\.00$
See your updated demo at regex101
* If you want to allow leading zeros, add `0*` at start.
* If you want to allow without `.00`, make that part optional.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "regex"
}
|
Pull mass name list from database or in script?
I need to fill an input box with a first name and last name. The user will press "Randomize" and it will pull a random first and last name and fill the inputs.
My question is I'm not sure if I should put the names in tables (firstNames, lastNames) or just store them in a javascript file and pull straight from that.
I'm trying to follow the Single Responsibility Principle so I'm inclined to choose the former, but then I have two more models, two more seeders, two more tables, and probably a class to pull all that together. And then do I fill from a CSV file or just from a manually populated seeder? It seems like a lot of work and extra files for a 1-time use.
I know I'll get crap for this being an opinion based question but there is no one or where else to ask.
Also if you know of a place to ask these kind of questions that won't get me ripped apart I'd appreciate that.
|
I would suggest using the Faker PHP library. That way you wouldn't have to create extra tables, models, or have to worry about finding yourself fake data.
To install it in your project, simply add the dependency in your composer.json file. and run a composer update.
"require-dev": {
"fzaninotto/faker": "1.3.*@dev"
},
Then you can use it to create fake first and last names for you (in your controller most likely)
$faker = Faker\Factory::create();
$firstName = $faker->firstName;
$lastName = $faker->lastName;
Edit:
To add your own names you can either edit or override the name provider file located here.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "oop, laravel, single responsibility principle, seeding"
}
|
Standard deviation for Gaussian distribution in Matlab
I have a number of test data (400 samples) that are distributed according to the Gaussian distribution, N(0,sigma). Is there a simple way of calculating the sample standard deviation sigma for these in Matlab? I have used the std function but I'm not sure whether it's correct, since I cannot see any assumptions on distribution in the matlab help except that it's identical.
|
The `std` command in Matlab does not assume uniformly distributed samples. The command `std(x)` is simply calculating the quantity $$ \hat{\sigma}=\sqrt{\frac{1}{n-1}\sum_{i=1}^n(x_i-\bar{x})^2} $$ with $\bar{x}=\sum\limits_{i=1}^nx_i$ for a vector `x` of length $n$. You can easily calculate this quantity by hand and compare with the `std` command.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "statistics, matlab"
}
|
Python- When I move items in one list to anther list, some items are missing
When I move items from list "X" to anther list "A", but some items are missing.
Here is my code.
X=list(range(2,11))
print(X)
A=list()
for x in X:
A.append(x)
X.remove(x)
print("A is ", A)
print("X is ", X)
I expected `X =[], A =[2,3,4,5,6,7,8,9,10],`
but the result was
A is [2, 4, 6, 8, 10]
X is [3, 5, 7, 9]
the odd numbers aren't moved. I want to know why they are not moved and how to move them.
I'm new to python programing, and any help will be greatly appreciated.
|
X=list(range(2,11))
print(X)
A=list()
X=X[::-1]
while X:
A.append(X.pop())
print("A is ", A)
print("X is ", X)
Instead of removing first reverse the X and pop the elements from X and append it to A.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "python, python 3.x"
}
|
Regex Odd/Even Amount
I have a regex question that I do not know how to do. It has to match all strings consisting any number of a's at the beginning and then either a single 0 if the number of a's was even or a single 1 if the number of a's was odd.
How can you keep track of even/odd?
Sample
* aaa1
* aaaa0
|
`^(a(aa)*1|(aa)+0)$`
or
`^(?:a(?:aa)*1|(?:aa)+0)$` if you are using captures.
The first portion: `a(aa)*1` will match any odd number of a's followed by a one, and the second portion: `(aa)+0` will match any even number of a's followed by a zero.
You can't keep track of the number of matches of a component of the pattern in regular expressions. They don't have memory. Fortunately, you can get around that limitation in this case.
|
stackexchange-stackoverflow
|
{
"answer_score": 11,
"question_score": 8,
"tags": "java, regex"
}
|
Nuxt emit data undefined
I'm trying to emit from child to parent with a payload and i get undefined value
What i'm doing, click on child button:
nextStep () {
this.$emit('next', { guests: this.guests, date: this.date })
}
Parent:
<BookStepTwo v-if="step === 2" :date="date" :guests="guests" @next="handleStepTwoNext()" @back="step = 1" />
methods: {
handleStepTwoNext (data) {
console.log(data)
this.step = 3
}
}
Payload: [{"guests":"1","date":{"start":"2021-07-21","end":"2021-07-22"}}]
Data gives me undefined.
|
Don't use arrow `()` in the emitted event handler :
@next="handleStepTwoNext"
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "vue.js, nuxt.js"
}
|
Cisco MIB Locator
Cisco has a MIB Locator which gives you a list of supported MIBs for a specific Cisco IOS Release. I have a MIB and need information on wich IOS version this MIB is supported. Does Cisco provide a database for that?
|
The feature you are looking for is on the same page you already have provided. On the bottom of the page there is a large box with the title `Search for MIB`. You can select your MIB in question there and click submit, which will lead you to another page where only the IOS/IOS-XE versions are listed which support your MIB. On this page you can narrow down the search by multiple factors, including:
* Release
* Platform Familiy
* Feature Set
The page will then provide you with IOS versions with this specific attributes that support your MIB.
|
stackexchange-networkengineering
|
{
"answer_score": 3,
"question_score": 0,
"tags": "cisco, cisco ios, snmp"
}
|
Install IIS 6 Management Compatibility on IIS 8 / Windows 2012
I cant access IIS server from console application because i need to install 6 Management Compatibility. I fixed this error on Windows 7, since its easy to find how to install 6 Management Compatibility.
!enter image description here
Where and how i can do that on Windows 2012 / IIS 8 ?
|
In Server 2012, go to Add Roles and Features. If you have not installed the Web Server Role, be sure to select that from the Server Roles section. When you get to the Role Services page for the Web Server Role, you will have the option to select IIS 6 Management Compatibility.
!Role Services screen
|
stackexchange-serverfault
|
{
"answer_score": 11,
"question_score": 8,
"tags": "windows, iis, windows server 2012, iis 8"
}
|
Redis Cloud doesn't exist in Azure Marketplace
I wanted to create a "Redis Cloud" via the Azure marketplace but I didn't found this service in the marketplace list. Doesn't it exist anymore? Why? Or is there some kind of limitation, e.g. it's only available for certain types of Azure subscriptions?
I'm wondering because via redislabs.com I can still choose "Azure" for creating a Redis Cloud - but not via Azure marketplace.
|
Sadly, you are right Munchkin.
I've looked into the matter and it appears that our Redis Cloud plugin is stuck in limbo between the old and new portals. This is an Azure team issue and we're waiting for a resolution from them.
Until this is rectified, note that you can always create a direct subscription via our website however and do feel free to contact our support team with any questions.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "azure, redis, azure marketplace"
}
|
How to suppress warnings from particular dll
I am adding 3rd party Lotus Notes dll in my project which is not CLS-Compliant. I need to set 'Treat Warning As Error'. How can I suppress all the warnings from that particular dll only.
All warnings are like
Identifier 'Domino.Name_Of_Identifier' is not CLS-compliant
|
You can't suppress warnings from a particular DLL - but you can turn off specific warnings.
In the message you'll see a number like CS3008 - go into Project Properties, Build Tab, and enter this into the Suppress Warnings field.
!Project Properties, Build Page
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "c#, c# 4.0, dll, lotus notes"
}
|
Replacing strings with sed in ubuntu
I have a config file with such value:
SITE_URL=
So I am trying to replace it with something like development.local.dev with sed, but not sure how to escape the domain correctly. Tried a lot of something like this:
sed -i -e 's/SITE_URL= .env
But keep getting: sed: -e expression #1, char 19: unknown option to `s'
|
It is because `/` is used a regex delimiter and it is used in your search pattern as well.
You can use an alternate delimiter e.g. `~` in `sed`:
sed '/^SITE_URL=/s~ file
SITE_URL=development.local.dev
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "bash, ubuntu, sed"
}
|
Error "Missing \endcsname inserted" when including PDF using \includegraphics
\documentclass[12pt,a4paper]{article}
\usepackage{color}
\usepackage[turkish]{babel}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{graphicx}
%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}
\includegraphics[width=3cm, height=4cm]{2.pdf}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%
The error message is:
> Missing \endcsname inserted. \relax l.334 ...udegraphics[width=3cm, height=4cm]{1.jpg}
but, if add only a picture, then it is ok.
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\includegraphics[width=3cm, height=4cm]{1.jpg}
\end{figure}
\end{document}
This is ok. But why does the first one give an error message?
|
By default the `turkish` language option makes `=` into an active character, essentially ruining any key=val interface (as they assume `=` to be a normal character).
The standard method of dealing with this is `\shorthandoff{...}`:
\documentclass{article}
\usepackage[turkish]{babel}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\shorthandoff{=}
\includegraphics[width=3cm, height=4cm]{example-image}
\end{figure}
\end{document}
Used like this, it temporarily (inside this `figure` env) deactivates `=` making it behave normally, thus `width=3cm` works again.
The documentation for `turkish` babel (`texdoc babel-turkish`) mentions that the activation of `=` is potentially dangerous, and you can use
\usepackage[turkish,shorthands=:!]{babel}
to just active `:!`, leaving `=` alone.
|
stackexchange-tex
|
{
"answer_score": 9,
"question_score": 4,
"tags": "errors, includegraphics"
}
|
Cntk personal dataset
I have read the cntk tutorials but I can not find a way to structure and create my image dataset. In tutorials they use, like the mnist dataset, files like mean.xml, map.txt and other files for labels and features. I can not find other guides on how to generate these files based on the folder, for example (positive and negative) from which to obtain file mapping and serialization of images in the format | labels | features|.
|
You can write a small Python program to create these files for yourself e.g. the map file can be done with an `os.walk` or some calls to `glob`. Similarly the mean.xml can be constructed using `PIL` and `minidom` as in this example.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, dataset, cntk"
}
|
How to make an integrated address based on a subaddress?
Monero is getting subaddresses soon. How are integrated addresses built upon those?
I'm trying the standard algorithm, using netbyte `0x35` (I'm on testnet) but the wallet rejects them as invalid.
Example:
* subaddress: `BdZHh8j3gieLUtCWEQqQWRbakvLCvffrfMkUALrrAi2gHMrwfRzeeqHM2ZMCPzpqhg5ZsgHJQmAev3i7epY6yV7NJYQNfWf`
* PID: `c28347cea0f01641`
* IA: `4Ghh5chLvwtLUtCWEQqQWRbakvLCvffrfMkUALrrAi2gHMrwfRzeeqHM2ZMCPzpqhg5ZsgHJQmAev3i7epY6yV7NT44nkedwuth8Mp7yns`
However, with my algorithm and also with the address tester at < the base address computed back from the IA is: `47124osrKgNLUtCWEQqQWRbakvLCvffrfMkUALrrAi2gHMrwfRzeeqHM2ZMCPzpqhg5ZsgHJQmAev3i7epY6yV7NJZKb2gx`
Before I dig into the source, can someone tell me if there are some rules I must follow when making IAs, or this is just not possible?
|
You don't. Subaddresses also solve the problem integrated addresses were designed for (allowing source identification in a single address). Since you can now generate a subaddress per source/client/customer, you don't need to assign a payment id anymore, so the ability to make integrated subaddresses was not added.
|
stackexchange-monero
|
{
"answer_score": 7,
"question_score": 4,
"tags": "testnet, integrated address, sub address"
}
|
How to convert a vector of string into vector of integers in R?
I have a vector string which looks like this
A <- c("162&u", "139&u", "87&us", "175&u", "54&us", "25&us", "46&us","16650", "16776", "16689", "16844")
How do I convert it into a vector of numeric arrays that looks like this in R?
A <- c(162,139,87, 175, 54,25,46,16650, 16776, 16689, 16844)
|
A generalized approach:
as.numeric(gsub("\\D+", "", A))
#[1] 162 139 87 175 54 25 46 16650 16776 16689 16844
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "r, vector, integer, character"
}
|
How to Decouple iCloud-Sourced Photos from the iCloud in Photos Application
Is there a way to decouple photos from iCloud in the Photos application when they arrive? Basically, on macOS, **I would like iCloud to deliver new photos and otherwise leave my local photo library alone**. If this is not possible, is there a work around, such as a method for creating independent copies of photos that arrive via iCloud?
I have found similar questions that explain that iCloud tightly couples photos across devices but nothing about how to work around the problem. Clearly different devices have different storage capacity, so it makes sense that one would like to enforce different policies on each device.
|
You cannot in Photos designate some photos as "local" and others as "iCloud Photo Library". It is all or nothing.
However, you can have locally stored photos outside of the Photos application, which will be untouched by iCloud Photo Library.
Regarding your comment about storage capacities: In Photos Preferences under the iCloud tab, you can set your storage policy to either (a) store photos and videos in full resolutions on this Mac, or (b) store photos and videos in full resolution on iCloud primarily and only cache photos/videos in full resolution locally as available storage allows.
|
stackexchange-apple
|
{
"answer_score": 1,
"question_score": 0,
"tags": "icloud, photos"
}
|
Debugging pgf-math
Just learned about pgfmath, but how can I debug it?
\pgfmathparse{..} \pgfmathresult
doesn't print anything inside a tikzpicture environment. How can I simply print the result of an expression to check weather the calculation was done correctly?
|
Christoph mentioned this but it's worth making explicit. If you don't want to actually draw anything you don't need a `tikzpicture` environment and you don't need to put `\pgfmathresult` in nodes.
\documentclass{article}
\usepackage{pgf}
\begin{document}
\pgfmathparse{2+3}
\pgfmathresult
\end{document}
|
stackexchange-tex
|
{
"answer_score": 3,
"question_score": 3,
"tags": "tikz pgf"
}
|
What is the name of this 'property' in statistics?
Today we have learned about something which roughly translates to 'Markov-property' at school. I have looked it up and found this page: < however, this is way too complicated for me and I am afraid this is not what I am looking for.
We learned that for statistical populations of units $x_1, x_2, x_3, \dots, x_n$ where all units are positive numbers (I am sorry if I use the terminology wrong, these words are completely new to me and English is not my native language), the following stands: Let $A > \bar{x}$ (Where $\bar{x}$ is the arithmetic average of the population). Then there are $\frac{n\bar{x}}{A}$ numbers which are greater or equal to $A$ (Where $n$ is the number of units in the population).
I hope I have been clear enough... Could anybody tell me what this is and where can I find more information about it?
|
In English this is known as Markov's inequality.
Specifically, given a collection of samples $x_1,\ldots,x_n$ we can define an associated probability distribution by giving each sample an equal probability $\frac{1}{n}$. Then the random variable $X$ represents choosing one of the $n$ samples uniformly at random. Markov's inequality says that as long as $X$ always takes nonnegative values (i.e. all the $x_i$ are nonnegative), $$\mathbb P(X \ge a) \le \frac{\mathbb{E}(X)}{a}.$$ In this case, $\mathbb P(X \ge a)$ is the probability of choosing a sample that is larger than $a$, which is $\frac{1}{n}$ times the number of samples larger than $a$, while $\mathbb E(X)$ is the expected value of $X$, which is $\mathbb E(X) = \sum p_ix_i = \frac1n\sum x_i = \bar x$.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 2,
"tags": "statistics, terminology"
}
|
Code to Make and Print a Dictionary Containing Input Values Outputs an Incomplete Dictionary; Why?
I'm trying to store 5 pairs of user input variables (user name & age) into a dictionary and return that dictionary in a print statement, but it keeps outputting a dictionary with only the last key-value pair. What's going on in the code making this happen?
query_count= 0
user_info = {}
for i in range (5):
query_count = 0
user_info = {}
user_info['user'] = input("user: ")
user_info['age'] = input("age: ")
query_count += 1
if query_count < 5:
continue
print(user_info)
example output:
{'user': 'Jamie', 'age': '42'}
|
U r actually updating the same keys again and again. U can instead use the username as a key and its value as age.
user_info = {}
for i in range(5):
name = input('Enter name:')
age = int(input('Enter age: '))
user_info[name] = age
print('One Entry Taken!')
print(user_info)
I don't think there is any need to print the age & name after every input. Output:
{'name1': 1, 'name2': 2, 'name3': 3, 'name4':4, 'name5': 5}
A pythonic way to achieve this:
user_info = {}
for i in range(5):
name, user_info[name] = input('Enter name: '), int(input('Enter age: '))
print(user_info)
I did not understand the use of query_count in ur logic. Plz elaborate.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, dictionary, input, conditional statements"
}
|
How to set the creation date of a file in Mac OSX to the current date?
I have tried to do this in terminal:
touch -t `date +%yy%mm%dd%HH%MM`/path/to/file
but it gives the error `touch: out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]`. How can I get the right date currently?
|
Try running `date +%yy%mm%dd%HH%MM` by itself, and the problem should become apparent:
$ date +%yy%mm%dd%HH%MM
19y10m26d11H40M
The format code for a two-digit year is `%y`, so `%yy` gives a two-digit year followed by a stray "y". All the others work the same way. So just un-double all the format codes. Oh, and I recommend using `$( )` instead of backticks:
$ date +%y%m%d%H%M
1910261141
$ touch -t $(date +%y%m%d%H%M) /path/to/file
But it's actually easier than that, because `touch` defaults to the current time. So all you actually need is `touch /path/to/file`.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "macos, date"
}
|
Заполнение столбца значениями из другой таблицы в случайном порядке sql
INSERT INTO Profile (user_id, media_source, country)
SELECT
(random() *10^3) as user_id,
now() - interval '15 minute' * random() as media_source,
( SELECT country_id FROM country
ORDER BY RANDOM()
LIMIT 1
) as country
from generate_series (1, 100) AS g(i)
;
Как сделать так, чтобы для столбца country выбиралось случайное значение для каждой сгенерированной строки?
|
INSERT INTO Profile (user_id, media_source, country)
SELECT
(random() *10^3) as user_id,
now() - interval '15 minute' * random() as media_source,
( SELECT country_id FROM (SELECT random() AS random_in, country_id FROM country) AS country
ORDER BY random_in*random_out
LIMIT 1
) as country
from random() AS random_out, generate_series (1, 100) AS g(i)
;
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "sql"
}
|
C# WPF resolution independancy?
I am developing a map control in WPF with C#. I am using a canvas control e.g. 400 x 200 which is assigned a map area of e.g. 2,000m x 1,000m.
The scale of the map would be: **canvas_size_in_meters / real_size_in_meters**.
I want to find the canvas_size_in_meters.
The canvas.ActualWidth gives the Width in DIU's (Device Independant Units). So, 400 DIU's is 400/96 = 4,17 inches, **PROVIDED** that the **physical** resolution of my monitor is 96 dpi.
However, using a ruler, I found that the physical resolution of my monitor is 87 dpi. (There are only few monitors that ACTUALLY have 96 physical dpi)
That DPI difference (10%) translates to a +10% difference in the actual map control width on screen.
How do I measure the size of a WPF control in inches EXACTLY and regardless of screen resolution and DPI setting ?
|
> How do I measure the size of a WPF control in inches EXACTLY and regardless of screen resolution and DPI setting ?
This isn't actually possible, because for it to work, WPF would have to know the resolution (in terms of DPI) of your monitor. Sounds nice in theory, but in practice windows doesn't know this information. This is why windows itself always assumes 96dpi blindly instead of being smarter about it.
Even if there were some way to manually tell it, or if your particular monitor has a custom driver that does pass the correct information to windows, this isn't going to work on anyone else's computer, so windows doesn't pass this information on to any applications.
The best you can do is draw a scale like google maps does. You know that 1 _pixel_ == 1 mile, so you can draw a 50 pixel line on your map, with a label saying "this line equals 50 miles"
|
stackexchange-stackoverflow
|
{
"answer_score": 9,
"question_score": 12,
"tags": "c#, wpf, gis, resolution, dpi"
}
|
Restricting text field to numbers only in Gravity Forms
We're trying to restrict a text field to numbers only. Here's what we've tried
* Add text field
* Apply input mask (9999999999)
The problem is that if someone does not fully complete the field, the number is erased when they tab into the next field or if they click anywhere outside of that field. It should not matter how many characters they put into the field, it should just restrict the field to a number.
If one only puts one 9 in the field, it restricts the field to 1 number. With the input mask set to ten 9's, you can enter 10 numbers. The problem is that if you do not enter the exact number, it clear the field once it loses focus.
We can do this with jQuery but we're hoping that Gravity has a hidden gem we've missed somewhere?
 name on the PayPal receipt?
I initiated a test donation to my IndieGoGo campaign, and noticed, that supporter see my full name ( _Premier_ account) or my company name ( _Bussiness_ account) on payment summary screen (and probably in the payment confirmation e-mail):
!enter image description here
However, when I'm trying to donate some program, I don't see neither company name, nor owner name, just the program name:
!enter image description here
Can I achieve the same for IndieGoGo? How can I run a campaign and let people pay without revealing my name (owner) or my company name on payment summary screen (above example) or in the payment confirmation e-mail?
I can't find proper settings / options in PayPal's configuration and repeated requests to PayPal Supports ends up with "autogenerated" answers (copy-paste from their FAQ), that doesn't bring me to the solution even a bit.
|
You can't hide company name on PayPal's receipt, when your PayPal account is set as `Business`. Customer sending money to such e-mail (and this is how it goes at Indiegogo) will _always_ see:
* company name,
* customers support phone number,
* company e-mail address (default one for particular account).
There is no way to change this.
To achieve situation presented on second screenshot, one must define its own Payment Buttons in `Merchant Services` section at PayPal and use only them. This method of paying however is not supported at Indiegogo, where money from supporters goes to PayPal account via e-mail.
So this is either way:
* direct payment to your company's e-mail address, were key details are visible,
* paying via click on special button on your own website, where users sees only product details.
Can't have both in the same time.
|
stackexchange-webapps
|
{
"answer_score": 1,
"question_score": 0,
"tags": "paypal"
}
|
Jar from HTML
A third party library I'm utilizing provided the JavaDoc HTML and associated bin files in a zip file. How can I create a jar file from the JavaDoc HTML?
Thanks.
|
A JAR file is nothing but a ZIP file with an (optional) manifest file inside.
Basically, rename the file to .JAR and that's it.
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 5,
"tags": "java, jar, javadoc"
}
|
Using LESS only to generate CSS as part of builds, not generating per-request?
I just started looking into dotless for my VS2012 solution and it seems that the less is compiled down to css every time a request hits the less file. This seems like a waste of cycles - I'm not going to be changing my CSS that much, and if I do, I'll deploy again.
Is it possible to use LESS as a developer-only tool to generate css that the clients download directly? A compile-on-demand version that I would use only when I make changes?
I don't see the benefit of compiling per request... if anyone can shed some light on that as well, I'd appreciate it.
|
You can using bundling and minification in .NET 4.5 to bundle and minify your LESS files into CSS.
Here is a quick guide on how to do it. Bundling and minification with dot-less
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "less, dotless"
}
|
Equivalent of Matlab "clearvars -except" in R
I want to remove some of the variables, NOT all as `remove()` and `rm` would do.
In Matlab I'd wright:
`clearvars -except Environnement Species *_species Latitude Longitude`
|
This is the best I can do. This creates `a,b,c` and deletes everything the the `Global Env` except for `b`.
a<-1
b<-2
c<-1:5
rm(list = ls()[!ls() %in% c("b")])
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -3,
"tags": "r, matlab, variables"
}
|
Why can I not access the DLC even though I have the Collectors Edition of Rocket League?
I recently bought the Rocket League Collector's Edition for my Xbox One and the four additional cars got installed straight away. However, when I accessed the garage, the cars from the included DLC packs were not there.
They are not in the Windows Store either, but the game case says they're included on the disc. I have fully installed the game, but the cars still won't appear.
Is my Collector's Edition disc incomplete or do I somehow unlock the cars in a different way?
|
I found this solution:
> Some users have reported only receiving the 4 extra DLC cars in Rocket League: Collector's Edition for the Xbox One.
>
> Not to fear, all of the 3 DLC pack items are there on your disc! The code included with your game will immediately unlock the 4 additional cars (Aftershock, Esper, Masamune, and Marauder), and as you play through the game, you will unlock everything else, including all of the DLC pack items from Chaos Run, Supersonic Fury, and Revenge of the Battle Cars.
|
stackexchange-gaming
|
{
"answer_score": 0,
"question_score": 0,
"tags": "xbox one, rocket league"
}
|
Get the first number in a string in script
This script returns a value like `33 | 4` and I need only the the first whole number, in this case `33`.
Can I use `.replace( /[^\d].*/, '' )` and where/how to put this? Or is there better solutions?
You are all very helpful, but i'm in a stage where I need to see my full script or a line from it with you solutions implemented ;-)
Thanks
jQuery(document).ready(function($) {
$("#input_1_1").blur(function() {
// sets the value of #input_1_8 to
// that which was entered in #input_1_1
$("#input_1_8").val($("#input_1_1").val());
});
});
|
You can use `parseInt()` or split your string with `|` and get the first result
console.log(parseInt("33 | 4"))
// or
console.log("33 | 4".split(" | ")[0])
In your case you can do
jQuery(document).ready(function($) {
$("#input_1_1").blur(function() {
$("#input_1_8").val(parseInt($("#input_1_1").val()));
});
});
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "javascript, jquery"
}
|
Django loaddata returns DeserializationError: 'NoneType' object has no attribute '_meta'
I have a json file coming from a dumpdata that I want to load and when doing loaddata after some time it returns this message:
`DeserializationError: 'NoneType' object has no attribute '_meta'`
There is no clue, no reference, I have no idea where this is coming from. I have tried with Django 1.4.8 and 1.5.4 and the result is the same.
What could it be?
edit: I have added a pdb to find out more and it appears that the objects that trigger the error are from auth.permission.
|
I just had the same problem so I don't know if the solution will be the same but here was mine :
I had post_save signals that didn't handle "raw=True" case.
It looks like post_save and pre_save signals are now sent even when you use loaddata, but with a "raw" argument (see < I don't know if it was already like that before but at least it wasn't in the docs.
So I just put in all my post_save signals :
if kwargs['raw']:
return
And it was al fine :)
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "django"
}
|
C#: Add data to an SQLMetal generated database class?
I used SQLMetal to generate a code file representing my database, and i can't figure out how to add entries to the database from the SQLMetal generated classes. How do i do this? do i just add to the various properties or something?
|
Here's a good overview of linq-to-sql, which includes how to add to your database via the auto-generated classes (from SQL Metal). **Link**
Essentially:
1. Create your database context object
2. Create a new object (which was auto-generated)
3. Populate your object's properties
4. Add your object to the correct collection within your database context
5. Submit changes to your database context. Voila!
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c#, sql, database, linq to sql, sqlmetal"
}
|
left and right hand sides are different why?
Let's say I have 50 coins total.
I give 20 coins to my friend
I am left with 30
Then I give 15 again
I am left with 15
Again I give 9
I am left with 6
Again I give 6
I am left with 0
When I sum them up back what I had left each time: 0+6+15+30 = 51
But I had only 50 rupees.
And when I calculated what I gave each time it is 6+9+15+20 = 50
And they both are different. Why they are different?
|
Because you should
> actually add what you give out, not you have left each time
which is
> 20+15+9+6=50
Second question:
> imagine this. you have 10 dollars. you spend them one by one. by adding what you have left each time you get 9+8+7+6+5+4+3+2+1=45 dollars. but you actually have 10 dollars in the beginning, not 45.
|
stackexchange-puzzling
|
{
"answer_score": 7,
"question_score": 3,
"tags": "mathematics"
}
|
How to remap ctrl+arrow keys to move word to word for mac
I'm coming from windows editors and I'm used to moving word to word in an editor (notepad, visual studio) or any application for that matter
Can somebody tell me how to remap the ctrl+rightarrow and ctrl+leftarrow to move word to word on my mac book pro retina running lion?
Currently the ctrl+leftarrow moves to the other dsktop on mac no matter what application I'm currently using. How can I disable that for one...
...and more importantly get the word for word traverse working in an application via ctrl+leftarrow and ctrl_rightarrow?
|
You can change the keyboard shortcuts for changing spaces from System Preferences:
, aws(create with AWS), minikube(create with Minikube) and etc.
However there is no option which create a cluster with local kubernetes cluster. I want to setup Jenkins X with my own cluster.
Can I get some advice?
Thanks.
|
when you have your cluster setup such that you can run `kubectl` commands against it, you can run `jx boot` to setup your jx installation. You don't need to use `jx create cluster` as your cluster already exists.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "kubernetes, jenkins x"
}
|
Remove page margin/border
as you can see from the picture, I marked the borders with X. Basically I've already remove all margin and borders but somehow during print preview, it shows me this white border which is very annoying. I cannot find other way to remove the border. Please guide. Thanks in advance.
!enter image description here
|
I believe those are Print Borders. A lot of printers cannot print to the edge of the paper, so Microsoft has set a minimum distance to always allow everything to be printed. The Print Border is defined by the type of printer you have. If you change your printer to XPS Document Writer, I believe that you can then remove this border.
|
stackexchange-superuser
|
{
"answer_score": 2,
"question_score": 1,
"tags": "microsoft word"
}
|
Is using a ground AND supply pours on a 2-layer PCB a bad design decision?
Ground pour on the top, supply pour on the bottom. Does this typically increase noise? Is it considered a poor design decision?
It's certainly makes things easier from a routing perspective to pop a via down when you need to supply a pin with power.
|
No, it's not a bad design decision, but it's often avoided because it can be a bad design decision sometimes, and many simply choose to use only ground pours on outer layers of the board regardless of the number of layers.
A lot of engineers choose to use only ground pours on outside layers for reasons of impedance (signal integrity), because ground is needed more often than power, and because it's common, many simply assume any visible pour is going to be ground. Many put power planes internal to protect them from damage - an errant screw rattling around inside a case coming into contact with a ground plane is less likely to cause a problem than one coming into contact with a power plane.
It's very convenient to have power pours, though, for some designs, and in two sided through hole designs it does make things easier in some ways. Once you run into a problem, though, you too may adopt a "ground planes or no planes on the outside layers" policy.
|
stackexchange-electronics
|
{
"answer_score": 2,
"question_score": 2,
"tags": "pcb design, ground plane"
}
|
How to count proportional distribution of given numbers?
I am trying to figure out how to count proportional distribution of given numbers - for example:
Number A: 5
Number B: 5
Number C: 5
In this case it means that the proportional distribution of each number is 33%.
But what if:
Number A: 17
Number B: 8
Number C: 59
I am trying to come up with a versatile formula (with rounding on zero decimal positions), but not successful so far.
I'd welcome every help with solving this case.
Thank you guys.
|
If $x_1, x_2,\dots, x_n$ are positive real numbers, then it seems to me like the "proportion" you are looking for, $p_i$, can be calculated as
$$p_i = \frac{x_i}{\sum_{j=1}^n x_j}$$
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "percentages"
}
|
What does session_write_close do when calling it before a query?
I was wondering what `session_write_close()` does. I find the manual a little bit vague. I have some pretty big `SELECT` queries. Before those `SELECT` queries I'm calling `session_write_close()`, and after the queries I'm calling `session_start()` again.
You might wonder why I do this, if I don't and an user is executing one of those `SELECT` queries and aborts them (trying to opening another page for example), the user can't open the new page (or has to wait pretty long). I think because the script is waiting until the large query is done.
**So my question(s):**
What exactly does `session_write_close()` do when calling it before a query?
Why doesn't the user have to wait (with `session_write_close()` before the query) when opening a new page, when aborting the query?
Thanks in advance
|
I hope that the below graph helps to understand what goes on; we're talking about a session for the same user (i.e. same session id):
script a | lock | script b
---------------------+------+-----------------
start
open session <- | yes | start
do stuff
close session -> | yes | -> open session
do heavy queries | | do stuff
open session <- | yes | <- script ended
script ended -> | no |
Closing the session when you're not going to use it, be it for a while or until the script ends, makes it available for another script.
Note that once the other script has run the session data may have been altered.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 5,
"tags": "php, sql"
}
|
Do function before submit of form - JQuery
How can I do a function when the user submits a form and then continue. My code is:
$("textarea.edit").parent().submit(function(e){
e.preventDefault();
$("textarea.edit", this).val("Hello");
$(this).submit();
});
But it didn't work??
|
You don't need to have the second `.submit()` as it is already in the method. Removing this, you should also remove the `.preventDefault()` method.
<form>
<textarea class="edit">Text</textarea>
<input type="submit">
</form>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("textarea.edit").parent().submit(function(){
$("textarea.edit").val("Hello");
});
})
</script>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "jquery, html"
}
|
Autofocusing multi v single point at a party
# Context
I've shot at a party at night recently. I've used mainly multi point (continuous) tracking as it makes more sense, as random events may come and go.
# Question
My friend suggests that I should have used single point to increase the amount of images worth keeping. I don't do that but I do bracketing, and it improves my keeper count, as well as just taking multiple shots. If Single point AF preferred when you're shooting at such events or is it more of a personal choice?
|
Single point or even manual focus, plus focus lock. The lock allows you to quickly focus with a half press of the shutter and then recompose to shoot. That way the focus is where you want it which may not be the centre of the frame.
|
stackexchange-photo
|
{
"answer_score": 0,
"question_score": 0,
"tags": "autofocus, focus, night, indoor"
}
|
Does not have storage.buckets.list access to the Google Cloud project?
I wrote a Ruby script that will upload an audio file to a Google Cloud Storage.
def upload_to_Google_cloud(audio_file)
project_id = "<project_id>"
key_file = "<json_file>"
storage = Google::Cloud::Storage.new project: project_id, keyfile: key_file
bucket_name = storage.buckets.first.name
puts bucket_name
bucket = storage.bucket bucket_name
local_file_path = "/path/#{audio_file}"
file = bucket.create_file local_file_path, "#{audio_file}.flac"
return "Uploaded #{file.name}"
end
Though, everytime I run the command -> ruby video_dictation.rb, it returns me an error which is **xxxxxxxxx does not have storage.buckets.list access to the Google Cloud project. (Google::Cloud::PermissionDeniedError)**.
Any help, suggestions? Thanks!
|
Should be permission issue.
1. Try to create a service account. It looks like this "[email protected]"
2. Go to IAM & Admin -> Permission
3. Assign that service account with "Storage Object Admin" role.
4. Try your code again. If is working, please scope down your permission to the below list based on your needs.
;
// Check to see if any rows where returned
if (mysql_num_rows($result) > 0)
{
while ($row = mysql_fetch_array($result))
{
$ownerID = $row["fk_ownerID"];
}
}
Now the variable $ownerID should have a number, or not. But I'm unsure how to check this. Currently I'm doing this:
if ( (strlen($ownerID) == 0) || ($ownerID == '0') || ($ownerID == 'null') )
But I'm pretty sure only one of these tests should be necessary.
What is the best way to check if a row field is empty or null?
|
Use empty() and/or is_null()
< <
Empty alone will achieve your current usage, is_null would just make more control possible if you wanted to distinguish between a field that is null and a field that is empty.
|
stackexchange-stackoverflow
|
{
"answer_score": 47,
"question_score": 32,
"tags": "php, mysql"
}
|
Using SELECT and concatenation MySQL?
<
This works:
SELECT
s.*,
(SELECT ProductName
FROM Products
WHERE SupplierID = s.SupplierID LIMIT 1) AS ProductNames
FROM
Suppliers s
I want to use something like this:
SELECT
s.*,
GROUP_CONCAT(SELECT ProductName
FROM Products
WHERE SupplierID = s.SupplierID) AS ProductNames
FROM
Suppliers s
Where each row of Suppliers is shown, even if ProductNames is empty but it gives an error.
Is something like that possible? I know that LEFT JOIN could also work.
|
I figured it out
<
SELECT s.*,
(SELECT GROUP_CONCAT(ProductName) FROM Products WHERE SupplierID = s.SupplierID) AS ProductNames
FROM Suppliers s
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "mysql, sql"
}
|
Why does tufte-book turn beta into "fi"
When using the `\mathbf` command instead of `\boldsymbol`, greek symbols are not always made bold. However, when using the `tufte-book` document class, the beta symbol is changed into **fi**. What is **fi** and why does this happen?
\documentclass[]{tufte-book}
\begin{document}
\[\beta\]
\[\mathbf{\beta}\]
\end{document}
Yields:  you have to use `\mathbold`, because `\mathbf` switches to OT1 encoding.
\documentclass{article}
\usepackage{mathpazo}
\begin{document}
\[b\beta\]
\[\mathbf{b\beta}\]
\[\mathbold{b\beta}\]
\end{document}

I am using a CNN architecture and adding few more layers in between and creating a new model. By using model.summary() on this new model, I see everything is aligned fine but in tensorboard, I am seeing duplicate blocks connected around with new blocks.Kind of new network parallely drawn with the old network block and some connection in between.
I am using tensorboard = Tensorboard() for the tensorboard in keras.
Please advise why I see these connections and old network blocks in parallel with new model blocks but on the other hand model.summary() looks totally fine.
I am trying to understand so any detail on this will help.
|
I have faced the similar issue.
The main reason for this is, whenever the model is created, every layer gets a new name. For example: if you have a model with two 2d-convolutional layers followed by a dense layer. Creating the model for the 1st time and executing `model.Summary()`, results in the below layer names:
* conv2d_1
* conv2d_2
* dense_1
While re-executing the same code, yields:
* conv2d_3
* conv2d_4
* dense_2
At the same time, the logs that Tensor-board uses are overwritten. Hence, parallel blocks of layers with different names appears.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "graph, keras, conv neural network, tensorboard"
}
|
Index not the same between writing and reading excel file
Here is the problem. I have a data frame that looks something like this
df1 = pd.read_excel('excelA.xlsx')
df2 = pd.read_excel('excelB.xlsx')
ind = df1['some_col']
cols = df2.columns
# Using index from df1 and columns from df2 create a new df
res_df = pd.DataFrame(index=ind, columns=cols)
# Inserting values from df2 into new df
for c in cols:
for j in range(len(df2[c])):
res_df[c].iloc[j] = df2[c].iloc[j]
print(res_df.index) // Index([something, something2, something3 ... ])
writer = pd.ExcelWriter('test.xlsx', engine='xlsxwriter')
res_df.to_excel(writer, sheet_name='Sheet1', index=True)
writer.close()
Now when I try to read the file
df = pd.read_excel('test.xlsx', dtype=str)
print(df.index) // RangeIndex(start=0, stop=1000, step=1)
Can anyone tell me what is happening here?
|
Check in excel what is column index of index column.
Then use pd.read_excel(''test.xlsx',index_col=[index_in_excel])
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, excel, pandas"
}
|
f.checkbox - how to add onclick that submits instantly?
So I have a check_box in rails 5, and I want it to submit instantly whenever it is clicked/unclicked. It should be possible with :onclick, but I'm new to js/jquery/ajax, and haven't had any luck searching.
I have this:
<%= form_for @client, :url => url_for(:controller => 'client_admin', :action => 'clientadminpageupdate') do |f| %>
<%= f.check_box :visible, :id => "checkbox" %>
<%= f.submit 'Save' %>
What I want to this is submit the form **instantly** by adding an
> :onclick => something-that-submits-the-form-instantly
How do I go about it?
|
If you just want to use it as a form submission you can use the following:
`:onclick => "this.form.submit()"`
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, jquery, ruby on rails, ajax, ruby on rails 5"
}
|
Entity Framework and deferred execution on lazy loaded ICollection
I'm using Entity Framework 4.1 and I have a one to many relationship.
When I query the lazy loaded `ICollection<T>` on the one side of the relationship the whole recordset is returned and it doesn't defer the execution like when I'm querying direct from the Repository `IQueryable` interface.
Is there any way to make this use deferred execution so I can do a query like
Model.Childs.Where(x => !x.Deleted.HasValue).Skip(10).Take(5);
Thanks in advance,
Tom.
|
That is principle of lazy loading in EF. Your navigation property is defined in your code and any LINQ query defined on that property is LINQ-to-Objects - it is not translated to SQL. Lazy loading always loads whole collection (as well as eager loading). When you query your repository you are querying IQueryable and using LINQ-to-Entities which is translated to SQL.
As workaround use explicit loading:
dbContext.Entry(Model).Collection(m => m.Childs)
.Query()
.Where(c => !c.Deleted.HasValue)
.Skip(10)
.Take(5)
.Load();
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "entity framework 4, deferred execution"
}
|
MediaStream on Windows Phone 7
I'm working on a Windows Phone application that displays an audioStream (as radio) but all I found is how to read a video or audio file using mediaElement.
How can i implement mediaStream?
|
I think you will find the following link on Using Smooth Streaming Media Element for Windows Phone 7 very useful. Basically, you add a reference to `Microsoft.Web.Media.SmoothStreaming` and use the control `SmoothStreamingMediaElement` to which you set the `SmoothStreamingSource` property to whatever stream you need to. Cake.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": ".net, windows phone 7, mediastreamsource"
}
|
Postgresql does not launch
I just installed postgresql 9.1 on my ubuntu server precise I installed postgres on an ubuntu workstation before and despite following the same steps (documented) nothing works.
When i do :
sudo /etc/init.d/postgresql start
There is no message at all, and there is no postgres process running. The /var/log/postgres/ folder exist but it's empty. How can i know what is wrong with my postgres?
EDIT : nothing relevant in var/log/messages
|
I totally deleted and reinstalled postgres, half of postgres was missing. I only used apt-get i'm not sure why the installation failed. After a clean install it waorks perfectly.
|
stackexchange-serverfault
|
{
"answer_score": 0,
"question_score": 0,
"tags": "ubuntu, postgresql"
}
|
Conditional Probablity - factorization
I am working though the exercises in the Computer Vision Models book.
Here I am at the Problem 2.7 which is described as:
> The joint probability $\mathrm{Pr}(w, x, y, z)$ over four variables factorizes as
>
> $$\mathrm{Pr}(w, x, y, z) = \mathrm{Pr}(w)\mathrm{Pr}(z\mid y)\mathrm{Pr}(y\mid x,w)\mathrm{Pr}(x)$$
>
> Demonstrate that $x$ is independent of $w$ by showing that $\mathrm{Pr}(x,w) = \mathrm{Pr}(x)\mathrm{Pr}(w)$.
What I did in the given RHS was: $\mathrm{Pr}(w)\mathrm{Pr}(z,y\mid x,w)\mathrm{Pr}(x)$.
Is this right? I have a serious doubt about it, I have missed something big here. Just can't put my finger on it. And if this is wrong, any tips on how to proceed?
|
I am going to assume everything to be continuous (to simplify the steps. Otherwise replace integrals by sums etc...). Thus non-rigorously
\begin{eqnarray*} p \left( x, w \right) & = & \int p \left( x, w, y, z \right) d y d z\\\ & = & \int p \left( z \left| y \right. \right) p \left( y|x, w \right) p \left( x \right) p \left( w \right) d y dz\\\ & = & p \left( x \right) p \left( w \right) \int p \left( z \left| y \right. \right) p \left( y|x, w \right) d y d z\\\ & = & p \left( x \right) p \left( w \right) \int p \left( y|x, w \right) \underbrace{\left( \int p \left( z|y \right) d z \right)}_{= 1} d y\\\ & = & p \left( x \right) p \left( w \right) \underbrace{\int p \left( y|x, w \right) d y}_{= 1}\\\ & = & p \left( x \right) p \left( w \right) \end{eqnarray*}
It would have been also possible to use Markov properties for graphs for something more elegant and a bit shorter.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 3,
"tags": "probability"
}
|
Example of VBA array being passed by value?
I thought that arrays were always passed by reference in VBA, but this example seems to be an exception:
' Class Module "C"
Private a_() As Long
Public Property Let a(a() As Long)
Debug.Print VarPtr(a(0))
a_ = a
End Property
' Standard Module
Sub test()
Dim a() As Long: ReDim a(9)
Debug.Print VarPtr(a(0)) ' output: 755115384
Dim oc As C
Set oc = New C
oc.a = a ' output: 752875104
End Sub
It's bugging me because I need to have a class containing an array and it's making an extra copy.
|
This seems to work, at least insofar as passing by reference:
Sub test()
Dim oc As New C
Dim a() As Long: ReDim a(9)
Debug.Print "test: " & VarPtr(a(0))
oc.Set_A a()
End Sub
In class module `C`:
Private a_() As Long
Public Property Let a(a() As Long)
Debug.Print "Let: " & VarPtr(a(0))
a_ = a
End Property
Function Set_A(a() As Long)
Debug.Print "Set_A: " & VarPtr(a(0))
a_ = a
End Function
I do note that the `VarPtr` evaluation of `a(0)` and `oc.a_(0)` is different, however, and I am not sure whether this is suitable for your needs:
!enter image description here
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "arrays, vba, excel"
}
|
Vertically Centering one side of a Multiline equation
I have a long PDE which I wish to write in the form F(phi)=0; however, it is too long to be written on a single line. As of now I have it written in my LaTex document simply using:
\begin{align*}
\phi_t + e^{-x}\phi_x - e^{-x}\phi + \Lambda e^{-x} \phi_z - 9 \mathcal{M} \mathcal{E} \phi^2\phi_z^2 + 6 \mathcal{M} \mathcal{E} \phi \phi_z^2 - 3 \mathcal{M} \mathcal{E} \phi^3 \phi_{zz} + 3 \mathcal{M} \mathcal{E} \phi^2 \phi_{zz} \\
- \frac{1}{2} \mathcal{M} \mathcal{E} \phi_z^2 - \frac{1}{2} \mathcal{M} \mathcal{E} \phi \phi_{zz} + \mathcal{E} \epsilon^2 \phi_z \phi_{zzz} + \mathcal{E} \epsilon^2 \phi \phi_{zzzz} = 0
\end{align*}
which works fine enough showing:
 as the type.
I have tried this with both `?` and `T`:
public EntityGun(<? extends AbstractEntityProjectile> entity) {
/* code */
}
Is there a different syntax for doing this? Or do I need to go about this differently?
|
To achieve what you want, to pass a parameter to the constructor of which the Object class has extended the AbstractEntityProjectile abstract class, simply use:
public EntityGun (AbstractEntityProjectile entity) {
/* code */
}
To initialize an EntityGun object, you class of the entity must have extended the AbstractEntityProjectile class. Note that entity will have the type AbstractEntityProjectile, hence you will only be able to invoke methods that explicitly defined in the abstract AbstractEntityProjectile class or those that are inherited by AbstractEntityProjectile. To work with methods introduced in the 'true' class of the parameter, you will need to cast it to the appropriate class.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java, minecraft"
}
|
Can`t load files for pygame project using pyqt resource system
I have .qrc file:
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource prefix="/data">
<file alias="key.png">resources/blocks/key.png</file>
</qresource>
</RCC>
I generate resources_rc.py by pyrcc5, than in my main script:
import resources_rc.py
key = pygame.image.load(':/data/key.png').convert_alpha()
I get an error:
File "E:/Python game/main.py", line 137, in main
key = pygame.image.load(':/data/key.png').convert_alpha()
pygame.error: Couldn't open :/data/key.png
What am I doing wrong?
|
The `:/foo/bar` filenames are special filenames used by Qt's (and thus PyQt's) ressource system.
pygame is not PyQt- you won't be able to do that outside of Qt.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, pyqt, pygame"
}
|
How to create and store a new image file in cocoa
I want to create and store a empty white image file on the disk. As I am new to cocoa I don't know how to do it.
|
I see, your question is related to Mac as you have added `cocoa` and `NSImage` tags. So try this.
NSRect kRect = NSMakeRect(0,0,100,100);
NSView *view = [[NSView alloc] initWithFrame:kRect];
CALayer *viewLayer = [CALayer layer];
[viewLayer setBackgroundColor:CGColorCreateGenericRGB(1, 0.0, 0.0, 1)]; //RGB plus Alpha Channel
[view setWantsLayer:YES]; // view's backing store is using a Core Animation Layer
[view setLayer:viewLayer];
// [self.window.contentView addSubview:view];
NSBitmapImageRep* kRep = [view bitmapImageRepForCachingDisplayInRect:kRect];
[view cacheDisplayInRect:kRect toBitmapImageRep:kRep];
NSData* kData = [kRep representationUsingType:NSPNGFileType properties:nil];
[kData writeToFile:@"/Users/MyName/Desktop/red.png" atomically:YES];
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "objective c, cocoa, nsimage"
}
|
Smarty format date to HTML5 <time /> spec
I am nearly there all I need it the last Time Zone
<time datetime="{$row.datetime.value|date_format:"%Y-%m-%dT%H:%M:%S%z"}"></time>
<time datetime="2011-07-11T00:00:00GMT Daylight Time"></time>
I need this to work by adding +01:00 like this: 2011-07-11T00:00:00+01:00 otherwise when I validate the page I get invalid date errors.
Looking at the doc page it doesn't
|
## Solution
<time datetime="{date('c', $row.datetime.value)}"></time>
## Alternative
Yes, I know that it's a non-standard way of calling functions. If you don't like it, you can write a Smarty plugin.
<?php
function smarty_modifier_standard_time($timestamp) {
return date("c", $timestamp);
}
?>
then save this plugin as modifier.standard_time.php in plugins directory and then call it like this:
{$row.datetime.value|standard_time}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, date, datetime, smarty, html"
}
|
Out of Universe, was Vader always planned to be Luke's father?
I was watching the original series and got to "I am your father". I thought: is this something the author planned all along or thought of while writing _The Empire Strikes Back_?
|
## No.
Prowse (the actor who played Vader) was originally told to reveal that it was _Obi-Wan_ who killed Luke's father.
However, the original writer of the script that would become Empire Strikes Back, Leigh Brackett, died before finishing the final draft.
After Leigh's death, Lucas took over writing the script. It was received poorly, likely spurring on the revisions.
Of course, the twist was done by filming and even the actor playing Vader was basically kept unaware of the twist.
. I have to display dynamically the content in the UIView. So what i am trying to do is to create an IBoutlet UIView and check if the content type is a text i convert this uiview to UILable and display the text, if the content type is an image i convert the UIView to a UIImageView etc... I need to work on the same UIView from the xib file, so how can i change the properties of the UIView to a UILable or a UIImageView.
Thank you
|
You cannot "change" an UIView to be something different.
I suggest you dynamically add subviews to your view:
UIView *newView = nil;
switch (content type) {
case 0: // text
newView = [[UILabel alloc] init];
((UILabel*)newView).text = @"someText";
[newView sizeToFit];
case 1: // button
{
UIButton *btn = [UIButton buttonWithType:...];
[btn setTititle:@"Ttile" forControlState:UIControlStateNormal]; // assign all needed properties
...
newView = btn;
}
case 2:
....
}
newView.frame = ... // calculate Frame using previously created content (e.g. remember y offset and add bounds.size.height after every iteration)
[self.view addSubView:newView];
....
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "iphone, objective c, uiview, uiimageview, uilabel"
}
|
Calculating the probability of winning at least $128$ dollars in a lottery St. Petersburg Paradox
**The St. Petersburg Paradox:**
Here is a lottery: a fair coin is flipped repeatedly until it produces "heads." If the first occurrence of heads is on the $nth$ toss, you are paid $2^{n-1}$. So for instance, if heads appears on the first toss, you are paid $1$ dollar; if heads appears for the first time on the second toss, you are paid $2$ dollars, and so on.
Generally, the paradox is that a person would not be willing to pay an infinite amount of money to play such a lottery, and the estimates are between $10$-$20$ dollars only.
My question is that how do I calculate the probability of winning at least $128$ dollars?
|
To win at least 128 dollars, you need a sequence of 7 tails, so the probability is $ \frac{1}{2^7}=\frac{1}{128}$
|
stackexchange-math
|
{
"answer_score": 7,
"question_score": 0,
"tags": "probability, probability theory"
}
|
What do the different icons in the ladder table mean?
Does the up/down arrows mean you are going to go up/down a league? Do they mean you are advancing/losing inside the division?
What do the other 2 icons (-- and !) mean?
!alt text
Is there some visual indication (reference) in that screen I'm missing? (I couldn't find the answer there)
|
The up and down arrows mean the player/team has changed position in their division since last week. An exclamation mark means the player is new to the division this week, and `--` indicates no change.
|
stackexchange-gaming
|
{
"answer_score": 5,
"question_score": 6,
"tags": "starcraft 2"
}
|
Test if a named pipe binding is available or already in use
I have a simple WCF service that is used for cross app-domain communication in our app.
the service is exposed via a NamedPipeBinding, currently using a hard coded name:
var address = "net.pipe://localhost/app/log";
NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
binding.ReceiveTimeout = TimeSpan.MaxValue;
binding.
logServiceHost = new ServiceHost(typeof(LogService));
logServiceHost.AddServiceEndpoint(typeof(ILogProvider), binding, address);
logServiceHost.Open();
The problem is that this name is hardcoded and so another instance of our app cannot allocate a new named pipe (since the name is already taken).
Is it possible to check if a name is already taken, and if so allocate a different name?
Or are there other easier strategies for handling such a scenario?
|
You're basically trying to make 'multi-instance aware' services. Typical approach to doing that is to allow each service instance to announce it's existance. The best way to do that is to use add an announcement endpoint:
var discoveryBehavior = new ServiceDiscoveryBehavior();
discoveryBehavior.AnnouncementEndpoints.Add(new UdpAnnouncementEndpoint());
logServiceHost.Description.Behaviors.Add(discoveryBehavior);
logServiceHost.AddServiceEndpoint(new UdpDiscoveryEndpoint());
logServiceHost.Open();
You can later on discover each instance of existing services in the network and take necessary steps to prevent endpoint URI collisions, if necessary.
You can read more about WCF Auto Discovery behavior via the link.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "c#, .net, wcf, named pipes"
}
|
Android backward compatibility techniques
I am now advanced in developing my 15-activities android app which is based on the latest API (15 ICS). Now I discovered that main functionalists of the app is NOT backward compatible even with the android v4 support such as:
1-fragmentTransaction animation 2-the ability to putStringSet in sharedPref 3-having mapActivity using fragments
I thought about making a second version for the older OS's of EACH class that has incompatibility issues (which are around 10) so I use them if I detect that the device running the app is old. However, I am sure this is a stupid way and there is a better way of doing this.
What is the best way to make your code compatible with API 7 and up without leaving the the features provided higher APIs ( at least to be used for the newer devices )
|
You can check the API level in android at runtime and enable the required features as per the API level.
Something like below.
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH){
// Do something for ICS and above versions
} else{
// do something for phones running an SDK before ICS
}
Additionally you can add the version qualifier to the resource folder such as drawable-v15 (will pickup drawables if the device API level is 15)
Check this LINK for more information on how to specify the required qualifiers for the resources
with this the latest functionality available will be enabled when launched on latest firmware devices and backward compatibility is enabled otherwise.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 3,
"tags": "android, android 4.0 ice cream sandwich, backwards compatibility"
}
|
Proof of Horrocks splitting criterion - the book by Okonek etc.
In the proof of Horrocks splitting criterion, Theorem 2.3.1, Okonek, Schneider, Spindler, there is this situation:
$E$ and $F$ are vector bundles on Projective space $P^n$ of the same rank and same $c_1$. We have a morphism $\phi:F\rightarrow E$, which is an isomorphism on a hyperplane, i.e. $\phi|_H:F|_H\rightarrow E|_H$. This gives $$det\,\phi:det\,F\rightarrow det\,E.$$
Since they have the same $c_1$, $det\,\phi\in H^0(P^n,det\,F^*\otimes det\,E)\simeq H^0(P^n,O)$.
Since $det\,\phi$ is non-zero on $H$ and is constant on $P^n$, $det\, \phi$ is nowhere vanishing.
They say that : thus $\phi$ is an isomorphism. How does this prove that $\phi$ is an isomorphism?
|
You can take the standard formula for the inverse matrix and apply it to the morphism of vector bundles. Explicitly, it works as follows.
Assume the rank of the bundles is $r$. First, consider the $(r-1)$-st exterior power of the map: $$ \Lambda^{r-1}\phi : \Lambda^{r-1}F \to \Lambda^{r-1}E. $$ Then transpose it: $$ \Lambda^{r-1}\phi^T : \Lambda^{r-1}E^\vee \to \Lambda^{r-1}F^\vee. $$ Finally, using the natural identifications $$ E \cong \det E \otimes \Lambda^{r-1} E^\vee, \qquad F \cong \det F \otimes \Lambda^{r-1} F^\vee, $$ and the isomorphism of determinants, one deduce from this the map $$ (\det \phi)^{-1} \otimes \Lambda^{r-1}\phi^T : E \to F. $$ This is the inverse of $\phi$ (that can be checked by a local calculation).
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "algebraic geometry"
}
|
Using JSON/AJAX information from getJSON to change the src of multiple iframes to include the videoIds taken from the YouTube API
So, I require four YouTube Videos to show the latest videos from a channel on page load, and am doing this by using
$( document ).ready(function(){
var YouTubeAPI = "
$.getJSON( YouTubeAPI, function( data){
$.each( data.items, function(i, item) {
$(".youtube-player").attr('src', " + items.id.videoId + "?controls=1&amp;showinfo=1&amp;rel=1");
})
}
});
The issue here is that the iframes all display the fourth video, instead of each video from the JSON GET.
Now, when replacing the line starting `$(".youtube-player").....` with `(alert(item.id.videoId);` I get the required VideoIds in an alert, starting with the newest (0) ID.
|
Can use `eq()` to match same index of elements to data
var $frames = $(".youtube-player");
$.getJSON(YouTubeAPI, function(data) {
$.each(data.items, function(i, item) {
$frames.eq(i).attr('src', " + item.id.videoId + "?controls=1&amp;showinfo=1&amp;rel=1");
})
})
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "javascript, jquery, youtube, youtube api, youtube data api"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.