I'm pretty proficient with PHP, outside of OOP - which I am just now starting to jump in to.
I've been watching videos and reading tutorials, but they are all still pretty confusing...
If I have
FILE 1 (class.time.php)
class Time {
function GetTime(){
$time = date('H:i:s');
printf($time);
}
}
and then in a nother php page I've got
FILE 2 (page.php)
I can do
include('class.time.php');
and then anywhere in this page I can then do
$time = new Time; //Calling the class and setting the class to a variable
$time->GetTime(); //This is BASICALLY saying (run the 'GetTime' function in the 'Time Class'
My main question is, is the comment above (This is BASICALLY saying.....) correct? or is there a better way to think of it?
friends, I have to trouble you as I couldn't find a solution after trying for a long time.
I have 3 columns of data. x, y, and the stress value (S) at every point (x, y). I want to generate a 2D color plot displaying continuous color change with the magnitude of the stress (S). The stress values increase from -3*10^4 Pa to 4*10^4 Pa. I only have hundreds of data sets for an area, but I want to see the stress magnitude (read from the color) at every location (x, y). What Matlab command should I use?
Thank you very much!
I want to make a 2D color plot showing stress magnitude (S) at very loctaion (x, y) based on continuous color change using limited
d = {'apple':9,'oranges':3,'grapes':22}
How do I return the largest key/value?
Edit: How do I make a list that has this sorted by largest to lowest value?
I have a very big table with a lot of rows, every row has stats for every user for certain days. And obviously I don't have any stats for future. So to update the stats I use
UPDATE Stats SET Visits=@val WHERE ... a lot of conditions ... AND Date=@Today
But what if the row doesn't exist? I'd have to use
INSERT INTO Stats (...) VALUES (Visits=@val, ..., Date=@Today)
How can I check if the row exists or not? Is there any way different from doing the COUNT(*)?
If I fill the table with empty cells, it'd take hundreds of thousands of rows taking megabytes and storing no data.
I have been searching the internet for the last few days trying to figure this out. My goal is to draw a textured and animated .x file exported from a 3D program. I found a tutorial of how to load and draw a .obj file, which I understand, but the tutorial doesn't say how to texture it, and .obj doesn't support animation. The .x file structure is human readable just like .obj, but I have no clue how to texture it, and I might be able to figure out how to animate it, but I would prefer to be instructed on that. Any help would be GREATLY appreciated.
This simple test, of course, works as expected:
scala var b = 2
b: Int = 2
scala b += 1
scala b
res3: Int = 3
Now I bring this into scope:
class A(var x: Int) { def +=(y:Int) { this.x += y } }
implicit def int2A(i:Int) : A = new A(i)
I'm defining a new class and a += operation on it.
I never expected this would affect the way my regular Ints behave.
But it does:
scala var b:Int = 0
b: Int = 0
scala b += 1
scala b
res29: Int = 0
scala b += 2
scala b
res31: Int = 0
Scala seems to prefer the implicit conversion over the natural += that is already defined to Ints. That leads to several questions...
Why? Is this a bug? Is it by design?
Is there a work-around (other than not using "+=")?
Thanks
I noticed that some enumerations have "None" as a enumeration member.
For example what I mean
enum Mode
{
Mode1 = 1,
Mode2 = 2,
Mode3 = 3,
None = 4
}
Why do they use it ? In what cases solution with a none member is more preferable (less preferable) ?
Suppose I have my models set up already.
class books(models.Model):
title = models.CharField...
ISBN = models.Integer...
What if I want to add this column to my table?
user = models.ForeignKey(User, unique=True)
How would I write the raw SQL in my database so that this column works?
Kohana's config files look like this.. here is an example of a database config file (simplified)
return array(
'dbhost' => 'localhost',
'user' => 'Tom_Jones'
);
I've also got a CMS which wants the connection details. Whilst the CMS uses a different user (with more rights), I'd like to know the best way to include this file and get the data out of it (so as to not repeat myself for hostname and dbname).
I haven't thought up of any elegant solutions yet and have not yet dug around Kohana to see how it does it. It's late Friday here so it's probably really obvious to everyone except me.
UPDATE
My apologies, I forgot to include that this is using Kohana 3!
I notice my query doesn't behave correctly if one of the like variables is empty:
SELECT name
FROM employee
WHERE name LIKE '%a%'
AND color LIKE '%A%'
AND city LIKE '%b%'
AND country LIKE '%B%'
AND sport LIKE '%c%'
AND hobby LIKE '%C%'
Now when a and A are not empty it works but when a, A and c are not empty the c part is not excuted so it seems?
How can I fix this?
I am using the Kohana 3 framework, and am using the native session driver.
For some reason, occasionally the sessions fail to write to their file.
Warning: session_start() [function.session-start]: open(/tmp/sess_*****, O_RDWR) failed: Permission denied (13) in /home/site/public_html/system/classes/kohana/session/native.php on line 27
I am pretty sure Kohana has its own in built error handler, but it is not triggered with this error (i.e. it shows up like a normal PHP error, not the Kohana error).
Anyone that has ever used Kohana will notice this seems to have bypassed Kohana's error handling (perhaps set with set_error_handler()).
Is there anyway to stop this error from appearing without switching from the native session (i.e. file based) driver?
Should I just give good practice the boot and append an @ error suppressor to session_start() in the core code of Kohana? Should I relax the error_reporting()?
Thanks
I'm using the latest CKeditor with jQuery adapter.
I have successfully got it to work, and display.
However, as I am completely new to CKeditor, how do I pass in config variables using the jQuery method?
This is what I've got
$( '#input-content' ).ckeditor('', {
toolbar: 'basic'
});
I think from what I've read, the first argument is meant to be a callback, and the 2nd the config. But doing this has not changed the editor at all.
How do I use these config properties etc using the jQuery adapter?
Thanks
I'd like to get the latest NHibernate build or build it by my own. The build available at SourceForge is dated by Nov 2009, although I see there was a lot of activity later, especially related to LINQ development.
So what is the best option? I can:
Get the latest source code and try to build it. Are there any instructions for this?
Get one of latest builds shared by someone else. Are there any people maintaining such builds?
Please note, that I'm not interested in 8-month old builds - I need the latest code for tests (LINQ, performance).
I know there is a similar question, but it looks like top answers there are outdated.
I wonder if this is possible with straight SQL on MySQL. I need to do SELECT COUNT(*) FROM on each table in the database and output results in one result set.
Is it possible to do with just SQL?
I have an analysis that can be parallelized over a different number of processes. It is expected that things will be both IO and CPU intensive (very high throughput short-read DNA alignment if anyone is curious.)
The system running this is a 48 core linux server.
The question is how to determine the optimum number of processes such that total throughput is maximized. At some point the processes will presumably become IO bound such that adding more processes will be of no benefit and possibly detrimental.
Can I tell from standard system monitoring tools when that point has been reached?
Would the output of top (or maybe a different tool) enable me to distinguish between a IO bound and CPU bound process? I am suspicious that a process blocked on IO might still show 100% CPU utilization.
I have just seen this in code
var thisYear = (new Date()).getFullYear();
See it live on JSbin.
This is cool, as I've always done something like that in 2 lines, i.e. create the new object instance and assigned it to a variable, then called the method on it.
Is this new method fine to use everywhere? Any gotchas?
Why does x alerts undefined for iframe but works for embed. I'm grabbing the iframe or embed code from a textarea
<iframe src="http://www.youtube.com/embed/9kiWvkj2ldWiU?hd=1"></iframe>
var textarea = $('#embedModal textarea'),
textareaValue = textarea.val(),
$embed = $($(textareaValue).find('iframe')),
x = $embed.attr('src');
alert(x); //alerts undefined for iframe
If you change find('iframe') to find('embed') and you try with the below embed code. then i'm able to get the value of src, but with iframe i get undefined. Seems strange.
<embed src="http://www.youtube.com/embed/9kiWvkj2ldWiU?hd=1"></embed>
how do i write a query that returns aggregate sales data for California in the past x months.
----------------------- -----------------------
| order | | customer |
|-----------------------| |-----------------------|
| orderId int | | customerId int |
| customerId int | | state varchar |
| deposit decimal | -----------------------
| orderDate date |
-----------------------
-----------------------
| orderItem |
|-----------------------|
| orderId int |
| itemId int |
| qty int |
| lineTotal decimal |
| itemPrice decimal |
-----------------------
Is it possible to clear a file preserving its timestamp, using standard Linux commands? For example:
echo "" file-name
converts the text file to empty, this is OK for me. But I need to keep the timestamp unchanged.
I'm making a new php page and I get the error
Fatal error: Call to undefined function phpinclude_once() in /home8/nuventio/public_html/marketing/pb2/dashboard.php on line 1
I'm not sure why I'm getting this error, I've done previous pages the same way as this with no problems. This is the line in question:
<?php
include_once("../utils.php");
?>
After that it just goes into regular HTML code. It works fine without that line.