I'd like to grab daily sunrise/sunset times from here. Is it possible to scrape web content with Python? what are the modules used? Is there any tutorial available?
Thanks
It's been asked a million times, its like this.
Say Invoice is the base class and InvoiceHistory is the class that simply inherits from Invoice.
When I do something like
invoiceList = session.CreateCriteria(typeof(Invoice)).List();
I get everything from Invoice (that I want, plus everything from InvoiceHistory).
Do I need to have an InvoiceBase and create derived versions for Invoice and InvoiceHistory?
In C, it is considered bad practice to call strlen like this:
for ( i = 0; strlen ( str ) != foo; i++ )
{
// stuff
}
The reason, of course, is that it is inefficient since it "counts" the characters in a string multiple times.
However, in Python, I see code like this quite often:
for i in range ( 0, len ( list ) ):
# stuff
Is this bad practice? Should I store the result of len() in a variable and use that?
Using Delphi 2009 + Firebird 2.1.3.
Database is ODS 11.1, default char set is UTF8.
My prepared query is as follows:
SELECT
a.po_id, a.po_no
FROM
purchase_order a
WHERE EXISTS
(SELECT 1
FROM
sales_order_item z1
JOIN
purchase_order_item z2
ON
z2.so_item_id = z1.so_item_id
AND
z2.po_id = a.po_id
WHERE z1.so_id = :soid)
ORDER BY a.po_no
Now when I loop this say 1000 times because I have 1000 x so_id, the CPU usage get at 100% for FBSERVER.EXE
Anyone encountered this problem?
I need to random some elements from an array. I'm doing that by randomizing the index $array[int(rand(100))]. I want some of the elements to appear more often. How do I do it?
I thought of a stupid solution of having those elements duplicated several times in the array, but I'm sure you guys can do better.
im using symfony with doctrine and zend.
i wonder if i wanna validate the user input data, should i use validation from symfony, zend or even doctrine?
i think i should go with symfony, but are there times the validation from zend or doctrine would be better?
thanks
There are often times I'll grep -l whatev file to find what I'm looking for. Say the output is
1234: whatev 1
5555: whatev 2
6643: whatev 3
If I want to then just extract the lines between 1234 and 5555, is there a tool to do that? For static files I have a script that does wc -l of the file and then does the math to split it out with tail & head but that doesn't work out so well with log files that are constantly being written to.
I am new in Prolog. I need to declare a function which looks at a list like
[[1, 0, 0], [1, 0, 0], [1, 0, 0]]
and if the value is 0 returns its address(by considering it as a double array).
I wrote a function basicly in the format:
function(..., X) :-
function(called by other values).
How can I write a function, that returns a value when each times it called(recursively). May I get them (in above question) as alternative X's???
Hi,
I am a bit new to reusable plugins for jquery. I have ran across this code several times and can't figure out exactly what is going on.
(function( $ ){
...
})( jQuery );
Can any one enlighten me?
Many times when I lose connection to my development server, I just log back in and have a .swp file to deal with when I re-open. Does vim have a mod to allow deleting by initial prompt?
Thanks
For example: mc_A play and in the end starts it starts mc_B to play. mc_B starts in the end mc_B starts mc_C ....
other idea: the moviclips start at different times with a timer? I hoppe somebody can help me, cause I didn´t find the right code! Thanks a lot
Hi,
I have an existing application that i want to implement password resets after 30 days.
But i dont want the user to use the same password as the last 5 times.
How do i go about doing this or is there any links i can follow.
Please help
Thanks,
I am writing a program that will need to measure time in minutes.
To be exact, it will wait 10 minutes, execute some code, wait 2 minutes, execute more code and repeat this 5 times (anyone guess what I'm trying to do?) and I am wondering how to do the breaks.
Thanks in advance!
Oh, and by the way, I'm on Mac.
I have a double value that equals 1.212E+25
When I throw it out to text I do myVar.ToString("0000000000000000000000")
The problem is even if I do myVar++ 3 or 4 times the value seems to stay the same.
Why is that?
I do not understand what is meant by the terms "compile time" and "run time" (or "runtime").
I'm also a bit confused about what "value type" and "reference type" mean, and how they relate to the 'times mentioned above.
Would someone please explain these things?
I was asked this interview question so thought I would post it here to see how other users would answer:
Please write some code which connects to a MySQL database (any host/user/pass), retrieves the current date & time from the database, compares it to the current date & time on the local server (i.e. where the application is running), and reports on the difference. The reporting aspect should be a simple HTML page, so that in theory this script can be put on a web server, set to point to a particular database server, and it would tell us whether the two servers’ times are in sync (or close to being in sync).
This is what I put:
// Connect to database server
$dbhost = 'localhost';
$dbuser = 'xxx';
$dbpass = 'xxx';
$dbname = 'xxx';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (mysql_error());
// Select database
mysql_select_db($dbname) or die(mysql_error());
// Retrieve the current time from the database server
$sql = 'SELECT NOW() AS db_server_time';
// Execute the query
$result = mysql_query($sql) or die(mysql_error());
// Since query has now completed, get the time of the web server
$php_server_time = date("Y-m-d h:m:s");
// Store query results in an array
$row = mysql_fetch_array($result);
// Retrieve time result from the array
$db_server_time = $row['db_server_time'];
echo $db_server_time . '<br />';
echo $php_server_time;
if ($php_server_time != $db_server_time) {
// Server times are not identical
echo '<p>Database server and web server are not in sync!</p>';
// Convert the time stamps into seconds since 01/01/1970
$php_seconds = strtotime($php_server_time);
$sql_seconds = strtotime($db_server_time);
// Subtract smaller number from biggest number to avoid getting a negative result
if ($php_seconds > $sql_seconds) {
$time_difference = $php_seconds - $sql_seconds;
}
else {
$time_difference = $sql_seconds - $php_seconds;
}
// convert the time difference in seconds to a formatted string displaying hours, minutes and seconds
$nice_time_difference = gmdate("H:i:s", $time_difference);
echo '<p>Time difference between the servers is ' . $nice_time_difference;
}
else {
// Timestamps are exactly the same
echo '<p>Database server and web server are in sync with each other!</p>';
}
Yes, I know that I have used the deprecated mysql_* functions but that aside, how would you have answered, i.e. what changes would you make and why? Are there any factors I have omitted which I should take into consideration?
The interesting thing is that my results always seem to be an exact number of minutes apart when executed on my hosting account:
2012-12-06 11:47:07
2012-12-06 11:12:07
i have included the plugin and written code like
if(page) { $.post(page,{},function(data){callBackFunction(data)}); }
function callBackFunction(data)
{
$('.page_change').html(data);
$('.page_change').effect("bounce", { times:3 }, 300);
$('#submit_show').show();
}
The data change is happening but the bouce effect i am not getting..how do i solve this issue..
I have in my model:
def presenter
@presenter ||= ProfilePresenter.new(self)
@presenter
end
The ProfilePresenter is a class that has methods like, get_link(), get_img_url(size), get_sex(), get_relationship_status() and other methods that have not to do with the model, not even with the controller but is used multiple times in the view.
So now i use them by doing this:
Profile.presenter.get_link
# or
Profile.presenter.get_img_url('thumb') # returns the path of the image. is not used to make a db query
I want to create a C# app which rests in the system tray.
However, I would like this application to overlay certain graphic elements / drawing on top of the screen above all windows at certain times.
So, for example, while my application is running, even though minimized to the tray, it will draw certain shapes on top of the screen regardless of what is there.
Is this possible using C#? If not, is there any other language that would have this capability?
Is there any efficient way in python to count the times an array of numbers is between certain intervals? the number of intervals i will be using may get quite large
like:
mylist = [4,4,1,18,2,15,6,14,2,16,2,17,12,3,12,4,15,5,17]
some function(mylist, startpoints):
# startpoints = [0,10,20]
count values in range [0,9]
count values in range [10-19]
output = [9,10]
I've been told a few times that Business Units in CRM 2011 are "tricky" and shouldn't be set up lightly since they have irreversible consequences for a CRM 2011 implementation.
On the other hand, teams in CRM 2011 seem much more flexible in managing record security.
For what reason would I still choose to set up Business Units in CRM 2011? What can I do with Business Units that I can't with Teams (and vice versa)?
I have 10 tables from which 4 contain each up to million rows. All values are inserted at once, and afterwards I only read the data many times. I am searching for a database that would perform greatly when it comes to selecting, joining or other reading etc.
What is the most recommended option?
Hi All
I have been reading the articles on MSDN, but my mind is dead (this usually happens when I read MSDN (No offense MSDN, but your articles confuse me at times.)), and I'm trying to do some "background work" in may app, but not sure how. It's just a single method. But the application hangs, and I have to wait up to 1 - 3 minutes for it to become ...unhanged?
Are there any simple examples that are laying 'roun online somewhere that I can have a look at/play around with?
Thank you all
Hello! :-)
I'm beginning to use the swtbot to test my reccent eclipse rcp projekt. A specific editor is opened multiple times in my application and want to count how often the editor is opened.
How can i do that using swtbot?
Thanks! :-)
I would like to obtain all the versions of a given file in my SVN repository. For instance, let's say that the file ThirdPartyAssembly.dll was checked 3 times, is there a command that will get me all the version on my HD (e.g. ThirdPartyAssembly.dll.v1, ThirdPartyAssembly.dll.v2, ThirdPartyAssembly.dll.v3, etc.)?
Thanks!