Hi
in mysql how to write a sql like this, to get the amount of X 20 and <20
select date, numberOfXMoreThan20,numberOfXLessThan20, otherValues
from table
group by (date, X20 and X<20)
thanks
how can i create method which return sqrt of given nunber? for example sqrt(16) returns 4
and sqrt(5) returns 2.3... please help i am using java and know Math.sqrt() API function but i need method itself
in my cms i have index.php, where client must enter username and password. if they are correct, he'll moove to admin.php, where the cms is.
but now hacker can enter to cms/admin.php, so my security now is awful.
i know, that i can use $_SESSION variable.
index.php - i can give some value to $_SESSION['success']:
$_SESSION['success'] = TRUE, and in admin.php just verify it
admin.php
if($_SESSION['success'] == TRUE)
{
my script here...
}
else header("Location: index.php");
but i want to rich this effect without SESSION.
could you give me an idea, how can i do it?
thanks
Hi,
When creating a branch, what are the implications of selecting the following?
Create copy in the repository from:
HEAD revision in the repository
Specific revision the repository
Working copy
char *sample = "String Value";
&sample is a pointer to the pointer of "String Value"
is the above statement right?
If the above statement right, what is the equivalent of &sample if my declaration is
char sample[] = "String Value"
I'm saving my image to photo gallary , but I want to fetch this image on click of UIButton and want to show it on the UIImageview or UIview.My code for saving image on photo gallery is as under:-
I don't want to use UIImagePickerViewController any where in my programme
UIImage *image = [UIImage imageNamed:@"flower.png"];
UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);
Why the following code prints "0-100"?
(function () {
for ( var i = 100; i >= 0; i -= 5) {
(function() {
var pos = i;
setTimeout(function() {
console.log(" pos = " + pos);
}, (pos + 1)*10);
})();
}
})();
I declare pos = i , which should be in a descending order. This code originated from John Resig' fadeIn() function in his book Pro javascript techniques.
Would it be possible to do something like the following in c#?
Basically TParent and TChildren should be types of the class A but not necessairly have the same types that were passed in. I know this may sound confusing but I want to strongly type the children and parents of a particular object, but at the same time they must be of the same type. Because TParent inherits from A this would imply that it requires type parameters that inherit from A but using potentially different types.
public class A<TParent, TChildren>
where TParent : A
where TControls : A
{
TParent Parent;
List<TChildren> Children;
}
or more easily seen here:
public class A<TParent, TChildren>
where TParent : A<?, ?>
where TChildren : A<?, ?>
{
TParent Parent;
List<TChildren> Children;
}
I hope this isn't too confusing. Is this at all possible?
Thanks :)
Hello Folks,
I am trying to develop a application where
The user 'X' has logged into Facebook
app has a set of email addresses (possible friends of user 'X')
app gets the list of friends of user 'X' (uids)
Want to check if user with email address [email protected] is a valid facebook user by using email address and is user X's friend (basically a uid to email mapping)
Thanks!
If I use proprocessor directives to define which code an OS will run, like so:
#if winXP // Compiling for Windows XP
platformName = "Microsoft Windows XP";
#elif win2000 // Compiling for Windows 2000
platformName = "Microsoft Windows 2000";
#elif win7 // Compiling for Windows 7
platformName = "Microsoft Windows 7";
#else // Unknown platform specified
platformName = "Unknown";
How does the system pick up which OS is being used?
This is an example from the book Visual C# 2010 Recipes, where the author says that the platformName variable (declaration ommitted), wil equal the OS above.
Thanks
following piece of code does not compile, the problem is in T::rank not be inaccessible (I think) or uninitialized in parent template.
Can you tell me exactly what the problem is?
is passing rank explicitly the only way? or is there a way to query tensor class directly?
Thank you
#include <boost/utility/enable_if.hpp>
template<class T, // size_t N,
class enable = void>
struct tensor_operator;
// template<class T, size_t N>
template<class T>
struct tensor_operator<T, typename boost::enable_if_c< T::rank == 4>::type > {
tensor_operator(T &tensor) : tensor_(tensor) {}
T& operator()(int i,int j,int k,int l) {
return tensor_.layout.element_at(i, j, k, l);
}
T &tensor_;
};
template<size_t N, typename T = double>
// struct tensor : tensor_operator<tensor<N,T>, N> {
struct tensor : tensor_operator<tensor<N,T> > {
static const size_t rank = N;
};
I know the workaround, however am interested in mechanics of template instantiation for self-education
Hi
I know this is something simple I am doing wrong.
I have three tables, installation, neighborhood, schools
Installation:
has_many :schools
has_many :neighborhoods
Neighborhood:
has_many :installations
has_many :schools
Schools:
belongs_to :installations
belongs_to :neighborhoods
I can't figure out how to show the name of the neighborhood the school is located in on the index view. I can get it to show on the show view once I have the school id. But on the index view I can't figure out what to put in the controller that will allow me to access the neighborhood name from the neighborhood_id that is in the School model. I am sure this is so easy and I am screwing up something stupid.
HELP!
Hi,
I have this POSIX thread:
void subthread(void)
{
while(!quit_thread) {
// do something
...
// don't waste cpu cycles
if(!quit_thread) usleep(500);
}
// free resources
...
// tell main thread we're done
quit_thread = FALSE;
}
Now I want to terminate subthread() from my main thread. I've tried the following:
quit_thread = TRUE;
// wait until subthread() has cleaned its resources
while(quit_thread);
But it does not work! The while() clause does never exit although my subthread clearly sets quit_thread to FALSE after having freed its resources!
If I modify my shutdown code like this:
quit_thread = TRUE;
// wait until subthread() has cleaned its resources
while(quit_thread) usleep(10);
Then everything is working fine! Could someone explain to me why the first solution does not work and why the version with usleep(10) suddenly works? I know that this is not a pretty solution. I could use semaphores/signals for this but I'd like to learn something about multithreading, so I'd like to know why my first solution doesn't work.
Thanks!
I am using the Jquery library to copy the text enter in one textfield to another textfield using a check box when clicked.. which is as follows
<html>
<head>
<script src="js/jquery.js" ></script>
</head>
<body>
<form>
<input type="text" name="startdate" id="startdate" value=""/>
<input type="text" name="enddate" id="enddate" value=""/>
<input type="checkbox" name="checker" id="checker" />
</form>
<script>
$(document).ready(function(){
$("input#checker").bind("click",function(o){
if($("input#checker:checked").length){
$("#enddate").val($("#startdate").val());
}else{
$("#enddate").val("");
}
});
}
);
</script>
</body>
</html>
now here i want the check box to be selected by default, so that the data entered in start date get copied automatically as check box is checked by default... so what event should be called here in jquery script?
please help me in resolving this issue...
I've an access database table with 3 fields :
Purchase date
Warranty time
Warranty expiry
Warranty time has 1, 2, 3, 4, 5 in it which corresponds to years.
How can I auto-populate the 'Warranty expiry' field (which is a date field) by looking at the 'Purchase date' and then adding on the 'Warranty time' (warranty time will be 1 = 365 days, 2 = 730 days, etc)?
Hi,
I would like to be able to round up any number to quater of the whole number.
For example:
100.33 - 100.50
100.12 - 100.25
100.66 - 100.75
100.99 - 101.00
100.70 - 100.75
100.00 - 100.00
100.25 - 100.25
etc...
thank guys...
I have a scale that connect to PC through RS232, I send "W" to receive the weight. The scale sends the weight all the time as it's read. How do I catch the weight that is being read?
Can i get any C# sample code?
Back in the old days of C, one could use array subscripting to address storage in very useful ways. For example, one could declare an array as such.
This array represents an EEPROM image with 8 bit words.
BYTE eepromImage[1024] = { ... };
And later refer to that array as if it were really multi-dimensional storage
BYTE mpuImage[2][512] = eepromImage;
I'm sure I have the syntax wrong, but I hope you get the idea.
Anyway, this projected a two dimension image of what is really single dimensional storage.
The two dimensional projection represents the EEPROM image when loaded into the memory of an MPU with 16 bit words.
In C one could reference the storage multi-dimensionaly and change values and the changed values would show up in the real (single dimension) storage almost as if by magic.
Is it possible to do this same thing using C#?
Our current solution uses multiple arrays and event handlers to keep things synchronized. This kind of works but it is additional complexity that we would like to avoid if there is a better way.
Hi,
I've seen in (Apple) sample code two types of ways of allocation memory, and am not sure I understand the difference and resulting behavior.
// FAILS
NSMutableArray *anArray = [NSMutableArray array];
[anArray release];
// WORKS
NSMutableArray *anArray1 = [[NSMutableArray alloc] init];
[anArray release];
By "FAILS" I mean I get crashes/runtime warnings etc., and not always as soon as I call the release...
Any explanation appreciated.
Thanks
I have a table named ChatSessions where I keep track of active users in the chatroom. I need to prune expired user sessions from the table every 10 minutes. Using pure php-mysql is plain simple but I'm totally clueless how to convert this into ActiveRecord in CodeIgniter. The plain SQL query is below:
SELECT *
FROM `ChatSessions`
WHERE `SessionExpires` < DATE_SUB( NOW( ) , INTERVAL 10 MINUTE )
Can anybody tell me what is the equivalent code in CodeIgniter using ActiveRecord?
Thanks in advanced.
Hello all, complete newbie here,
I need to find a way to store 250 KB of plain text numbers inside my program's executable file.
Usually, I would put the data in a separate file and let the program read it while it is running, but that's not an option here. Instead, the program and the data need to be in one executable file.
I have absolutely no idea how to do it (except writing 250.000 #defines :-) and I'd appreciate any suggestions.
Thank you very much!
Want to verify that my understanding of how this works.
Have an unmanaged C++ Class with one public instance variable:
char* character_encoding;
and whose only constructor is defined as:
TF_StringList(const char* encoding = "cp_1252");
when I use this class in either managed or unmanaged C++, the first thing I do is declare a pointer to an object of this class:
const TF_StringList * categories;
Then later I instantiate it:
categories = new TF_StringList();
this gives me a pointer to an object of type TF_StringList whose variable character_encoding is set to "cp_1252";
So, is all that logic valid?
Jim
I was involved in an interesting debate about the visibility of domain models & was wondering if people here have any good guidance.
Per my understanding of MDA, we need not expose the domain model throughout the application layers & tiers
The reason being that any change to the domain model has an impact in the overall application
The wise thing to do would be to expose light-weight object (DTO's) which are a small sub-set of the domain model to abstract the actual model
On the flip side, any change to the domain model would mean changing various DTO's throughout the application for the change to be visible, while if we do expose the domain model, then the change is in a single location
Hope to see some comments & thoughts about this.
Appreciate all the help!