18-08-2009, 18:44
|
#91
|
Inactive
Join Date: Dec 2005
Posts: 23
|
Re: Programming Challenges?
Quote:
Originally Posted by punky
Change your Reply To Thread box from HTML WYSIWYG to plain text. You can toggle it by clicking the  button in the top right.
|
That does the trick. Many thanks.
Never noticed the stuff in the top right before. Must be old age
|
|
|
19-08-2009, 07:18
|
#92
|
Inactive
Join Date: Jul 2009
Location: In the thick of East Anglia
Posts: 573
|
Re: Programming Challenges?
When I was learning C in the 80's, I used to write programs to prove or disprove if a number is prime. Specifically the Lucas Lehmer test.
Easy to do in C. Re-writing in 8051 assembler will make you a real programmer. Moreso if you then re-write code to get your graphics card to do it using ultrafast VRAM.
Dissassembling programs is also good practise. Compile a program to multiply two numbers, go and look at the generated code and try to work out what's going on.
I personally always find assembly programming more challenging. Getting a floating point divide to work is easy. Not in 128bytes of stack in 512bytes of reserved code space it isn't.
|
|
|
19-08-2009, 08:35
|
#93
|
Remoaner
Cable Forum Team
Join Date: Mar 2004
Posts: 32,719
|
Re: Programming Challenges?
Quote:
Originally Posted by Waldo Pepper
I personally always find assembly programming more challenging. Getting a floating point divide to work is easy. Not in 128bytes of stack in 512bytes of reserved code space it isn't.
|
Thankfully we have better languages to abstract tasks like that away from us
|
|
|
19-08-2009, 12:00
|
#94
|
laeva recumbens anguis
Cable Forum Team
Join Date: Jun 2006
Age: 68
Services: Premiere Collection
Posts: 43,475
|
Re: Programming Challenges?
Quote:
Originally Posted by Damien
Thankfully we have better languages to abstract tasks like that away from us 
|
Yup - machine time/hardware cheap, people time expensive (which does not excuse carp/inefficient code).
__________________
Thank you for calling the Abyss.
If you have called to scream, please press 1 to be transferred to the Void, or press 2 to begin your stare.
If my post is in bold and this colour, it's a Moderator Request.
|
|
|
19-08-2009, 12:33
|
#95
|
Remoaner
Cable Forum Team
Join Date: Mar 2004
Posts: 32,719
|
Re: Programming Challenges?
Quote:
Originally Posted by foreverwar
Yup - machine time/hardware cheap, people time expensive (which does not excuse carp/inefficient code).
|
Nope for a start others need to maintain it, inefficiency is avoided but I don't think it's as massive a problem as people make out. Often the areas you think a inefficient are not so while other areas may be. Anything web based then bandwidth is probably your most precious resource which you need to optimise.
For example the optimisations we were doing on Month Hall would have no noticeable effect, if you were doing a website and sending too much kb to the client it would be very notable.
|
|
|
20-08-2009, 10:19
|
#96
|
Inactive
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
|
Re: Programming Challenges?
What's wrong with this c code?
Code:
#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
}
---------- Post added at 10:19 ---------- Previous post was at 10:10 ----------
NVM - nothing wrong with the code, something wrong with Ubuntu.
It doesn't include the standard libraries as part of the install, which means that the code above won't compile.
Sorted now.
|
|
|
20-08-2009, 17:19
|
#97
|
Permanently Banned
Join Date: Jun 2003
Location: Nr Carnforth
Age: 49
Services: M6 Keele
Posts: 5,462
|
Re: Programming Challenges?
This may be a good place to ask this question which is probably too simples to have a thread of it's very own. Working on upgrading our current flat db to a more complex relational db in order to speed things up both in use and data entry. This bit of code is the index of dates.
I have 2 tables - courses and dates and each course can be associated with many dates.
This went well till a 4th date was added now I get an error.
Quote:
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 9 in /home/purple/public_html/test/date_index.php on line 24
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 9 in /home/purple/public_html/test/date_index.php on line 25
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 9 in /home/purple/public_html/test/date_index.php on line 26
Start Date: 22/08/09
Course:
|
As I understand my code it gets an array of the dates and for each one it uses the course_id to get the course_name from the courses db.
Can anyone explain what I'm doing wrong?
Code:
<?php
include("menu.php");
include("connect.php");
$query="SELECT * FROM date ";
$result=mysql_query($query);
$num = mysql_num_rows ($result);
mysql_close();
if ($num > 0 ) {
$i=0;
while ($i < $num) {
$date_start = mysql_result($result,$i,"date_start");
$course_id = mysql_result($result,$i,"course_id");
$id = mysql_result($result,$i,"id");
$date = date("d/m/y",strtotime($date_start));
include("connect.php");
$query2="SELECT * FROM course WHERE (`id`='$course_id') ";
$result2=mysql_query($query2);
$num2 = mysql_num_rows ($result2);
mysql_close();
$i2=0;
$code = mysql_result($result2,$i2,"code");
$name = mysql_result($result2,$i2,"name");
$id = mysql_result($result2,$i2,"id");
echo "<b>Start Date:</b> $date<br>";
echo "<b>Course:</b> $name<br>";
echo "<a href=\"date_update.php?id=$id\">Update Date</a> - <a href=\"date_delete.php?id=$id\">Delete Date</a>";
echo "<br><br>";
++$i; } } else { echo "The database is empty"; }?>
The Error is
|
|
|
31-08-2009, 09:21
|
#98
|
Inactive
Join Date: Jun 2003
Age: 44
Posts: 14,750
|
Re: Programming Challenges?
I remember what heero was saying about microprogramming, so I thought this was worth posting. Its an IP stack (sort of) that fits inside a Twitter tweet.
http://www.sics.se/~adam/twip.html
Code:
char b[140];unsigned short *s=b;*l=b;t;main(){while(1){read(0,b,140);b[20]=0;s[11]+=8;t=l[4];l[4]=l[3];l[3]=t;write(1,b,140);}}
|
|
|
16-09-2009, 22:20
|
#99
|
Inactive
Join Date: Jun 2003
Age: 44
Posts: 14,750
|
Re: Programming Challenges?
Bit of a bump, I stumbled on a great programming blog today (well judgng by the latest few articles anyway)
http://cafe.elharo.com/
Its aimed at experienced programmers but novice ones can learn a lot from those more experienced.
|
|
|
17-09-2009, 12:28
|
#100
|
Virgin Media Employee
Join Date: Sep 2005
Location: Winchester
Services: Staff MyRates
BB: VM 1Gb
TV: VM XL
Phone : VM XL
Posts: 3,274
|
Re: Programming Challenges?
Try Perl, nice easy and big following. Head over to Perlmonks for support, help and Perl chat.
__________________
I work for VMO2 but reply here in my own right. Any help or advice is made on a best-effort basis. No comments construe any obligation on VMO2 or its employees.
|
|
|
17-09-2009, 12:37
|
#101
|
-
Join Date: Jun 2003
Location: Somewhere
Services: Virgin for TV and Internet, BT for phone
Posts: 26,546
|
Re: Programming Challenges?
I have to admit, I miss c++ programming. I used to write a lot of little utils for admin stuff in work (restarting machines remotely, monitoring them, that sort of thing) in c++, but the boss had this idea of centralising all our admin stuff on one website.
So, any utils I write now have to be created using ASP, PHP or Perl. Of course, I could write something in c++ that just interfaces with the site using CGI, but I don't think that would be allowed.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +1. The time now is 22:42.
|