Operations
A Swift framework inspired by WWDC 2015 Advanced NSOperations session.
Something really weird is happening.
float p1 = (6 / 100);
NSLog(@"p1 = %f", p1);
With those two lines of code I get the following output:
p1 = 0.000000
Why is a simple devide with static numbers not working! I have so much work to do to deal with divide not working! What he heck, am I crazy?
Source: (StackOverflow)
I'm referring to the basic relational algebra operators here.
As I see it, everything that can be done with project can be done with select.
I don't know if there is a difference or a certain nuance that I've missed.
What do folks @ SO think
Source: (StackOverflow)
So I've created a WCF service application and hosted it on IIS7. It currently has a few test 'helloworld' methods. When I run it in my browser I get this screen:
Now the service itself works great, but how can I display the operations like this:
Thanks to marc_s for the link: http://www.dotnetcurry.com/ShowArticle.aspx?ID=399 which I've followed so my web config is now setup like:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="WcfServer.Service1">
<endpoint address="" binding="webHttpBinding" contract="WcfServer.IService1" behaviorConfiguration="HelpBehaviour" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="AjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="HelpBehaviour">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension" />
</system.webServer>
</configuration>
However, this only works locally. When I publish to my server on IIS7 I get a 404 error page when I click on the help link. Does anyone know why this is, or has come across it before?
(Last bit was solved by running: aspnet_regiis.exe -iru
)
Source: (StackOverflow)
I read that doing a & 0x7fffffff
masks just the sign bit and doesn't tampers with the other bits.
int a = Integer.MIN_VALUE;
System.out.println(a & 0x7fffffff);
But, this code outputs
0
instead of
2147483648
Why is that?
Source: (StackOverflow)
I have a vector of zeros, say of length 10. So
v = rep(0,10)
I want to populate some values of the vector, on the basis of a set of indexes in v1 and another vector v2 that actually has the values in sequence. So another vector v1 has the indexes say
v1 = c(1,2,3,7,8,9)
and
v2 = c(0.1,0.3,0.4,0.5,0.1,0.9)
In the end I want
v = c(0.1,0.3,0.4,0,0,0,0.5,0.1,0.9,0)
So the indexes in v1 got mapped from v2 and the remaining ones were 0. I can obviously write a for loop but thats taking too long in R, owing to the length of the actual matrices. Any simple way to do this?
Source: (StackOverflow)
I've just discovered Sikuli, and would like to see a comprehensive functions list without digging through the online-examples and demos.
Has anyone found such a list?
Furthermore, apparently Sikuli supports more complex loops and function calls as well, and seems to be based in Python(!!). Examples would be great.
Thanks.
Source: (StackOverflow)
What are the order of operations when using two assignment operators in a single line?
public static void main(String[] args){
int i = 0;
int[] a = {3, 6};
a[i] = i = 9; // this line in particular
System.out.println(i + " " + a[0] + " " + a[1]);
}
Edit: Thanks for the posts. I get that = takes values from the right, but when I compile this I get:
9 9 6
I thought it would have been and ArrayOutOfBounds exception, but it is assigning 'a[i]' before it's moving over the 9. Does it just do that for arrays?
Source: (StackOverflow)
Is there a way to make a function atomic in C.
I am not looking for a portable solution.(platforms looking for - Win,Linux)
Source: (StackOverflow)
I've put all the code and running info below. When handling very long strings, the speed of operations in the title is different. Why and How many other operations show the same characteristics?
(If the loops is lower than 10^4, the different is negligible.)
➜ ~ cat t1.pl
#!/usr/bin/env perl
$a = 'a';
$i = 0;
while ($i < 100000){
$a .= 'a';
$i++;
}
➜ ~ time perl t1.pl
perl t1.pl 0.01s user 0.00s system 85% cpu 0.021 total
➜ ~ cat t2.pl
#!/usr/bin/env perl
$a = 'a';
$i = 0;
while ($i < 100000){
$a = $a.'a';
$i++;
}
➜ ~ time perl t2.pl
perl t2.pl 0.50s user 0.01s system 99% cpu 0.507 total
Source: (StackOverflow)
Just wondering what the difference between a single precision floating point operation and double precision floating operation is.
I'm especially interested in practical terms in relation to video game consoles, for example does the Nintendo 64 have a 64 bit processor and if it does then would that mean it was capable of double precision floating point operations? Can the ps3 and Xbox 360 pull off double precision floating point operations or only single precision and in general use is the double precision capabilities made use of (if they exist?).
Thanks for any help!
Source: (StackOverflow)
I've a code alike
void ExecuteTraced(Action a, string message)
{
TraceOpStart(message);
a();
TraceOpEnd(message);
}
The callback (a) could call ExecuteTraced again, and, in some cases, asynchronously (via ThreadPool, BeginInvoke, PLINQ etc, so I've no ability to explicitly mark operation scope). I want to trace all operation nested (even if they perform asynchronously). So, I need the ability to get last traced operation inside logical call context (there may be a lot of concurrent threads, so it's impossible to use lastTraced static field).
There're CallContext.LogicalGetData and CallContext.LogicalSetData, but unfortunately, LogicalCallContext propagates changes back to the parent context as EndInvoke() called. Even worse, this may occure at any moment if EndInvoke() was called async.
EndInvoke changes current CallContext - why?
Also, there is Trace.CorrelationManager, but it based on CallContext and have all the same troubles.
There's a workaround: use the CallContext.HostContext property which does not propagates back as async operation ended. Also, it does'nt clone, so the value should be immutable - not a problem. Though, it's used by HttpContext and so, workaround is not usable in Asp.Net apps.
The only way I see is to wrap HostContext (if not mine) or entire LogicalCallContext into dynamic and dispatch all calls beside last traced operation.
Source: (StackOverflow)
I'm trying to use operator overloading to define the basic operations (+,-,*,/) for my polynomial class but when i run the program it crashes and my computer frozes.
Update4
Ok. i successfully made three of the operations, the only one left is division.
Here's what I got:
polinom operator*(const polinom& P) const
{
polinom Result;
constIter i, j, lastItem = Result.poly.end();
Iter it1, it2, first, last;
int nr_matches;
for (i = poly.begin() ; i != poly.end(); i++) {
for (j = P.poly.begin(); j != P.poly.end(); j++)
Result.insert(i->coef * j->coef, i->pow + j->pow);
}
Result.poly.sort(SortDescending());
lastItem--;
while (true) {
nr_matches = 0;
for (it1 = Result.poly.begin(); it1 != lastItem; it1++) {
first = it1;
last = it1;
first++;
for (it2 = first; it2 != Result.poly.end(); it2++) {
if (it2->pow == it1->pow) {
it1->coef += it2->coef;
nr_matches++;
}
}
nr_matches++;
do {
last++;
nr_matches--;
} while (nr_matches != 0);
Result.poly.erase(first, last);
}
if (nr_matches == 0)
break;
}
return Result;
}
Source: (StackOverflow)
I'm trying to perform computations involving matrix operations and complex math - sometimes together, in C. I'm very familiar with Matlab and I know these types of computations could be performed simply and efficiently. For example, two matrices of the same size, A and B, each having elements of complex values can be summed easily through the expression A+B. Are there any packages or techniques that can be recommended to employ programming these types of expressions in C or Objective C? I am aware of complex.h which allows for performing operations on complex numbers, but am unaware of how to perform operations on complex matrices, which is what I'm really after. Similarly, I'm aware of packages which allow for operations on matrices, but don't think they will be useful in working on complex matrices.
Source: (StackOverflow)
I have the following scenario:
- Editor Role should not be allowed to
delete nodes. Therefore the corresponding
permission is de-selected in the
permissions page.
- However Editor
should be able to to delete nodes
from Views Bulk operations. Using
Rules an action is created called
"safe delete" that checks things like
if the node is not published etc.
before deleting the node.
The problem is the Views Bulk Operations respects Node permissions. Editor will not be able to delete the node as he has not been given that permission. Is there a way that Editor can become a higher role user (as sort of sudo) while performing that action in VBO? Alternatively is there a way to tell VBO to ignore node access for this action?
I'm sure this is a mainstream requirement but I can't seem to find a solution.
Solutions which do not involve programming will be preferred.
Source: (StackOverflow)