I need an example of a slow Excel sheet that could exist in the real world. Problem is I'm not sure what sort of functions are computationally difficult.
Are there any sort of (maths?) functions that are easy enough to program that they can be used in Excel, yet computationally expensive?
Something which has a real world application is a bonus.
I dynamically load in a few li's that have a label and a checkbox in them to another visible ul. I set the checkboxes to be checked="checked" and i am trying to trigger an event to happen when i change these dynamically inserted checkboxes but nothing occurs.
Here is the jquery:
$(".otherProductCheckbox:checkbox").change( function(){
alert('test');
});
Here is the html for the dynamically added li's:
<li class="otherProduct"><input type="checkbox" class="otherProductCheckbox radioCheck" checked="checked"/><label>Product Name</label></li>
Any idea why i cant get the alert to happen when the checkbox changes its checked state?
Is there anyway to store users data such as userid, email, etc to be accessible from all pages of a website after they have logged in, but without using sessions or cookies?
For example:
class User
{
var $userid;
var $username;
var $email;
.. methods..
}
after they login at login.php
$currentUser = new User($_POST['username'])
now, how do I access $currentUser from another page, such as index.php if I shouldn't use sessions or cookies at all?
so that I could do the following in index.php:
if ($currentUser->userid > -1)
{
echo "you are logged in as: " . $currentUser->username;
}
else
{
echo "click here to login";
}
i asked a similar question before, here, but the answers didn't fulfill my needs.
I'm using the CakePHP blog example:
function add() {
if (!empty($this->data)) {
if ($this->Post->saveAll($this->data)) {
$this->Session->setFlash('Your post has been saved.');
$this->redirect(array('action' => 'index'));
}
}}
I want to modify it in a way that the user is redirected to the post after adding it:
But this doesn't work:
$this->redirect(array('action' => 'view', $this->Post->id)));
What is the correct way to read the model's data after creation?
Is there a framework which can be used in your application, to make it expose internal objects on some port for inspection.
for.e.g. after i start my application in this case a GUI Application, and then say launch http://localhost:9100 then it should show me the statistics of the app.
I played a bit with HttpListener accepting connections and then outputting raw HTML, it works fine for simple tasks, but there is too much worked involved if i have make a proper object browser.
Thanks in Advance.
I'm trying to make a hash function so I can tell if too lists with same sizes contain the same elements.
For exemple this is what I want:
f((1 2 3))=f((1 3 2))=f((2 1 3))=f((2 3 1))=f((3 1 2))=f((3 2 1)).
Any ideea how can I approch this problem ? I've tried doing the sum of squares of all elements but it turned out that there are collisions,for exemple f((2 2 5))=33=f((1 4 4)) which is wrong as the lists are not the same.
I'm looking for a simple approach it there are any.
Based on a click event on the page, via ajax I fetch a block of html and script, I am able to take the script element and append it to the head element, however WebKit based browsers are not treating it as script (ie. I cannot invoke a function declared in the appended script).
Using the Chrome Developer Tools I can see that my script node is indeed there, but it shows up differently then a script block that is not added dynamically, a non-dynamic script has a text child element and I cannot figure out a way to duplicate this for the dynamic script.
Any ideas or better ways to be doing this? The driving force is there is potentially a lot of html and script that would never be needed unless a user clicks on a particular tab, in which case the relevant content (and script) would be loaded. Thanks!
What is the difference between the $get and $find functions in javascript?
I'm guessing that these functions aren't really javascript-native things, so an additional question would be what are they native to?
Hi,
I need to make a stored procedure or function that returns a set of rows. I've noted that in a stored procedure i can SELECT * FROM table with success. If i fetch rows in a loop and SELECT something, something_other FROM table once per loop execution, I only get one single result.
What I need to do is looping, doing some calculations and returning a rowset. What's the best way to do this? A temporary table? Stored functions?
Any help appreciated.
I am building a program that takes a input file in this format:
title author
title author
etc
and outputs to screen
title (author)
title (author)
etc
The Problem I am currently getting is a error "ifstream infile has incomplee type and cannot be defined"
#include <iostream>
#include <string>
#include <ifstream>
using namespace std;
string bookTitle [14];
string bookAuthor [14];
int loadData (string pathname);
void showall (int counter);
int main ()
{
int counter;
string pathname;
cout<<"Input the name of the file to be accessed: ";
cin>>pathname;
loadData (pathname);
showall (counter);
}
int loadData (string pathname) // Loads data from infile into arrays
{
ifstream infile;
int counter = 0;
infile.open(pathname); //Opens file from user input in main
if( infile.fail() )
{
cout << "File failed to open";
return 0;
}
while (!infile.eof())
{
infile >> bookTitle [14]; //takes input and puts into parallel arrays
infile >> bookAuthor [14];
counter++;
}
infile.close;
}
void showall (int counter) // shows input in title(author) format
{
cout<<bookTitle<<"("<<bookAuthor<<")";
}
Thanks ahead of time,
kd7vdb
I was thinking QT on OpenGL.
Multiplatform ability and being able to be closed (at no cost) at a later point would be important points.
But I'm very interested in finding a way that is not only viable but also has the least amount of reinvention of the wheel.
e.g. "Why not Ogre? A ready powerful 3D engine without reinventing that part".
But I'm very uncertain in what is the optimal collection of tools for that job.
Is there a way to pass a wrap and unwrap a TObject descendent in an OleVariant? I am trying to pass a TObject across automation objects. I know it's not a good idea but I don't have a good alternative.
Something like this:
function GetMyObjAsVariant;
var
MyObj: TMyObj;
begin
MyObj := TMyObj.Create;
result := OleVariant(MyObj);
end;
Which would be used by a client as
var
MyObj: TMyObj;
begin
MyObj := GetMyObjAsVariant as TMyObj;
end;
This fails to compile, returning
E2015 Operator not applicable to this operand type.
Often, I have a list of objects. Each object has properties. I want to extract a subset of the list where a specific property has a predefined value.
Example:
I have a list of User objects. A User has a homeTown. I want to extract all users from my list with "Springfield" as their homeTown.
I normally see this accomplished as follows:
List users = getTheUsers();
List returnList = new ArrayList();
for (User user: users) {
if ("springfield".equalsIgnoreCase(user.getHomeTown())
returnList.add(user);
}
I am not particularly satisfied with this solution. Yes, it works, but it seems so slow. There must be a non-linear solution.
Suggestions?
I have a function to return points along a line and my return comes back with two decimal points...? For example, a return of my variable px will be something like -88.4029.032940598.
vx is the x vector and mult is the distance of the line plus distance to calculate the point.
Here is the operation that is returning these values:
var mult = parseFloat(mag + theUnit);
var px = coord_one.x_point + (vx * mult);
console.log(px);
Never have seen this before- I appreciate any and all help!
I am trying to add time to a Date object in javascript but am not getting the results that I am expecting. I am trying to pull a timer off of the page and add it to the current time to get the unix timestamp value of when the timer will hit zero. The time on the page is displayed as " HH:MM:SS ". This is what I have:
time=getTimerText.split(":");
seconds=(time[0]*3600+time[1]*60+time[2])*1000;
to convert the time into milliseconds.
fDate=new Date();
fDate.setTime(fDate.getTime()+seconds);
add the milliseconds to the javascript timestamp
alert(Math.round(fDate.getTime() / 1000));
convert the javascript timestamp to a unix timestamp
Since the timer is counting down I should get the same result every time i run the script, but I don't. Can anyone see what I might be doing wrong here?
Below is a simple program which computes sqrt of a number using Bisection. While executing this with a call like sqrtr(4,1,4) in goes into an endless recursion . I am unable to figure out why this is happening. Below is the function :
double sqrtr(double N , double Low ,double High )
{
double value = 0.00;
double mid = (Low + High + 1)/2;
if(Low == High)
{
value = High;
}
else if (N < mid * mid )
{
value = sqrtr(N,Low,mid-1) ;
}
else if(N >= mid * mid)
{
value = sqrtr(N,mid,High) ;
}
return value;
}
There is something I am missing. Say I have the following code:
private Bitmap source = new Bitmap (some_stream);
Bitmap bmp = new Bitmap(100,100);
Rectangle newRect = new Rectangle(0, 0, bmp.Width, bmp.Height);
Rectangle toZoom= new Rectangle(0, 0, 10, 10);
Graphics g = Graphics.FromImage(bmp);
g.DrawImage(source, newRect, toZoom, GraphicsUnit.Pixel);
My goal is to zoom-in the 10x10 pixels on the top left corner of the source picture. After I created the graphics object g and called DrawImage: the requested rectangle (toZoom) will be copied to bmp, or will it be displayed on the screen? I am a bit confused, can somebody please clarify?
I am creating an abstract class. I want each of my derived classes to be forced to implement a specific signature of constructor. As such, I did what I would have done has I wanted to force them to implement a method, I made an abstract one.
public abstract class A
{
abstract A(int a, int b);
}
However I get a message saying the abstract modifier is invalid on this item. My goal was to force some code like this.
public class B : A
{
public B(int a, int b) : base(a, b)
{
//Some other awesome code.
}
}
This is all C# .NET code. Can anyone help me out?
Update 1
I wanted to add some things. What I ended up with was this.
private A() { }
protected A(int a, int b)
{
//Code
}
That does what some folks are saying, default is private, and the class needs to implement a constructor. However that doesn't FORCE a constructor with the signature A(int a, int b).
public abstract class A
{
protected abstract A(int a, int b)
{
}
}
Update 2
I should be clear, to work around this I made my default constructor private, and my other constructor protected. I am not really looking for a way to make my code work. I took care of that. I am looking to understand why C# does not let you do this.
I have two tables:
Job
job_id, <other data>
Job_Link
job_link_id, job_id, start_timestamp, end_timestamp, <other data>
There may be multiple records in Job_Link specifying the same job_id with the start_timestamp and end_timestamps to indicate when those records are considered "current", it is guaranteed that start_timestamp and end_timestamp will not overlap.
We have entities for both the Job and Job_Link tables and defining a one-to-many relationship to load all the job_links wouldn't be a problem. However we'd like to avoid that and have a single job_link item in the Job entity that will contain only the "current" Job_Link object.
Is there any way to achive that?
Hi,
I have a Tour object which has many Place objects. For the list of tours, I want to show some info of the tour, the number of places of the tour, and three Place's images. Right one my SQL queries are (i'm using Doctrine with Symfony on MySQL)
get Tour
get Tour 1 places
get Tour 2 places
get Tour 3 places
...
get Tour n places
If I have a three Tour list, it's not so bad; but I'm sure it can get bad if I do a 10-20 tour-list. So, thinking on how to improve the queries I've thought of several measures:
Having a place count cache
Storing the urls of three images on a new tour field.
The problem with 2. is that if I change the image, I have to check all the tours to update that image for another one.
What solution do you think is best to scale the system in a near future? Any other suggestion.
thanks!
Using the Visual Studio Nov 2012 CTP, which supports variadic templates (among other things). The following code:
template<int, typename... Args>
void myfunc(Args... args)
{
}
template<>
void myfunc<1, float>(float)
{
}
produces the following errors:
error C2785: 'void myfunc(Args...)' and 'void myfunc(float)' have different return types
error C2912: explicit specialization 'void myfunc(float)' is not a specialization of a function template
(yeah, the first one is pretty funny)
So my questions are:
1) Am I writing legal C++11 here?
2) If yes, is there a way to find out if this is a known bug in MSVC before submitting it?
Hi,
i have a select box like that
<select name="sehirler_post" id="sehirler_post">
i am getting values via jquery. i know two different ways to get values.
first one is :
var sehirler_post = jQuery('select#sehirler_post').attr('value');
second one is:
jQuery('#sehirler_post ').val()
and finally here is my problem, i have something like this:
jQuery("#okay").load("ajax_post_category.php?okay="+id+"");
i would like to use selectbox value instead of id (okay="+id+"). so, i must change +id+ part with select box value. however i can not do it..
i tried to do like that:
jQuery("#okay").load("ajax_post_category.php?okay="+jQuery('#sehirler_post').val()+"");
it did not work. there must be a way, so i can use selectbox value instead of id in my load function. if anyone helps me, ill be so glad.
regards
Hi all,
Anybody know how can I add multiple email addresses in Outlook field "To" via C#?
foreach (var to in mailTo)
newMail.To += to + "; ";
When I try do it how I described this above I receive next kind of string:
[email protected]@[email protected]