View Full Version : The Off Topic Programming Thread!
Dygear
15th April 2006, 13:13
... Let the off topicness begin!
What is your most hated function call?
For me it's preg_match in the PHP Programing Langue, I just don't get it, however many times I read the manual.
colcob
15th April 2006, 13:16
Yeah, I have failed to get reg expressions full stop. I mean I know in principle what they do, but arggh that syntax does my head in.
the_angry_angel
15th April 2006, 13:23
Regular expressions are definately one of those things that drive me nuts, as well. Unfortunately I have to use a variety of editors, both personally and at work - all of which have radically different regex markup. For instance ^p in Ultra Edit for a newline, instead of \n.
If you start using something like gVim, or Scite with a decent RegExp search and replace, you do start learning it more. Often though, I have to resort to testing things on my regexp tool :(
Currently the functions doing my head-in, are in the APR-Util bucket and brigade module (http://apr.apache.org/docs/apr-util/group___a_p_r___util___bucket___brigades.html). It makes sense, until you want to run a transform on the whole set of data, instead of a chunk :( Although I love the new Apache HTTPD filter system, its rather different and confusing for a few days (since it relies on APR buckets and brigades).
Edit: if anyone knows the best way to do the above, please give me a shout :)
filur
15th April 2006, 15:13
Regular expressions are by far my favorite tool. :)
Very tricky to get used to, but once you're there pretty much any other string parsing thingie seems completely useless. The only problem is when expressions get very long. :)
@Dygear, sections on regular expressions in the PHP manual is basically for people who already know how to use them, it's more just a list of modifiers and basic syntax, google for some tutorials or buy a book instead, it'll be worth it.
Most hated function call? fork(), it doesn't work on Windows. (PHP)
<?php
$str = stream_get_contents(fopen("http://liveforspeed.net","r"));
echo preg_replace(array(
"/\n/ms",
"/<.[^>]*>/ms",
"/.*April.[^W]*|(?=\!).*/ms",
"/a(r)e/",
"/th(?=[ai])/"
),
array(
" ",
"",
"",
"\\1",
"d"
),
$str) . "!!1! (rly?)\n";
?>
sdether
15th April 2006, 17:01
Regular expressions are by far my favorite tool. :)
Same here. It's the reason i got into perl in first place. I admit that regex is a pain in almost every other language, but it just part of the landscape in perl.
Most of my programming now revolves around building object models, but when someone hands me a text file and needs the data to be converted into something else, or have something extracted from it, I always whip up a perl script to do the regex and write the data out in a format that's easier to parse for my other code.
Dygear
16th April 2006, 12:59
Thanks filur :). I'll look more into the function as well, see what it does ...
[edit] ... LOL The script tosses this out " We r pleased to announce dat there will be an important S2 update dis month!!1! (rly?) " ...
Dygear
16th April 2006, 20:37
Parsing Packets With PHP (Cool Title Don't Ya Think - God I Need To Get A Life.)
Anyway, I have been playing around with the code that was posted on the fourms here not to long ago by our resident PHP InSim Guru filur. Anyway, in his exprament he simply took the first 3 charaters from the packet and added a little Keanu Reeves 'Whoa' to it then thow it out for us all to see. But it only had the packet identifier, it did not have information on what the packet really had in it.
So this it my (failed) attemp to read a LAP packet from the server using PHP.
<?php
stream_set_blocking( $socketOut = fsockopen( "udp://127.0.0.1", 65000 ), FALSE );
stream_set_blocking( $socketIn = stream_socket_server( "udp://127.0.0.1:64999", $errno, $errstr, STREAM_SERVER_BIND ), FALSE );
fwrite( $socketOut, "ISI\0" . pack( "Scc", 64999, 1+8+16+32, 1 ) . str_pad( "asdf", 16, "\0" ) );
$time = microtime( TRUE );
while( microtime( TRUE ) - $time < 30 )
{
if( $packet = fread( $socketIn, 1024 ) )
{
$time = microtime( TRUE );
switch( substr( $packet, 0, 3 ) )
{
case 'LAP':
$LAP['LAP'] = substr( $packet, 0, 3 );
$LAP['UName'] = substr( $packet, 4, 28);
$LAP['PName'] = substr( $packet,29, 33);
$LAP['CName'] = substr( $packet,34, 66);
$LAP['Time'] = substr( $packet,67, 61);
$LAP['PlyNum'] = substr( $packet,62, 63);
$LAP['UniqueId']= substr( $packet,64, 65);
$LAP['VerifyId']= substr( $packet,66, 68);
break;
default:
echo "Packet " . substr( $packet, 0, 3 ) . " Is Unhandled\n";
}
}
usleep(100 * 1000);
}
?>
filur
16th April 2006, 20:59
So this it my (failed) attemp to read a LAP packet from the server using PHP
That's pretty similar to my thingie, tho mine isn't hardcoded like that. :razz:
Anyway, you're not using substr correctly, the parameters are string, start offset, length. You're thinking string, start offset, end offset, which isn't right.
$LAP['UName'] = substr( $packet, 4, 28);
Will actually read 28 bytes from offset 4, not the range 4 - 28.
Dygear
16th April 2006, 21:03
Ahh, that explains it, should of read the manule one more time :). Thanks mate :).
[edit]
:HUGE GRIN ON HIS FACE:
$LAP['LAP'] = substr( $packet, 0, 3 );
$LAP['UName'] = substr( $packet, 4, 24);
$LAP['PName'] = substr( $packet,28, 24);
$LAP['CName'] = substr( $packet,52, 32);
$LAP['Time'] = substr( $packet,84, 4);
$LAP['PlyNum'] = substr( $packet,88, 1);
$LAP['UniqueId']= substr( $packet,89, 1);
$LAP['VerifyId']= substr( $packet,90, 1);
print_r( $LAP );
Dygear
16th April 2006, 21:44
How would I go about reading the data tho? The unpack function is not very helpful, but once more, I must be using it wrong ...
Array
(
[LAP] => Array
(
[1] => L
)
[UName] => Array
(
[1] => D
)
[PName] => Array
(
[1] => ^
)
[CName] => Array
(
[1] => F
)
[Time] => Array
(
[III] => 1125888
)
[PlyNum] =>
[UniqueId] =>
[VerifyId] =>
)
case 'LAP':
// Get Data
$LAP['LAP'] = substr( $packet, 0, 4 );
$LAP['UName'] = substr( $packet, 4,24 );
$LAP['PName'] = substr( $packet,28,24 );
$LAP['CName'] = substr( $packet,52,32 );
$LAP['Time'] = substr( $packet,84, 4 );
$LAP['PlyNum'] = substr( $packet,88, 1 );
$LAP['UniqueId']= substr( $packet,89, 1 );
$LAP['VerifyId']= substr( $packet,90, 1 );
// Make Readable
$LAP['LAP'] = unpack( "a", $LAP['LAP'] );
$LAP['UName'] = unpack( "a", $LAP['UName'] );
$LAP['PName'] = unpack( "a", $LAP['PName'] );
$LAP['CName'] = unpack( "a", $LAP['CName'] );
$LAP['Time'] = unpack( "IIII", $LAP['Time'] );
$LAP['PlyNum'] = unpack( "I", $LAP['PlyNum'] );
$LAP['UniqueId']= unpack( "I", $LAP['UniqueId'] );
$LAP['VerifyId']= unpack( "I", $LAP['VerifyId'] );
print_r( $LAP );
filur
16th April 2006, 22:00
I figured out the unpack types by trial and error, what i use is:
char: just grab raw (plain substr).
byte: signed char "c".
word: unsigned short "S", note that input must be 2 bytes.
short: signed short "s".
int: signed integer "i".
MSHT: 3x signed char "c", skipping thousands since they're never present.
The other types listed in InSim.txt that i haven't included are AFAIK only present in packets not needed in server handling, float, for example, is only used to present replay speed and FOV.
Dygear
17th April 2006, 19:28
Right, thanks mate :).
the_angry_angel
20th April 2006, 13:11
Something I've always hated, but today more than usual; reading other people's code. Unless both myself and the other programmers / coders are in a "metal-sync", I just tend to think "wtf, I wouldnt do it like that" and not get past it. Either that or I need a few days to get into the api and mindset of the coders.
VorTeX3k
20th April 2006, 15:13
Something I've always hated, but today more than usual; reading other people's code. Unless both myself and the other programmers / coders are in a "metal-sync", I just tend to think "wtf, I wouldnt do it like that" and not get past it. Either that or I need a few days to get into the api and mindset of the coders.
know this problem, too ;) but since working in a large software company, where you get some bugs assigned of which you didn't even knew the program itself you learn this very fast ;)
the_angry_angel
20th April 2006, 15:31
I've just come across some legacy code from within our firm. Its driving me nuts, which has driven me to rant about it :(
Victor
20th April 2006, 15:55
installed eAccelerator on this forum server yesterday. I'm so happy about it I wanted to praise it :)
filur
20th April 2006, 16:21
Something I've always hated, but today more than usual; reading other people's code. Unless both myself and the other programmers / coders are in a "metal-sync", I just tend to think "wtf, I wouldnt do it like that" and not get past it. Either that or I need a few days to get into the api and mindset of the coders.
Different indenting is enough to make me loathe a piece of code. :zombie: :)
the_angry_angel
20th April 2006, 16:28
installed eAccelerator on this forum server yesterday. I'm so happy about it I wanted to praise it :)
Cool :) I'll be watching with baited breathe, to see how the forum survives this time ;)
Edit: Now all you need to do is upgrade to apache 2.x and do some mod_mem_cache fu (if you can spare the memory that is) ;)
Different indenting is enough to make me loathe a piece of code.Tell me about it. I usually end up re-indenting ;)
On a different note, has anyone else tried php with ZTS enabled, stripped out any "unsafe" php modules, with the apache worker or event mpm's recently?
Dygear
20th April 2006, 17:32
Well, I am glad this thread is getting use from other's then my self!
No rants today, happy to be using PHP makes life easyer. :). <Said the noob programmer>
der_jackal
20th April 2006, 19:00
Okay, my turn for a rant, I've always, ALWAYS hated the "traidional" blocking.
if (Value){
FooBar();
}
May not seem like a big deal, but it's annoying when you're blocking huge nested statements..I think it just "looks" horrible.
switch (Irp->MajorFunction){
case IRP_MJ_DEVICE_CONTROL:
case IRP_MJ_INTERNAL_DEVICE_CONTROL:
switch (IrpStack->Parameters.DeviceIoControl.IoControlCode){
case IOCTL_SOME_DEVICE:
switch (Request->ReqeustNumber){
case REQUEST_ALLOCATE_ADDRESS_RANGE:
/*
Bunch of stuff goes here
*/
}
}
}
Just a nit pick... :D
filur
20th April 2006, 19:09
if (Value){
FooBar();
}
No indent at all? I'd refuse to read it. :)
The worst kind of indent is ..
if (Value)
{
if (otherValue)
{
hello();
}
}
And my wonderful indent looks like ..
if (Value) {
hello();
}
.. that. :)
der_jackal
20th April 2006, 19:50
I much prefer
void Foo(
IN ULONG Param1,
OPTIONAL ULONG Param2)
{
if (SOME_VALUE == Param1)
{
Bar(Param1);
}
}
IMO, just makes it SO much easier to visualize the blocks that way.
sdether
20th April 2006, 22:38
Different indenting is enough to make me loathe a piece of code. :zombie: :)
The indentation wars are the worst. When i'm using emacs, I can hit some keys and have the whole thing re-indented. But i have to refrain myself from the temptation, because it really messes with revision control, as it sees every line as changed which will come back to bite you when you try to dig for when a change entered the system.
In Visual Studio, our team has just agreed to all suffer to the MS auto-formatting. Sure it's not exactly the way any of us would do it, but at least its a consistent compromise. Although I still use 2 spaces for indent when everyone else uses 4 :)
der_jackal
20th April 2006, 22:43
Although I still use 2 spaces for indent when everyone else uses 4 :)
^ YEAH!!!!
*grumbles* Can't STAND the 4 space indenters...
Dygear
21st April 2006, 00:15
^ YEAH!!!!
*grumbles* Can't STAND the 4 space indenters...
I use the stanard tab indent of 8 spaces (Runs)
<?php
function foo_bar_tar_yar( $some_random_var )
{
if( $some_random_var == 'Your Mother' )
{
echo "No, your mother!\n";
}
}
foo_bar_tar_yar( 'Your Mother' );
?>
For me, the function name is allways proceeded by the opening parenthesis then a space, and any variables I want to pass, if more then one, then the comma is proceeded by a space and the next variable name is incerted, and so on. The squiggly brace always goes on its own line. I also tab.
the_angry_angel
22nd April 2006, 16:20
The worst kind of indent is ..
if (Value)
{
if (otherValue)
{
hello();
}
}
Bah, thats the One True Method(TM) :p Granted, I wouldn't do it with 8 spaces, but a tab. To be honest, as long as whatever editor you're using can collapse and highlight parenthesis and brackets, then its not so much of a problem :)
Dygear
23rd April 2006, 10:07
I'm actually using AutoHotkey (www.autohotkey.com (http://www.autohotkey.com)) to do that (selectively send key presses to LFS when using the joystick buttons). Unfortunately I'm not sure which method AHK uses to send the key presses. It's free, so if you don't have a problem with running an extra executable (you can convert the scripts into standalone exes), you could let AHK handle the button presses and selectively send them to either your Insim app or LFS.
Or you could check out PPJoy (http://www.geocities.com/deonvdw/Docs/PPJoyIntro.htm). It's a virtual joystick driver than can take inputs from other apps.
I was wondering if any of you knew how I could get LFS Style mouse steer into games such as rFactor, or any game the accepct a steering wheel as input.
What I want to do is use the mouse to control the cars, and as most games don't have the LFS style mouse steer, it's been a pain in the arse to race other games ( and yes, I do have a wheel, but it's much to slow to be an effective control device. )
MonkOnHotTinRoof
23rd April 2006, 11:58
I was wondering if any of you knew how I could get LFS Style mouse steer into games such as rFactor, or any game the accepct a steering wheel as input.
I'd like that too. I already tried some time ago using PPJoy app (you can map mouse to virtual joystick :D ), but rFactor freezed somewhere on the way from menus to racing :shrug:. I gave up anyway, cause I found some old joystick...
Dygear
27th April 2006, 02:17
Hey, guys, I need a C++ or Java programmer that is willing to make a replica of the Formula 1 Java Live Timming Thingy. It would be for SimFIA . . . So any one up for the job?
Shep
27th April 2006, 17:32
I hate having the leading bracket on the same line as the command, like filur's last if.
It makes no sense to me- it is harder to line up the closing brackets when dealing with bigger blocks of code.
Then again I come from a Pascal background, where the words "begin" and "end" were the brackets. :)
TagForce
27th April 2006, 18:04
I hate having the leading bracket on the same line as the command, like filur's last if.
It makes no sense to me- it is harder to line up the closing brackets when dealing with bigger blocks of code.
Then again I come from a Pascal background, where the words "begin" and "end" were the brackets. :)
Yup... The only sure way to learn proper indentation is using pascal :)
You one of those that when you started using another language the first thing you did was try to set the colors of the IDE to something EXACTLY like the old DOS Pascal IDE? I know I am :P
Frankmd
27th April 2006, 18:09
Hey, guys, I need a C++ or Java programmer that is willing to make a replica of the Formula 1 Java Live Timming Thingy. It would be for SimFIA . . . So any one up for the job?
I've been planning to make something like that for the masters of endurance. A kind of software version of the tracker website. Cant promise it will be anytime soon though, Im currently drowned with work for university, and that isnt going to change untill July, and then it is summer and I dont want to be inside programming :)
Kegetys
27th April 2006, 18:13
I like to keep things tidy:
void nkfsDec(void *data, int size) {
BYTE *k = key;
for(int i=0;i<size;i++) {
((BYTE*) data)[i] -= *k++;
if(*k == 0x00) // End of key, loop
k=key;
}
}
I find this style of indenting to be very readable, and keep the code from being too 'loose' which I find makes it harder to read. I guess thats because the first C code I ever read was indented like this (I think)...
Shep
27th April 2006, 18:20
Haha, I used Turbo Pascal for everything, so I never did anything in DOS. This was in 2000,
Turbo Pascal for Windows only bolded the reserved words, and made anything in single/double quotes blue.
I use JCreator for my Java work, and I too tried to make it look like TPW :D I took about a year of from Java, and when I came back I got used to their colorscheme.
When I was programming in C for a course last semester the linux box I was connecting to with PuTTY would color everything- reading red, blue and green text on a black background is hard! I had no idea how to change it. :shrug:
ikkah
28th April 2006, 09:10
I find this style of indenting to be very readable, and keep the code from being too 'loose' which I find makes it harder to read. I guess thats because the first C code I ever read was indented like this (I think)...
My style is the exact opposite of that.
void nkfsDec( void *data, int size ) {
BYTE *k = key;
for ( int i = 0; i < size; ++i ) {
((BYTE*)data)[i] -= *k++;
if ( *k == 0x00 ) {
k = key;
}
}
}
Yes, my tabs are 8 spaces wide. In my opinion making the code look loose makes it easier to read. I overuse horizontal space but I don't like to waste vertical space as much, maybe because I want to see as much code as possible without having to scroll.
So what do your IDEs look like in action? Here's my VC++: http://www.lfs-suomi.com/ikkah/vs.png
Notice the ultrawide code view and the light green background for comments.
DarkTimes
1st May 2006, 23:18
Has anyone else here ever tried to build a website engine? It's something I've been messing about with of late. I guess it's just an extension of having a set of useful classes to automate those sorts of things you do in every site, but I'm trying to put it together with a very good extensible design.
What I'm thinking is having a very strong core engine, with all the functionality slotting in as sort of plugins. Just basically a system which allows me to work very fast and never have to write the same code twice... yeah, fat chance.
But anyway, I've got a database abstraction layer (various types of database would 'technically' be supported as plugins, but it reality it only works with MySQL), a template engine (which works really well actually, but doesn't stop me hating template engines), plus lots of different classes to automate logins and sessions and cookies and all that stuff.
Only problem is that every time I work on a new project, I start to use my engine, but find I end up having to rewrite classes at various point. Kinda defeats the purpose... but anyway...
There's really not enough information around about the theory on designing complex web applications, I guess your supposed to know all this stuff anyway, but web sites are kind of different from other programs. I find myself going more and more to traditional program design, just chucking all my HTML stuff in templates (I hate templates, they rarely achieve a decent format/code seperation) and having nothing but pure PHP in my pages....
Ah, just a bit of a off-topic web-programming rant...
Anarchi-H
2nd May 2006, 03:50
Hehe, been there, done that DarkTimes. It is nigh on impossible to make code that is everything to every project for everyone... It just isn't going to happen.
The best you can do is keep it modular so that as little code has to be re-written as possible to facilitate the specific extra features any site needs. If it looks like it might be useful to another site, bung it in the repository with everything else.
That way the only bit you have to re-write (most of the time) is the 'glue' that sticks all of your random code lumps together in to some intelligible (or not sometimes) API.
As for my editor... I usually have no less than 8 or 9 gVim windows open, a couple or three Firefoxes and photoshop, and when I'm debugging CSS about 8 other versions of various browsers. Oh, and not forgetting at least one winamp :p
the_angry_angel
2nd May 2006, 07:42
I've recently been involved in designing and implementing a forum, which could be extended via plugins, to do almost anything. At the end of the day you're always going to get some hacked code that does Just Something(TM) (AKA screenshot code). However, we eventually decided on a kind of event driven system. Basically we looked at a micro kernel as a rough setup, and we ended up with a singleton "kernel" object which would allow external apps to hook into it, and pass event's. Unfortunately in most web-based languages this isn't a good choice - its a hell of a lot slower, but it does give you a lot of flexibility and produces some nice code.
Regarding templates, I totally agree. They're a total klunk most of the time, and I generally have a dislike for them, but they do allow non-techies to get stuck in a lot of the time. I've recently found clearsilver to have some very nice syntax, that most designers or Your Boss(TM), can cope with. Of course, it does tend to require that you're running the php add on, writing your webapp in C, or you've beaten me to writing mod_clearsilver for apache ;)
Dygear
2nd May 2006, 15:22
Would it not be a better idea to have the kernal tell all of it's plugins what it is doing. EX (Kernal says "I want to display a post", post plugin says "Ok I'll make the HTML for you.")
NotAnIllusion
15th May 2006, 23:12
Sry to barge in on this Advanced Stuff.. there's something I have been wondering: Is there any way to get MySQL 5.0x GA & PHP 5.x talking to each other without copying 'libmysql.dll' to an existing PATH directory? :scratchch
I have PHP installed in 'c:\php' and that path is also in the system PATH environment variable thingy, but PHP would have none of it until I finally conceded and copied 'libmysql.dll' to '\windows\system32'.
Dygear
16th May 2006, 21:15
I dislike C# and Java due to the way they are setup. I'm more of a procedural man myself. But C# and Java seem to throw that to the side. I never have taken the time to understand classes, and Java and C# live on them. That could be the main problem. I just don't have the time to learn it as of right now. It just seems wrong. I should really buckle down and attempt to learn more about classes, so that I can start using C# and Java.
Dygear
3rd June 2006, 02:15
I'm installing Ubuntu while I'm typing this to you. Now your thinking "Ya so what, you have a lap top or your using a second computer, big deal". No, I'm installing Ubuntu on THIS computer, the computer I'm using to type into the input box is also going about formatting one of my hard drives. I really think this is the best thing that has happend to installing an OS. They have the LiveCD and if you like the OS you can then install it to your hard drive, while still using the LiveCD part. I've got to say, I'm really very impressed.
Yea, and saying that, as soon as I rebooted to go into the OS that I did install on to my hard drive GRUB fails with error 18. We'er going to have to format the hard drive one more time :(. Oh well. Rember kids, if you'r installing linux, be sure to make a /boot mount point that is less then 1024 cylinders. So I'm going to go do that now ...
Dygear
3rd June 2006, 03:26
Works now :).
DarkTimes
3rd June 2006, 09:04
I dislike C# and Java due to the way they are setup. I'm more of a procedural man myself. But C# and Java seem to throw that to the side. I never have taken the time to understand classes, and Java and C# live on them. That could be the main problem. I just don't have the time to learn it as of right now. It just seems wrong. I should really buckle down and attempt to learn more about classes, so that I can start using C# and Java.
I've been doing a huge amount of C# recently, it wasn't something I'd looked into too much before, but I downloaded C# Express and was pretty blown away with how quick you can develop with it. Windows Forms are just fantastic for getting your application running quickly, you can take all that time you normally spend building the GUI and concentrate on what your program actually does.
OOP programming is something I'm pretty butch with too. I think though that if you're not really using OOP fully or don't fully understand the concepts, then it doesn't really help you make better code than procedural programming does. But if you start to implement it properly and intelligently it can do wonders for your code, when you start to use inheritance, polymorphism and encapsulation correctly, it's hugely powerful. Often though badly written or only partially OOP programs can be more hassle than procedurals stuff...
Java I'm not a fan of to be honest, never got too into it. I'd recommend C# instead by a long way...
NotAnIllusion: If you're running PHP on WinXP then you can just install MySQL as a Windows service, on my Apache installation it didn't need any more configuration then just running through the MySQL install setup. I think you might need MySQL Windows Essentials installer to do that, you can find it at http://dev.mysql.com/downloads/
NotAnIllusion
3rd June 2006, 13:38
NotAnIllusion: If you're running PHP on WinXP then you can just install MySQL as a Windows service, on my Apache installation it didn't need any more configuration then just running through the MySQL install setup. I think you might need MySQL Windows Essentials installer to do that, you can find it at
I do have MySQL installed as a service but the problem was that PHP Not Apache) needed to be configured for it and wasn't co-operating. Couldn't be bothered to find a way to get it working the way I wanted so I copied the necessary file to my system32. I just hate doing that because then even after removing PHP there's a residual file I don't need. Yuck! :p Thank you though, I'm now well into developing a web GUI in PHP for the dedi server for my uni final year project :D
Dygear
15th June 2006, 08:54
Well, you're not using two languages in your example. You're using the output from two languages.
C and SmallC are two different languages.
The output from two languages ... explain.
Silkswift
15th June 2006, 13:32
C and SmallC are two different languages.
The output from two languages ... explain.In your resulting program, you're not actually using the language, but the compiled code that was generated by each language compiler (usually as DLLs, in some sort of "machine language"). These can interoperate.
the_angry_angel
15th June 2006, 14:06
I thought I'd updated this...clearly not.
In the case of using PHP and GTK there are exported functions and wrappers around these functions - which allow the two languages to communicate. These are usually called bindings. You can get GTK bindings for python and php for example, which allow you to use the GTK widget set within either of those languages to create desktop applications. It usually means writing an addon module for your chosen higher level language, such as Python, PHP, to interact with the lower level one.
Using SmallC, or VB, or C# with C is a case of exporting the functions in a standard way from a DLL or SO file, which the languages then recognise, and import. To put it rather simply.
In the case of using something like Javascript or Lua in your own applications, you embed the interpreter engine into your code. This engine will then convert the script into the equivilent "C" at runtime. Using this embedding method you can also define your own functions which can allow you to extend the native libraries of that language.
Clear as mud?
Leachman
15th June 2006, 17:41
Works now :).
Lilo doesn't have this limitation.
Wordan
21st July 2006, 12:08
I am going to dig up this thread... What I hate in programming is other programmers. They are all younger and more capable than me. I really love technical things and wish I had enough knowledge in programming to make something usefull, but I must be a really slow learner, and I am not academic. I barely finished my college course, and I didn't finish the last one. I envy you all!
At the moment I am trying to dig in to programming theory with Ruby. I find it[Ruby] very easy to remember. I looked at my old GCSE maths revision books yesterday and boy am I clueless, I gotta try and refresh my memory.
As for indentation, I've settled on tabs so anybody can set their editor to space them as they like. I set mine up for 2 spaces
the_angry_angel
21st July 2006, 12:27
As for indentation, I've settled on tabs so anybody can set their editor to space them as they like.Sing it again brother! :D
Dygear
22nd July 2006, 15:45
Let's not forget the source code file is smaller too. As 1 tab is equal sometimes to about 8 spaces.
Dygear
7th August 2006, 22:19
SimFIA, the website and league, is very much in need of some more programmers. I'm looking for not only PHP programmers, but python programmers aswell. If you can do it in C++ or C# or Java that is fine by me. I'd very much like all work to be open source. So if your happy with then them drop me a PM on here or on the SimFIA fourms.
What kind of work will we be doing? Simple really. Programming for Live For Speed. Getting fule load from clients for Team Principles in the F1. Live Timing and Scoring for main SimFIA website (I'll be the lead for this, providing we chose lurLFSD.). Completely unified stats engine (Closed Source) (Again I'll take the lead programmer role for this).
BurnOut69
7th August 2006, 22:47
Let's not forget the source code file is smaller too. As 1 tab is equal sometimes to about 8 spaces.
Compiler gets rid of any blanks or comments, so this doesnt affect the size of the output in any way.
the_angry_angel
7th August 2006, 23:07
What kind of work will we be doing? Simple really. Programming for Live For Speed. Getting fule load from clients for Team Principles in the F1. Live Timing and Scoring for main SimFIA website (I'll be the lead for this, providing we chose lurLFSD.). Completely unified stats engine (Closed Source) (Again I'll take the lead programmer role for this).Sounds interesting, and I may beable to dedicate time to it in the coming weeks, provided work pans out as being reasonably quiet. Just one question though; that basically reads as a load of total marketing gumft, what does it all mean? ;)
Dygear
8th August 2006, 01:25
Sounds interesting, and I may beable to dedicate time to it in the coming weeks, provided work pans out as being reasonably quiet. Just one question though; that basically reads as a load of total marketing gumft, what does it all mean? ;)
Yea it's kinda ment to sound that way. SimFIA is ment to be professional and much of my posts about SimFIA are to promote it.
Compiler gets rid of any blanks or comments, so this doesnt affect the size of the output in any way.
I was referring to the source code file only. Disk space becomes an issue alot for me, and every little helps.
BurnOut69
8th August 2006, 09:56
We are talking about bytes anyway...and I really doubt anyone adds so many comments that they increase the size of the source dramatically hehe.
BTW I work as C# programmer so depending on the task and available time I may be able to give a hand. You know where to find me (#69 :smileypul)
Dygear
8th August 2006, 13:32
We are talking about bytes anyway...and I really doubt anyone adds so many comments that they increase the size of the source dramatically hehe.
BTW I work as C# programmer so depending on the task and available time I may be able to give a hand. You know where to find me (#69 :smileypul)
*Chuckles* Allright thanks for the notice.
Dygear
25th August 2006, 04:18
Try netstat -a -b -v on your computer. I wonder why ns.chaintech.cz:23604 is connected to my computer. I hate chinatech they make reallybad stuff.
C:\Documents and Settings\Dygear>netstat -a -b -v
Active Connections
Proto Local Address Foreign Address State PID
TCP dygear-x86:epmap dygear-x86:0 LISTENING 1012
c:\windows\system32\WS2_32.dll
C:\WINDOWS\system32\RPCRT4.dll
c:\windows\system32\rpcss.dll
C:\WINDOWS\system32\svchost.exe
-- unknown component(s) --
[svchost.exe]
TCP dygear-x86:microsoft-ds dygear-x86:0 LISTENING 4
-- unknown component(s) --
[System]
TCP dygear-x86:1025 dygear-x86:0 LISTENING 344
C:\WINDOWS\System32\WS2_32.dll
C:\WINDOWS\System32\alg.exe
C:\WINDOWS\system32\RPCRT4.dll
C:\WINDOWS\system32\ole32.dll
[alg.exe]
TCP dygear-x86:netbios-ssn dygear-x86:0 LISTENING 4
-- unknown component(s) --
[System]
TCP dygear-x86:1517 102.157.36.72.reverse.layeredtech.com:3784 ESTA
BLISHED 3104
C:\WINDOWS\System32\mswsock.dll
C:\WINDOWS\system32\WS2_32.dll
C:\Program Files\Ventrilo\Ventrilo.exe
-- unknown component(s) --
[Ventrilo.exe]
TCP dygear-x86:4380 ns.chaintech.cz:23604 FIN_WAIT_1 1704
-- unknown component(s) --
[System]
TCP dygear-x86:2134 localhost:2133 TIME_WAIT 0
TCP dygear-x86:2142 64.233.161.147:http TIME_WAIT 0
TCP dygear-x86:2154 64.106.174.50:http TIME_WAIT 0
TCP dygear-x86:2155 64.106.174.50:http TIME_WAIT 0
UDP dygear-x86:2948 *:* 1204
C:\WINDOWS\system32\mswsock.dll
c:\windows\system32\WS2_32.dll
c:\windows\system32\DNSAPI.dll
c:\windows\system32\dnsrslvr.dll
C:\WINDOWS\system32\RPCRT4.dll
[svchost.exe]
UDP dygear-x86:isakmp *:* 780
C:\WINDOWS\system32\WS2_32.dll
C:\WINDOWS\system32\oakley.DLL
C:\WINDOWS\system32\LSASRV.dll
C:\WINDOWS\system32\ADVAPI32.dll
C:\WINDOWS\system32\kernel32.dll
[lsass.exe]
UDP dygear-x86:3629 *:* 1204
C:\WINDOWS\system32\mswsock.dll
c:\windows\system32\WS2_32.dll
c:\windows\system32\DNSAPI.dll
c:\windows\system32\dnsrslvr.dll
C:\WINDOWS\system32\RPCRT4.dll
[svchost.exe]
UDP dygear-x86:1032 *:* 1204
C:\WINDOWS\system32\mswsock.dll
c:\windows\system32\WS2_32.dll
c:\windows\system32\DNSAPI.dll
c:\windows\system32\dnsrslvr.dll
C:\WINDOWS\system32\RPCRT4.dll
[svchost.exe]
UDP dygear-x86:1040 *:* 1204
C:\WINDOWS\system32\mswsock.dll
c:\windows\system32\WS2_32.dll
c:\windows\system32\DNSAPI.dll
c:\windows\system32\dnsrslvr.dll
C:\WINDOWS\system32\RPCRT4.dll
[svchost.exe]
UDP dygear-x86:3628 *:* 1204
C:\WINDOWS\system32\mswsock.dll
c:\windows\system32\WS2_32.dll
c:\windows\system32\DNSAPI.dll
c:\windows\system32\dnsrslvr.dll
C:\WINDOWS\system32\RPCRT4.dll
[svchost.exe]
UDP dygear-x86:3630 *:* 1204
C:\WINDOWS\system32\mswsock.dll
c:\windows\system32\WS2_32.dll
c:\windows\system32\DNSAPI.dll
c:\windows\system32\dnsrslvr.dll
C:\WINDOWS\system32\RPCRT4.dll
[svchost.exe]
UDP dygear-x86:4500 *:* 780
C:\WINDOWS\system32\WS2_32.dll
C:\WINDOWS\system32\oakley.DLL
C:\WINDOWS\system32\LSASRV.dll
C:\WINDOWS\system32\ADVAPI32.dll
C:\WINDOWS\system32\kernel32.dll
[lsass.exe]
UDP dygear-x86:microsoft-ds *:* 4
-- unknown component(s) --
[System]
UDP dygear-x86:3631 *:* 1204
C:\WINDOWS\system32\mswsock.dll
c:\windows\system32\WS2_32.dll
c:\windows\system32\DNSAPI.dll
c:\windows\system32\dnsrslvr.dll
C:\WINDOWS\system32\RPCRT4.dll
[svchost.exe]
UDP dygear-x86:3627 *:* 1204
C:\WINDOWS\system32\mswsock.dll
c:\windows\system32\WS2_32.dll
c:\windows\system32\DNSAPI.dll
c:\windows\system32\dnsrslvr.dll
C:\WINDOWS\system32\RPCRT4.dll
[svchost.exe]
UDP dygear-x86:ntp *:* 1108
c:\windows\system32\WS2_32.dll
c:\windows\system32\w32time.dll
ntdll.dll
C:\WINDOWS\system32\kernel32.dll
[svchost.exe]
UDP dygear-x86:1900 *:* 1240
c:\windows\system32\WS2_32.dll
c:\windows\system32\ssdpsrv.dll
C:\WINDOWS\system32\ADVAPI32.dll
C:\WINDOWS\system32\kernel32.dll
[svchost.exe]
UDP dygear-x86:1872 *:* 1624
C:\WINDOWS\system32\WS2_32.dll
C:\WINDOWS\system32\wininet.dll
C:\WINDOWS\system32\kernel32.dll
[wmplayer.exe]
UDP dygear-x86:1900 *:* 1240
c:\windows\system32\WS2_32.dll
c:\windows\system32\ssdpsrv.dll
C:\WINDOWS\system32\ADVAPI32.dll
C:\WINDOWS\system32\kernel32.dll
[svchost.exe]
UDP dygear-x86:ntp *:* 1108
c:\windows\system32\WS2_32.dll
c:\windows\system32\w32time.dll
ntdll.dll
C:\WINDOWS\system32\kernel32.dll
[svchost.exe]
UDP dygear-x86:netbios-ns *:* 4
-- unknown component(s) --
[System]
UDP dygear-x86:netbios-dgm *:* 4
-- unknown component(s) --
[System]
Victor
3rd October 2006, 17:37
the following has nothing to do with lfs, but i just have to express the joy over my latest find :
OpenWRT - a very nice firmware for a lot of routers, originally Linksys ones ( supported devices (http://wiki.openwrt.org/TableOfHardware) ). Basically after you flash your router with it, you have turned your router into a fully loaded linux-networking box, meaning you get access to all iptables functionality and in combination with ip and tc you can setup QoS schemes (very cool) and as long as memory permits (mine has around 16mb for OS + running things + some filespace), you can install all sorts of other stuff on it. I've even got a working php 5.0.3 running on my router :D Remember my router isn't a whole pc - i'm talking about such a consumer hardware router :) (Linksys wrt54g v.1.1)
Anyway, since there's a lot of geeks similar to me reading this forum, I figured there'll be some guys with a compatible router who might like this. If you are a bit familiar with linux and have no fear of flashing your hardware, then i strongly recommend openwrt (http://openwrt.org). It turns your normal consumer router into a pro router :) Do remember to read all the docs about installing though and do check to see if your router is supported. If not, you can potentially brick the router and throw it away.
Back to fiddling about now
the_angry_angel
3rd October 2006, 18:12
It might be worth pointing out that getting a compatible WRT54G (excluding L revisions) can be a pain in the neck. I luckily managed to get mine (v2) from ebay.
I'm currently running DD-WRT, which is pretty similar to OpenWRT in terms of features, with the addition of a better web gui (imho) :D You can also ssh / telnet to most standard DD-WRT images if you'd like to change things the manual way, just as you would with OpenWRT :D The only up side with OpenWRT is that it runs on a much larger range of hardware, and its easier to get involved with :) If you'd just like your router to work, or you need it to work (in terms of employment) then I'd not recommend playing with this stuff.
Victor
3rd October 2006, 18:28
yeah open wrt is more for those who don't need a webgui and can get by from the command line - i don't even have the httpd running anymore to save some memory :)
Initially I installed hyperWRT-thibor, which was already a great improvement to the original firmwares (which even have a nasty bug in them, keeping connections open way too long, flooding the routers buffers). But then my eye fell on openwrt and i'm loving that now for its versatility and community support (great source of available packages).
btw, if only this router http://www.asus.com/products4.aspx?l1=12&l2=43&l3=0&model=979&modelmenu=1 had a normal PC-cpu and a little more memory - then you could throw out your Linux PC and run everything from the hardware router :D (presumably consuming less power and more silent too)
Dygear
4th October 2006, 03:06
Allright, I knew about WRT54G (I infact own one and, yes, they do rock), I also knew about the firmware thing from The Screen Savers. (http://www.youtube.com/watch?v=-MoHHKkpSz0) (We will miss you TSS.) But PHP thing is new to me, and that is REALLY awsome!
The Screen Savers Dark Tip for Linux IDS can be found at time index 22:30 and goes on from there.
Victor
4th October 2006, 03:49
too bad they made the common mistake of claiming that raising the wlan signal strength gives a better connection - it just raises the signal bar on the receiving end, but unless the receiving end also raises its signal strength, the signal won't get much better :shy: Wlan isn't a broadcast ;)
Dygear
4th October 2006, 03:54
So, where do I find the php to run on it? Oh man, my internet is a hell of alot snapper now.
Victor
4th October 2006, 04:02
Assuming you went for openwrt, you can get the php package via here : http://www.ipkg.be/package/1213305 (there are also other php versions available - just search for php on that website).
note - of course that's not a fully blown php - you won't find gd in there for example :) But it has sockets which is most important on a router I guess. Though mysql support might've been handy for some occasions.
Dygear
4th October 2006, 04:02
Yes I did, thank you :).
glyphon
15th November 2006, 18:30
i think next year sometime i'm going to start working on a project in java...only i don't know java. i'm pretty good with javascript, php, and coldfusion. In fact, the project is integrating an app that built with javascript into a pre-existing java app. so, my first task in this project is to find a reference book. only thing is, there are hundreds, if not thousands of books out there, and most of them probably suck (most tech books do).
so my question is...what java book would you recommend?
In the past, i liked the O'Rielly PHP book, but there are about 50 Java books by O'Rielly, so I can't even just go with the Java book by them. So, recommendations please :)
DarkTimes
11th July 2007, 20:57
Bump.
I've finally started forcing myself to learn C/C++ and I'm making some decent progress. However one thing I've suffered from is a lack of a good IDE for my tasks. At first I was using BloodDev-C++, which I just hated. What a horrible environment to program in. But I finally stumbled onto a wonderful open-source IDE called Code::Blocks. I fully recommend it, it's fantastic! I'm just giving it a well deserved plug. :)
http://www.codeblocks.org/
OK - more console apps! :)
Edit: Oh - get a nightly-build, the last release came out years ago and was a bit crap. They don't support it anymore, the nightly builds are where it's at!
BrandonAGr
11th July 2007, 21:31
However one thing I've suffered from is a lack of a good IDE for my tasks.
http://msdn.microsoft.com/vstudio/express/downloads/ ?
DarkTimes
11th July 2007, 21:41
Yeah, I tried that. I didn't take to it tbh. Code::Blocks is better in my view. :)
I love VSE C#. but the C++ version isn't doing it for me...
Dygear
13th July 2007, 17:33
Code::Blocks huh? I'll give it a go!
the_angry_angel
13th July 2007, 22:05
Code::Blocks huh? I'll give it a go!I heartily recommend using the nightly builds over the "stable" version. Its got a lot more fixes and tweaks.. shame they've not released a new stable yet :(
wheel4hummer
19th July 2007, 04:04
I've currently been trying to learn assembly and machine code. I want to get a cheap microcontroller just to play around with. What is assembly useful for, anyway? I want to figure out how to write my own DOS drivers.
MonkOnHotTinRoof
19th July 2007, 05:30
I've currently been trying to learn assembly and machine code. I want to get a cheap microcontroller just to play around with. What is assembly useful for, anyway? I want to figure out how to write my own DOS drivers.
Assembly language is low-level CPU specific language. It's commands are directly compiled into machine code.
Hardly anyone uses assembly language today. Even lower layers of OS and drivers are usually written in C.
Advantages of ASM are: full control over CPU, fastest possible execution speed if experienced in ASM programming (and lots of time for optimization), small output files.
Disadvantages: not portable, hard to maintain code, nonproductive.
Assembly is great to learn architecture of CPU and for fun. It was my second language, right after Spectrum Basic :razz:. Tho it might be overkill for you. Usually microcontrollers can be programmed with stripped-down variants of C.
jjones
19th July 2007, 16:48
Hi im not a programmer, Im interested in all this insim stuff, i dont understand what its for, :shrug: Could some 1 explain what insim is and the benefits of using it, Sorry if i sound stupid, just interested .
thanks john :tilt:
the_angry_angel
19th July 2007, 17:00
Insim, OutSim and Outguage are methods of communicating with LFS to import and extract specific information.
Insim lets you get a very wide variety of information about what the client or server is doin, depending on where its connecting to (an InSim client which connects to a server gets a lot more information).
OutSim is designed to things like motion simulators and gives acceleration, heading, etc. vectors for your vehicle (client side only).
Outgauge gives you the gauges of your vehicle (client side only).
The advantage of using these "protocols" is that you can extract information that would otherwise be rather tricky to get ahold of.
the_angry_angel
19th July 2007, 17:02
Hardly anyone uses assembly language today. Even lower layers of OS and drivers are usually written in C.It's used for debugging more than you might imagine. A good C programmer will know at least some ASM for this reason.
Assembly is great to learn architecture of CPU and for fun. It was my second language, right after Spectrum Basic :razz:. Tho it might be overkill for you. Usually microcontrollers can be programmed with stripped-down variants of C.ASM is still used on a number of home appliances, such as heating timers, etc. where there is a ridiculously small amount of memory available.
DarkTimes
19th July 2007, 17:04
Hi im not a programmer, Im interested in all this insim stuff, i dont understand what its for, :shrug: Could some 1 explain what insim is and the benefits of using it, Sorry if i sound stupid, just interested .
thanks john :tilt:
Well basically InSim allows you to write a stand-alone program which can communicate with LFS and internally it works much in the same way as normal multiplayer works.
LFS sends out network packets which contain various information about what's happening in the game, your program then picks these packets up and processes the information it needs from them. In turn your program can also send packets back to LFS, instructing it to carry out certain tasks, or requesting for information to be sent, or sent in a specific way.
The benefits of using it are quite clear really, but probably examples would be good. For instance the CCRT license system uses InSim, LFSLapper is present on practically every server and displays information about current lap times to players on the server, LFSPitboard allows you to have a little customised pitboard show every time you cross the start line, LFSStats tracks statistical information about races and then allows you to view and export that data.
The possibilities are endless...
jjones
19th July 2007, 17:06
Insim, OutSim and Outguage are methods of communicating with LFS to import and extract specific information.
Insim lets you get a very wide variety of information about what the client or server is doin, depending on where its connecting to (InSim connects to the server gets a lot more information).
OutSim is designed to things like motion simulators and gives acceleration, heading, etc. vectors for your vehicle (client side only).
Outgauge gives you the gauges of your vehicle (client side only).
The advantage of using these "protocols" is that you can extract information that would otherwise be rather tricky to get ahold of.
:) cheers i find that outsim is interesting and motion sims, the build i saw on the threads looks very impressive indeed, As for the rest its way over my head. But thanks for explaining.:thumb:
Its amazing what u find if u look about, the lfs manual covers it all,
DarkTimes
19th July 2007, 17:15
ive currently been trying to learn assembly and machine code. I want to get a cheap microcontroller just to play around with. What is assembly useful for, anyway? I want to figure out how to write my own DOS drivers.
There's not really a huge impetus to learn ASM any more, it used to be very useful for writing performance critical programs, or embedding some ASM in a performance critical part of your code. For instance a lot of games used ASM in the most performance critical part of their loops, as you can see if you download the open source Quake III source code from id, which is written in C with some ASM inserted at key locations.
Nowadays though compliers and virtual machines are so clever and optimised that often its actually possible to harm performance by adding ASM if you don't know what you're doing. Plus of course modern PCs are so blindingly fast that performance has started to take 2nd precedence to ease of use and reuseability.
As others say, if you want to write device drivers you could do it with C.
wheel4hummer
19th July 2007, 20:47
There's not really a huge impetus to learn ASM any more, it used to be very useful for writing performance critical programs, or embedding some ASM in a performance critical part of your code. For instance a lot of games used ASM in the most performance critical part of their loops, as you can see if you download the open source Quake III source code from id, which is written in C with some ASM inserted at key locations.
Just because it isn't useful doesn't mean anything. I am a recreational programmer. I program in assembly because I find it fun.
DarkTimes
19th July 2007, 21:59
Yes, but it was a response to the question of what assembly can be useful for. I didn't say ASM is useless or that no one should use it. But in my opinion the uses for ASM have declined with the advent of much more sophisticated programming environments and stupidly fast computers. Really we have reached a point where ASM has very few practical applications in general programming. Although almost all of us program in our spare time because we do find it fun. No matter what language you use, so long as you find it fun, that's all that matters. :)
shadow2kx
19th July 2007, 22:27
Yes, but it was a response to the question of what assembly can be useful for. I didn't say ASM is useless or that no one should use it. But in my opinion the uses for ASM have declined with the advent of much more sophisticated programming environments and stupidly fast computers. Really we have reached a point where ASM has very few practical applications in general programming. Although almost all of us program in our spare time because we do find it fun. No matter what language you use, so long as you find it fun, that's all that matters. :)
ASM is only used to enhance the simplicity and the volocity of particuliar part of a program. Like in "real time" programming, when you need to put deadline you'll may be requiered to speed up some part of an application and sometimes there is no other way to do but by deassembly your program and modify it by hand. I had to do like that with one of my program. Also needed to program a kernel.
>> Edit: was already said, i didn't understanded.
And learning ASM may be quiet usefull to fully understand the world of programation.
One thing that we must not forget is that every programation laguage goes from High level programation language to ASM to binary (if i'm not wrong, offcourse :p).
DarkTimes
20th July 2007, 00:25
I'm digging myself into a hole, I know, but if you have to resort to ASM to optimise your code these days, then there is probably a whole lot wrong with your code that a few lines of assembly are unlikely to fix.
the_angry_angel
22nd July 2007, 01:09
More of a sysadmin-type moan, but I need to find some way of humilitating myself and I figure its probably aimed at the right sort of people. For some reason I decided that it would be a good idea to do an apt-get update on one of my personal boxes - whilst fairly intoxicated. Needless to say I wasn't paying attention and the upgrade system broke exim (the email server I run).
I swear nothing has, or will in future, sober me up quicker than watching it break my carefully crafted system as it upgrades to the new version and I say "no" to not change the conf files to the new version. Unfortunately once its on, unless you want to roll back and then upgrade again (which is equally mad sometimes) you have to fix the files yourself - or fire up a VS and get the files converted there instead.
I spent a good portion of the day working on having a hang over tomorrow/this morning as well :(
Victor
22nd July 2007, 01:15
that'll teach you not to make backups of vital stuff :tilt:
the_angry_angel
22nd July 2007, 01:35
that'll teach you not to make backups of vital stuff :tilt:I do make backups :p But only of data and conf files on my personal machines, unfortunately :( Perhaps I shall revise this.
sdether
22nd July 2007, 03:57
I've switched to running all my servers as vmware images (will try Xen on my new server). Aside from being able to run multiple servers on one machine, I can easily back up each server and even bring it up on another machine, should the host machine die on me. It's made my life so much easier.
DarkTimes
8th October 2007, 20:07
Quite an interesting development, Microsoft have announced they are releasing the source-code to the .NET Framework libraries, so in VS2008 you can step-through into the underlying code. Sounds pretty cool to me!
http://weblogs.asp.net/scottgu/archive/2007/10/03/releasing-the-source-code-for-the-net-framework-libraries.aspx
the_angry_angel
8th October 2007, 20:11
Unfortunately it's not the entirety of the .NET framework, only some base libraries that make up part of it :( (or at least that's my interpretation)
DarkTimes
8th October 2007, 20:27
Well from what I've read it will initially be :
System
System.IO
System.Collections
System.Configuration
System.Threading
System.Net
System.Security
System.Runtime
System.Text
System.Web
System.Windows.Forms
System.Data
System.Xml
System.Windows
With more to come in the months ahead, such as WCF, Workflow, and LINQ. It's obviously not complete, but it's a fair amount to get started with.
Hollywood
8th October 2007, 20:42
That's pretty much all of version 2.0. :)
System
System.IO
System.Collections
System.Configuration
System.Threading
System.Net
System.Security
System.Runtime
System.Text
System.Web
System.Windows.Forms
System.Data
System.Xml
System.Windows
WPF/WCF/WWF(when is the WorldWildLifeFoundation going to sue?!) is 3.0 so it makes since it'll come out later. LINQ is still beta along with all the other 3.5 stuff so I would not expect it to come out til much later.
With more to come in the months ahead, such as WCF, Workflow, and LINQ. It's obviously not complete, but it's a fair amount to get started with.
Nonetheless, will be interesting to see the code as written (like you can with Java... which in some cases is horrific) instead of through IL interpreters like Reflector. Especially when dealing with ASP.NET. Basic .NET code is great, Windows Forms is pretty solid, but a lot of the design choices, etc. made for ASP.NET are just assinine.
BurnOut69
8th October 2007, 20:52
Ehm...windows forms is FAR from solid, visual inheritance is a royal pain in the ass - ever heard of the white screen of death?
http://blogs.msdn.com/rprabhu/archive/2005/08/11/450332.aspx
DarkTimes
8th October 2007, 21:04
I have to admit I've only ever seen that screen on a handful of occasions, and even then just hitting Rebuild Solution would fix it.
col
9th October 2007, 14:11
I'm digging myself into a hole, I know, but if you have to resort to ASM to optimise your code these days, then there is probably a whole lot wrong with your code that a few lines of assembly are unlikely to fix.
I think you have a _very_ narrow view of modern programming.
Sure, if you have to resort to ASM optimization for some web scripting thing or for a simple console tool, then there might be something wrong with your design, but there are so many areas in which there are never enough resources.
What if you are processing a large data set using an algorithm that is NP-complete (and there aren't any more efficient alternative algorithms), then you need all the help you can get, and a "who needs ASM, modern cpus are well fast" attitude just isn't going to get the job done !
What about embedded platforms? there are millions of consumer products out there that all run some sort of software. The more efficient the software is, the cheaper the product can be to manufacture... You gonna code it in java and send a memo to the boss demanding 10 times more ram and a much bigger processor ?
What about handheld devices... gamboy advance/DS are good examples. Not only is the cpu comparatively tiny, and the memory restrictions extreme, you have to factor battery usage into your software design ! the larger percentage of the time the cpu is idle, the longer the battery will last !
It is going to get more and more difficult to hand code in assembly as we move towards truly concurrent architectures (everything gets more difficult as that happens), but assembly will still be valuable to optimize small code sections.
Anyway, I think it's amazing to hear folks who develop 'application software' for PCs or websites generalizing their experience to all of programming :)
Hollywood
9th October 2007, 17:29
Yup, usually caused by developers doing tasks that are too long. And yes there are some issues (especially in VS2005 that weren't in VS2003 but seem to be taken care of in VS2008 betas) with inheritance and controls moving, etc.
Ehm...windows forms is FAR from solid, visual inheritance is a royal pain in the ass - ever heard of the white screen of death?
http://blogs.msdn.com/rprabhu/archive/2005/08/11/450332.aspx
TAYLOR-MANIA
24th April 2008, 09:16
Hi, I didn't really know where to put this...
I was just wondering if a 'knock-out' system has been made (or thought of) via Insim.
I mean the kind of mode you can see in some arcade games, where the last car behind gets knocked out on the start of the next lap, you know? Last man standing wins kinda-thing.
I thought it should be very much possible to do & it could be really good if done well. Just a thought...
Stigpt
24th April 2008, 16:57
very possible and easy - just use mci to see what is tha car in last whenever a LAP is sent. The spectate that car. Dunno if you can do that via insim, but i guess you can. Good n easy mod - you try to code it - its a good starting point!
JamesF1
24th April 2008, 17:03
Yup, very simple to implement. You should be able to do it relatively simply if you're willing to spend a good while learning how to program in one of the languages that already has a library (presuming you don't already know how to program). :)
DarkTimes
26th December 2008, 19:48
edit: irrelevant.
Dygear
28th December 2008, 14:34
Google has a countdown to 2009 (http://www.google.com/countdownto2009/#utm_source=em&utm_medium=hpp&utm_campaign=hpp) and with all of the newb questions on how to do a proper JavaScript Timer, I thought I would dissect this for ya all and post it up here. Pretty good job from the google guys, but then, I would expect nothing less. I guess I'll do the Calendar next :)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Google Timer</title>
<style type="text/css">
html, body {
margin: 1em 0 0 0;
padding: 0 0 0 0;
background-color: #002040;
color: #FFFFFF;
font: 1em Arial;
}
</style>
<script charset="utf-8" type="text/javascript">
var d = new Date();
var today = d.getDate();
function Calcage(secs, timeUnit, timeUnitMax) {
var s = ((Math.floor(secs / timeUnit)) % timeUnitMax).toString();
if (s.length < 2)
s = '0' + s;
return (s);
}
function CountBackLoop(targetDate, preFix) {
var dthen = new Date(targetDate);
var dnow = new Date();
var ddiff = new Date(dthen - dnow);
var secs = Math.floor(ddiff.valueOf() / 1000);
// calculate the amount of time remaining
var ddays = Calcage(secs, 86400, 100000);
var dhrs = Calcage(secs, 3600, 24);
var dmins = Calcage(secs, 60, 60);
var dsecs = Calcage(secs, 1, 60);
if (secs <= 0)
ddays = dhrs = dmins = dsecs = 0
else
setTimeout('CountBackLoop();', 990);
// write the amount of time remaining to the countdown timer
document.getElementById(preFix + '_day').innerHTML = ddays;
document.getElementById(preFix + '_hr').innerHTML = dhrs;
document.getElementById(preFix + '_min').innerHTML = dmins;
document.getElementById(preFix + '_sec').innerHTML = dsecs;
}
function pageInit() {
CountBackLoop('12/28/2008 15:00', 'TopGear');
CountBackLoop('01/01/2009 00:00', '2009');
}
</script>
</head>
<body onload="pageInit();">
<center>
<h2 id="timer">
<span id="countdown">
<span id="TopGear_day"></span> days,
<span id="TopGear_hr"></span> hours,
<span id="TopGear_min"></span> mins,
<span id="TopGear_sec"></span> secs
until Next Episode of TopGear!
</span>
<br />
<span id="countdown">
<span id="2009_day"></span> days,
<span id="2009_hr"></span> hours,
<span id="2009_min"></span> mins,
<span id="2009_sec"></span> secs
until 2009!
</span>
</h2>
</center>
</body>
</html>
the_angry_angel
28th December 2008, 23:09
on how to do a proper JavaScript TimerJust a plea to any planning on using JS in any sort of major manner (i.e. in a large project) - make it gracefully degrade. The google countdown is a good example of how to assume that it's turned on, and what happens when it's not.
Use JS to rewrite the DOM, rather than write it completely and provide complete functionality
Dygear
28th December 2008, 23:16
Just a plea to any planning on using JS in any sort of major manner (i.e. in a large project) - make it gracefully degrade. The google countdown is a good example of how to assume that it's turned on, and what happens when it's not.
Use JS to rewrite the DOM, rather than write it completely and provide complete functionality
Mind posting an Example?
wheel4hummer
28th December 2008, 23:17
Just a plea to any planning on using JS in any sort of major manner (i.e. in a large project) - make it gracefully degrade. The google countdown is a good example of how to assume that it's turned on, and what happens when it's not. I disabled JS for the hell of it, and I see what you mean. At the top of the page, it just says " days, hours, mins, secs until 2009!". And the calendar doesn't even show up! Wow, google, wow.
Mind posting an Example?
noscript tag? That would allow limited functionality. Like displaying the countdown from when the page was refreshed (which would, however, require server-side scripting obviously), but still show the whole calendar thing below it, and the search box. Limited functionality, but better then the page being all messed up. Problem, of course, is the larger amount of disk space required to render the page. Perhaps, a server-side javascript renderer would work better. There would be an application which would render all the javascript on the page and send it to the user as regular HTML. Limit of that method is processing power being used up.
Dygear
28th December 2008, 23:47
noscript tag? That would allow limited functionality. Like displaying the countdown from when the page was refreshed (which would, however, require server-side scripting obviously), but still show the whole calendar thing below it, and the search box. Limited functionality, but better then the page being all messed up. Problem, of course, is the larger amount of disk space required to render the page. Perhaps, a server-side javascript renderer would work better. There would be an application which would render all the javascript on the page and send it to the user as regular HTML. Limit of that method is processing power being used up.
I do have a php function that I made a while back that makes Calendars ...
<?php
function generate_calendar($year = NULL, $month = NULL, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){
if ($year === NULL) {
$year = date('Y');
}
if ($month === NULL) {
$month = date('m');
}
$first_of_month = gmmktime(0,0,0,$month,1,$year);
$day_names = array();
for ($n = 0,$t = (3 + $first_day) * 86400; $n < 7; $n++, $t += 86400)
$day_names[$n] = ucfirst(gmstrftime('%A',$t));
list ($month, $year, $month_name, $weekday) = explode(',', gmstrftime('%m,%Y,%B,%w', $first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7;
$title = htmlentities(ucfirst($month_name)) . ' ' . $year;
@list($p, $pl) = each($pn);
@list($n, $nl) = each($pn);
if($p) $p = '<span class="calendar-prev">' . ($pl ? '<a href="' . htmlspecialchars($pl) . '">' . $p . '</a>' : $p) . '</span> ';
if($n) $n = ' <span class="calendar-next">' . ($nl ? '<a href="' . htmlspecialchars($nl) . '">' . $n . '</a>' : $n) . '</span>';
$calendar = '<table class="calendar">' . "\n" . '<caption class="calendar-month">' . $p . ($month_href ? '<a href="' . htmlspecialchars($month_href) . '">' . $title . '</a>' : $title) . $n . "</caption>\n<tr>";
if ($day_name_length) {
foreach($day_names as $d)
$calendar .= '<th abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "</tr>\n<tr>";
}
if ($weekday > 0)
$calendar .= '<td colspan="' . $weekday . '"> </td>';
for ($day = 1, $days_in_month = gmdate('t', $first_of_month); $day <= $days_in_month; $day++, $weekday++) {
if ($weekday == 7){
$weekday = 0;
$calendar .= "</tr>\n<tr>";
}
if (isset($days[$day]) && is_array($days[$day])) {
@list($link, $classes, $content) = $days[$day];
if (is_null($content))
$content = $day;
$calendar .= '<td' . ($classes ? ' class="'.htmlspecialchars($classes) . '">' : '>'). ($link ? '<a href="' . htmlspecialchars($link) . '">' . $content . '</a>' : $content) . '</td>';
} else {
$calendar .= "<td>$day</td>";
}
}
if ($weekday != 7)
$calendar .= '<td colspan="' . (7-$weekday) . '"> </td>';
return $calendar . "</tr>\n</table>\n";
}
?>
DarkTimes
29th December 2008, 00:34
edit: irrelevant.
the_angry_angel
29th December 2008, 08:10
Mind posting an Example?Unfortunately most of the real world code I've written to do this sort of stuff over the last 3 years is in a non-public application for work, and most of the personal stuff I do doesn't need the fancy JS stuff, as its only me using it.
However, a high level example would be something like this - a rating form for an item - the client by default gets a full form, with a dropdown list of "poor", "good", "excellant" and a submit button. To make it cooler, on full document load (I use jQuery, so "document ready") I find the form, remove the submit button, and hide the dropdown list. I then insert 3 images (stars), with applicable functions on hover, which changes the star to a filled in star, and on click which submits the rating for that item using a XMLHttpRequest, and sets the value of the dropdown list to match (because in the actual code this happens in, it's possible to submit the form in other ways).
Using jQuery or Prototype, etc. makes stuff like this very easy. Now some will argue that you're making life harder for yourself, and to an extent you are. However, I view it this way - I'm writing 1 full application, which will work in almost any browser from the last 10-15 years, and then I am modifying it only slightly.
If you're using MVC in some form, it makes dealing with getting data back in a compatible format very easy. For the Zend Framework you can write your own context handler, or use the AjaxContext controller plugin, there are applicable examples for almost every framework out there. If you've rolled your own it's almost as easy to do, as most popular JS frameworks send a "X_REQUESTED_WITH: XMLHttpRequest" header, so it's trivial to detect an "ajax" request.
Edit:
Simon Willison's talk from May of this year might be of interest as it covers unobtrusive/graceful degradation - http://simonwillison.net/static/2008/xtech/
wien
29th December 2008, 09:08
However, a high level example would be something like thisHere (http://www.kjokken-elverum.no/index.php?page=gallery&category_id=2)'s a working example from a site I made a while ago. It's not a rating system, but the gallery there is coded up in the same basic way you described. If JS is turned off or unavailable, each of the thumbnails in the gallery just link to a new page with the selected image. If it's on, the image gets loaded and inserted dynamically into the currently loaded page.
JamesF1
31st December 2008, 08:50
Just a plea to any planning on using JS in any sort of major manner (i.e. in a large project) - make it gracefully degrade.
Entirely agree.
Use JS to rewrite the DOM, rather than write it completely and provide complete functionality
Exactly :thumbsup:
Dygear
3rd February 2009, 11:59
I have a question about MySQL querys.
My problem, I have a table that has users who have been added out of order of their joindate (JDate) so when I sort the table by `JDate` it provides a result that is inconsistent with a incrementing numerical value of the PRIMAY KEY `id`. I would like to craft a query that would allow me to select the values from one table and insert them into another table. The table `members` and `members_sorted` have the same structure as shown in the query.
Here is the query so far:
--
-- Table structure for table `members_sorted`
--
CREATE TABLE IF NOT EXISTS `members_sorted` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`FName` varchar(32) NOT NULL,
`LName` varchar(32) NOT NULL,
`Status` set('Advisor','Active','Inactive','Medical','Leave ') NOT NULL,
`JDate` date NOT NULL,
`BDate` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
--
-- Dumping data for table `members` SORTING VALUES INTO `members_sorted`;
--
INSERT INTO `members_sorted` SELECT `FName`, `LName`, `Status`, `JDate`, `BDate` FROM `members` ORDER BY `JDate`, `LName`;
However this query returns the error: #1136 - Column count doesn't match value count at row 1; I know this is due to myself omitting the `id` from the list, but I don't want that value to be transmitted over to the new table, I would like that value to be dynamically rebuilt with this query.
Dygear
3rd February 2009, 12:09
Edit:
Simon Willison's talk from May of this year might be of interest as it covers unobtrusive/graceful degradation - http://simonwillison.net/static/2008/xtech/
Missed that first time around, and it's wonderful, I think I will start programming with jQuery. The provided examples are awesome.
the_angry_angel
3rd February 2009, 12:37
However this query returns the error: #1136 - Column count doesn't match value count at row 1;A select into might be more useful in your situation Dygear - SELECT `FName`, `LName`, `Status`, `JDate`, `BDate` INTO `members_sorted` FROM `members` ORDER BY `JDate`, `LName`; Or INSERT INTO `members_sorted` (`FName`, `LName`, `Status`, `JDate`, `BDate`) VALUES(SELECT `FName`, `LName`, `Status`, `JDate`, `BDate` FROM `members` ORDER BY `JDate`, `LName`); Either should work, if I've remembered correctly. Edit: That said, a view might even be more appropriate, assuming your SQL engine supports them.
amp88
3rd February 2009, 12:37
However this query returns the error: #1136 - Column count doesn't match value count at row 1; I know this is due to myself omitting the `id` from the list, but I don't want that value to be transmitted over to the new table, I would like that value to be dynamically rebuilt with this query.
Is there any difference using the below create table statement rather the one you included above?
CREATE TABLE IF NOT EXISTS `members_sorted` (
`id` int(10) unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
`FName` varchar(32) NOT NULL,
`LName` varchar(32) NOT NULL,
`Status` set('Advisor','Active','Inactive','Medical','Leave ') NOT NULL,
`JDate` date NOT NULL,
`BDate` date NOT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
Dygear
5th February 2009, 09:23
INSERT INTO `members_sorted` SELECT `id` = NULL, `FName`, `LName`, `Status`, `JDate`, `BDate` FROM `members` ORDER BY `JDate`, `LName`;
That worked. LOL;
DarkTimes
5th February 2009, 16:49
I think that's what they call an elegant solution. :)
DarkTimes
5th February 2009, 17:04
Incidentally, how do you all pronounce SQL? I was always taught to pronounce it ess-qee-ell, but over the last few years I've made the mental gear-shift to start pronouncing it as sequel, as that's how the Amaracans say it. I prefer the original French abbreviation, I think.
wien
5th February 2009, 17:17
Incidentally, how do you all pronounce SQL?I'm a firm believer in "call it whatever the hell you like". I hate these creative pronunciations the geek community always insists on using. "guh-nome", "postgres-cue-ell", "sequel"... gimme a frikkin' break. If they want me to pronounce it that way they can spell it accordingly. (Which means I pronounce it ess-cue-ell, since... that what it says.)
JamesF1
5th February 2009, 18:17
I'm a firm believer in "call it whatever the hell you like". I hate these creative pronunciations the geek community always insists on using. "guh-nome", "postgres-cue-ell", "sequel"... gimme a frikkin' break. If they want me to pronounce it that way they can spell it accordingly. (Which means I pronounce it ess-cue-ell, since... that what it says.)
This man speaks bucket-loads of sense :thumbsup: "Ess-cue-ell" is the way forward.
Flame CZE
5th February 2009, 18:19
Incidentally, how do you all pronounce SQL? I was always taught to pronounce it ess-qee-ell, but over the last few years I've made the mental gear-shift to start pronouncing it as sequel, as that's how the Amaracans say it. I prefer the original French abbreviation, I think.
The right pronounciation is ess-cue-ell
amp88
5th February 2009, 18:23
Incidentally, how do you all pronounce SQL?
The first version of SQL was developed at IBM by Donald D. Chamberlin and Raymond F. Boyce in the early 1970s. This version, initially called SEQUEL, was designed to manipulate and retrieve data stored in IBM's original relational database product
Sequel it is then...
Sequel is faster and easier to say anyway.
JasonJ
5th February 2009, 22:53
If you read the whole article you can see that is the old name for the SQL predecessor. :x There's no "C" or "E" so I am proud to pronounce it as "es queue el" :smileypul
Dygear
6th February 2009, 16:03
Incidentally, how do you all pronounce SQL? I was always taught to pronounce it ess-qee-ell, but over the last few years I've made the mental gear-shift to start pronouncing it as sequel, as that's how the Amaracans say it. I prefer the original French abbreviation, I think.
I pronounce it ess-qee-ell, I find the term sequel to be inaccurate as it an acronym not a word. Though I call AOL Instant Messager aim and not by each letter individually ... A-I-M.
pb32000
9th February 2009, 11:27
I pronounce it ess-qee-ell
Why qee?
Surely 'Q' is pronounced cue, or queue etc.
DarkTimes
9th February 2009, 11:59
Why qee?
Why anything?
Dygear
9th February 2009, 21:40
Why qee?
Surely 'Q' is pronounced cue, or queue etc.
SQL = ess-cue-ell (normal) || ess-qee-ell (accent)
DarkTimes
11th April 2009, 15:39
Joy is spending your Saturday afternoon trying to get around the fact that wxGlade is so buggy it won't even import its own export files. :/
Dygear
12th April 2009, 07:28
Joy is spending your Saturday afternoon trying to get around the fact that wxGlade is so buggy it won't even import its own export files. :/
I had an issue like that with a version of C#, I would include a lib and that was it, I would recompile with no changes to the code other then the lib ... the compile fails based on the contents of the lib being programmed in a previous version of C# and it not working with the newer version. But, it was a standard lib that comes with Visual Studio, from that point on, I did not bother with C#.
I just want to throw this out there, I'm not cut out to be a C# programmer, I did not look to fix the problem that proped up from this simple adding of a lib, but it hit a road block for me as I was looking for a quick and dirty way to handle something and I really don't think C# is cut out for that kind of work.
Dygear
12th May 2009, 16:12
Hey, guys, I need a C++ or Java programmer that is willing to make a replica of the Formula 1 Java Live Timming Thingy. It would be for SimFIA . . . So any one up for the job?
What's really crazy is that I ended up programming this for myself using Filur's lurLFSd in PHP. Crazy how far we come as programmers in such a short amount of time.
Anyway, speaking of how far we have come, I'm in need of some help with some SQL.
I'm trying to get data from 3 different tables in a database. I want to get the address of the device(s) based on id of the device(s), as connected to the member's account, that will give me a full return address for each device connected to the account.
SELECT
members.*, devices.*, smtp.*
FROM
`members`, `devices`, `smtp`
WHERE
(members.devices = devices.id)
AND
(devices.service = smtp.id);
And, gosh, there is nothing wrong with that code, it works! ... by explaining it 'out loud' I fixed my problem! Well one problem anyway, my next problem is that members.devices can work like a csv file of sorts, how do I handle that in SQL?
dawesdust_12
12th May 2009, 16:23
As a random note... isn't SQL supposed to be pronounced like "Sequel"... so it's My-"Sequel"...
Swore I read somewhere that that is correct.
NotAnIllusion
12th May 2009, 17:50
As a random note... isn't SQL supposed to be pronounced like "Sequel"... so it's My-"Sequel"...
Swore I read somewhere that that is correct.
The first version of SQL was developed at IBM (http://en.wikipedia.org/wiki/IBM) by Andrew Richardson, Donald C. Messerly (http://en.wikipedia.org/w/index.php?title=Donald_C._Messerly&action=edit&redlink=1) and Raymond F. Boyce (http://en.wikipedia.org/wiki/Raymond_F._Boyce) in the early 1970s. This version, initially called SEQUEL,
The first version was pronunced 'sequel' for this reason. While it can still be used, the modern SQL (afaik) isn't an actual concatenation of SEQUEL and therefore pronuncing SQL as 'sequel' in my view, even if de facto (which I don't think it is) is technically incorrect.
bunder9999
13th May 2009, 01:24
they can call it "sequel" all they want, and i will always reply "what?"... everyone i know calls it S-Q-L. :shrug:
same goes for daemon... it's not "demon"... it's "day-mon". :shrug:
Dygear
14th July 2009, 21:09
SELECT *, `Total` AS (`Training` + `Meeting` + `Detail` + `Crew` + `Additional`) FROM `Hours` ORDER BY `Total` DESC;
I'm sure you all know what I'm trying to do, but the implementation is just not working for me. Anyone have any suggestions?
(It should be noted that the rows `Training`, `Meeting`, `Detail`, & `Crew` are FLOATs and the row `Additional` is a TINYINT.)
dawesdust_12
14th July 2009, 21:13
Now here's my question... What difference does setting the correct types in MySQL make?
Not that I don't do it (out of being told to use the correct types always), but what bearing does it have on anything?
GeForz
14th July 2009, 21:21
SELECT *, `Total` AS (`Training` + `Meeting` + `Detail` + `Crew` + `Additional`) FROM `Hours` ORDER BY `Total` DESC;
I'm sure you all know what I'm trying to do, but the implementation is just not working for me. Anyone have any suggestions?
(It should be noted that the rows `Training`, `Meeting`, `Detail`, & `Crew` are FLOATs and the row `Additional` is a TINYINT.)
What Database are you using?
Normally you write the table rows first and then the name you want the "result" to be named...
e.g. SELECT CONCAT(last_name,', ',first_name) AS full_name FROM mytable ORDER BY full_name;
NotAnIllusion
14th July 2009, 21:24
SELECT *, `Total` AS (`Training` + `Meeting` + `Detail` + `Crew` + `Additional`) FROM `Hours` ORDER BY `Total` DESC;I'm sure you all know what I'm trying to do, but the implementation is just not working for me. Anyone have any suggestions?
(It should be noted that the rows `Training`, `Meeting`, `Detail`, & `Crew` are FLOATs and the row `Additional` is a TINYINT.)
Shouldn't the alias come after the AS, not before?
SELECT *, (lots of stuff) AS 'Total' FROM...
edit: yeah, what the camel said.
tongey
14th July 2009, 21:31
SELECT *, `Total` AS (`Training` + `Meeting` + `Detail` + `Crew` + `Additional`) FROM `Hours` ORDER BY `Total` DESC;I'm sure you all know what I'm trying to do, but the implementation is just not working for me. Anyone have any suggestions?
(It should be noted that the rows `Training`, `Meeting`, `Detail`, & `Crew` are FLOATs and the row `Additional` is a TINYINT.)
Hey Marc, been a long time. How you doing? :)
Should the SQL code be this way around?
SELECT *, (`Training` + `Meeting` + `Detail` + `Crew` + `Additional`) AS `Total` FROM `Hours` ORDER BY `Total` DESC;
EDIT: See above :x
DarkTimes
14th July 2009, 23:38
Now here's my question... What difference does setting the correct types in MySQL make?
Not that I don't do it (out of being told to use the correct types always), but what bearing does it have on anything?
I know nothing about this, and will probably be told off for commenting on it, but my understanding is that knowing the type of the column is very important to SQL in order for it to perform such fast queries. In a very simple model, if you have a table with a single column of floats, if you query that table for the 114th row, you can just increment the internal pointer by 114 * 4, and immediately read out that record. If it knows how many bytes each column/row takes up it can do very simple primary school maths to reach a record quickly.
DarkTimes
14th July 2009, 23:49
OK - I knew I read about this, it's MY HERO Joel Spolsky.
How does a relational database implement SELECT author FROM books? In a relational database, every row in a table (e.g. the books table) is exactly the same length in bytes, and every fields is always at a fixed offset from the beginning of the row. So, for example, if each record in the books table is 100 bytes long, and the author field is at offset 23, then there are authors stored at byte 23, 123, 223, 323, etc. What is the code to move to the next record in the result of this query? Basically, it's this:
pointer += 100;
One CPU instruction. Faaaaaaaaaast.
Yes, I ain't no original neither. You should view the source (http://www.joelonsoftware.com/articles/fog0000000319.html).
Dygear
15th July 2009, 09:10
Wow, I'm sorry for that stupid question! I should of seen that myself, but I had be programming code all night and it got to the point where I could not see the problem in my own code. Sorry for that. On a side note, I learned something about how SQL reads data so fast, and the only reason why I choose to keep the database data types to the smallest they need to be is because I want the foot print on the server's hard drive to be as small as possible. It had nothing to do with read times, but now I that's another reason for me to use the correct data type.
(I'm going to look this up after I post this, but Joel is the guy who hosts the Stack Overflow Podcast with Jeff right?)
DarkTimes
15th July 2009, 21:47
Yes, that's the same Joel Spolsky. I recommend reading his essays as he is a very smart guy. Also, as I said before, he's hilarious.
Back to the off-topic topic, does anyone know of any good idiot guides to using Subversion? I've been trying to setup SVN on my Codeplex project for LFSPoints 3.0, but I find my brain dribbling out of my ears after a few minutes. Yes, I don't know how to use version control, I suck blah blah. :)
dawesdust_12
15th July 2009, 22:19
Don't use Subversion, it sucks.
I would suggest Git. It's a lot better and merges... are well... I've never had to do one manually, Git is intelligent and does them automatically unless it runs into something it can't do, where you then only haffto fix that file manually.
http://www.youtube.com/watch?v=4XpnKHJAok8
Go watch that, and from personal experience of trying to use SVN, CVS, and Git (to see which was easier/more efficient), I found git to be a clear winner in ease of use and at actually doing stuff like merges, branches and such.
http://toolmantim.com/articles/setting_up_a_new_remote_git_repository
The only downside is it is only effective on either a SSH-able box, but it is able to set it up over virtually anything. A local directory can be a repository and you clone into a working directory or even FTP/HTTP (WebDAV). It's actually probably the greatest thing I've ever seen.
DarkTimes
15th July 2009, 22:42
I am using Codeplex to host my project and I don't believe they use Git. In fact I believe they use Microsoft's proprietary source control system, but it does support Subversion. I have TortoiseSVN installed, and I skimmed the manual, but I find it complicated and I don't really get how I can just add my existing, and rather large, project folder to it. Meh, I know nothing about this.
wien
16th July 2009, 01:36
http://svnbook.red-bean.com/ ?
No sure how this ties into the Codeplex stuff though. I'm sure they've made it more complex than need be somehow.
EDIT: Easiest is probably to just initialise a repository on you local harddrive using TortoiseSVN (right click on folder -> TortoiseSVN -> Create repository here) and experiment on that. Once you get the concepts it's probably easy to figure out the Codeplex stuff.
EDIT2: Oh, and yeah; GIT is indeed much better in a multitude of ways, but it does lack some of the good GUI tools SVN has, as well as integration with things like Codeplex apparently. You'll probably get by fine with SVN though. Just don't rely too heavily on branching and stuff like that as merging code back from a branch is a right pain in the arse.
Dygear
16th July 2009, 06:50
Yes, that's the same Joel Spolsky. I recommend reading his essays as he is a very smart guy. Also, as I said before, he's hilarious.
Back to the off-topic topic, does anyone know of any good idiot guides to using Subversion? I've been trying to setup SVN on my Codeplex project for LFSPoints 3.0, but I find my brain dribbling out of my ears after a few minutes. Yes, I don't know how to use version control, I suck blah blah. :)
I read the entire post you linked to, it was great, I think I might just do some more reading up on his works. I really need to start reading coding horror again but Medic School is starting soon and I've got to focus on that!
Bob Smith
16th July 2009, 13:20
I've started using subversion at home on VHPA, since I've gotten use to it at work over the past 18 months. I too am using Tortoise SVN as my client, and I'm using VisualSVN as my server. I found it a complete breeze to set up a new repository in an empty folder, then just moved all my files in there and added them.
I've heard about git but can't say I've ever tried it. Maybe git is better at dealing with conflicts but it's not often I get then with svn and then the conflict editor usually gets me sorted in no time at all.
wien
16th July 2009, 13:41
I've heard about git but can't say I've ever tried it. Maybe git is better at dealing with conflicts but it's not often I get then with svn and then the conflict editor usually gets me sorted in no time at all.It not so much how it deals with conflicts (which it does about the same as Subversion), but rather how it avoids conflicts in the first place.
I remember having hell of a time trying to maintain two separate branches of development on my 3D framework in Subversion. Merging in changes from trunk to the branch always seemed to create a mess of conflicts all over every piece of changed code. Merging the branch back to trunk was also a real bitch which resulted in me having to manually solve a boatload of conflicts. And if I wanted to cherry-pick one change from one branch to another? More conflicts. And this was with me as the sole developer. Add a few dozen more, and it gets really hairy.
Git on the other hand makes this trivially easy by nature of how it is structured. You just branch and merge at will and it magically Just Works. It really changes the way you work if you're used to Subversion. Doing a small experiment? Branch and do your changes, merge back if it's good. Fixing a bug? Branch, fix and merge. Need one commit from another branch that fixes a problem you're seeing? Cherry-pick it into your current branch, and you're done. Easy.
The few cases where I've actually had to manually resolve a conflict in git it's always been an actual conflicting change and something that needs programmer intervention. Add to that it's distributed nature (which means you have the entire change history in your local working copy, as well as the ability to commit while working offline), and you've got yourself a winner.
If you've got an hour: Linus Torvalds on why you're stupid if you use Subversion (http://www.youtube.com/watch?v=4XpnKHJAok8). :)
dawesdust_12
16th July 2009, 14:47
It not so much how it deals with conflicts (which it does about the same as Subversion), but rather how it avoids conflicts in the first place.
I remember having hell of a time trying to maintain two separate branches of development on my 3D framework in Subversion. Merging in changes from trunk to the branch always seemed to create a mess of conflicts all over every piece of changed code. Merging the branch back to trunk was also a real bitch which resulted in me having to manually solve a boatload of conflicts. And if I wanted to cherry-pick one change from one branch to another? More conflicts. And this was with me as the sole developer. Add a few dozen more, and it gets really hairy.
Git on the other hand makes this trivially easy by nature of how it is structured. You just branch and merge at will and it magically Just Works. It really changes the way you work if you're used to Subversion. Doing a small experiment? Branch and do your changes, merge back if it's good. Fixing a bug? Branch, fix and merge. Need one commit from another branch that fixes a problem you're seeing? Cherry-pick it into your current branch, and you're done. Easy.
The few cases where I've actually had to manually resolve a conflict in git it's always been an actual conflicting change and something that needs programmer intervention. Add to that it's distributed nature (which means you have the entire change history in your local working copy, as well as the ability to commit while working offline), and you've got yourself a winner.
If you've got an hour: Linus Torvalds on why you're stupid if you use Subversion (http://www.youtube.com/watch?v=4XpnKHJAok8). :)
Yeah, in the times I've been using it... The few conflicts I've had is when I was working on a file at the same time with a friend and I decided to do a total restructure of a file... turns out he was doing the same thing so git didn't know what the heck to do with these 2 files that were dramatically different. Other than that, I'll never use anything but git.
DarkTimes
16th July 2009, 22:08
As I say I don't see any option for Git on Codeplex, maybe I'm just being dense, as per normal. Anyway, I spent some time on TortoiseSVN this afternoon and managed to get it working. I think one of those situations where I was just looking for more complexity than was there. Still not sure I'm doing it all correctly, but the source now shows up on the Web site. I'm not sure how to make changes to it, so I might need to read the manual for that, but anyway I've made some progress.
wien
16th July 2009, 23:11
I'm not sure how to make changes to it, so I might need to read the manual for that, but anyway I've made some progress.Edit your local working copy, right click on the file(s)/folder(s) you changed, select commit, write a descriptive log message, job done. :)
Dygear
18th July 2009, 10:35
I'm in shock right now. Over the past few days I've answered some questions on these forums that I would never even get close to answering a few months ago. I have no idea how it happened, but I think I've finally become a real programmer. I understand this does not make me a good programmer, but I find it interesting that I'm answering more questions that I'm asking for the first time. Has anyone else had a moment, where they stepped back, and realized they where getting good at this?
amp88
18th July 2009, 13:48
I have no idea how it happened, but I think I've finally become a real programmer. I understand this does not make me a good programmer, but I find it interesting that I'm answering more questions that I'm asking for the first time. Has anyone else had a moment, where they stepped back, and realized they where getting good at this?
I've never felt like a good or confident programmer. I think part of the problem was that I didn't start using PCs until I was about 12/13 and I didn't start programming until I went to uni to study computer science. It was a steep learning curve which put me off to an extent. I did about 3 years of Java and about 6 months of C at uni and I've had some good and bad moments from when I started up to today.
Good moments:
Writing your first "Hello World!" application (well, it's got to be there, doesn't it...).
Writing your first recursive method...that works!
Writing your first abstract data type implementation from scratch (e.g. Linked List, Stack, Queue, Priority Queue, Binary Search Tree).
Writing your first GUI (even if it does use absolute positioning...yuck!).
Writing little utility applications for yourself that make your life slightly easier.
The first time a friend asks you for help trying to do something and you not only understand the question but can actually help them.
Writing your first 'game' (minesweeper for me).
Understanding how ActionListeners work in Java (it took me a bit of time)
The first time you get paid for being a programmer.
Bad moments:
Writing your first recursive method...that doesn't seem to work no matter what you try.
The first time you get a compiler error that you just cannot understand. You spend 5 minutes convinced there's a bug in the compiler only to finally realise there's a misplaced bracket, semi-colon, a colon that should be a semi-colon (or vice versa) etc.
The first time you ask someone else (friend, colleague, boss (!)) to test an application that you have thoroughly tested and not been able to break that they can break instantly by doing something you hadn't thought about.
The first time you get a bug report in production code that you wrote.
Dygear
18th July 2009, 17:08
I've never felt like a good or confident programmer. I think part of the problem was that I didn't start using PCs until I was about 12/13 and I didn't start programming until I went to uni to study computer science. It was a steep learning curve which put me off to an extent. I did about 3 years of Java and about 6 months of C at uni and I've had some good and bad moments from when I started up to today.
I started using computers when I was, 6 (Back in 1995). Then I started programming for AMX Mod (http://amxmod.net), AMX Mod is a plugin system for the original Half Life engine primarily used in Counter Strike 1.5 / 1.6 Servers, where it's plugins are made in SmallC as it was called then, but is now known as PAWN (http://www.compuphase.com/pawn/pawn.htm). That was 2003, from there I started programming in PHP (2004), did some work in C, C#, C++ (all 2005), and recently I started branching out into JavaScript (2008). I've been programming for 7 years now, and I am only now starting to fell confident with the materiel I've covered. It would seem that Peter Norvig is right, why is everyone in such a rush, Teach Yourself Programming, In Ten Years (http://norvig.com/21-days.html) (I would like to point out that I read this article when I was around the 3 year mark, and I'm so glad I remembered it, it's a great read.).
DarkTimes
18th July 2009, 17:40
I start out by learning HTML back in about 2000-ish, when I first got the internet. One day I was just browsing and I wondered how web sites were made (I'd never had an inclination to do this kind of thing before). I got a book and started learning HTML, then CSS and Javascript. So I guess you could say Javascript was the first language I learned. After that I began to wonder how big database-driven sites were made, and started to find out about this PHP thing. I programmed PHP for a couple of years, but I got frustrated as I realised I would rather be writing desktop apps.
I first of all started to learn Java, but quickly got put off by its GUI API, which at that time was pretty bad, and also the language itself kind of annoyed me (and still does if I'm honest, although nowhere near as much as PHP :p). I gave up on Java and tried C#, and was just blown away by the .NET Framework, Visual Studio and the way Microsoft supports programmers. After spending a long time getting to grips with .NET, I decided to go lower level and learned C (never did much with C++, I liked the simplicity of C, and still do). Then I made the move into dynamic languages, such as Python and Ruby. Which kinda takes me to where I am today. My next step is to learn a functional programming language, such as F#.
I would say the biggest moments for me where:
Learning about the stack and heap, and pointers (especially how arrays were just pointers)
Learning about OOP, inheritance, abstract classes, and interfaces
Learning .NET things such as generics, delegates, events and asynchronous programming
Learning about socket programming with InSim, streams and packets and all that stuff
Learning that publishing your source code makes you a better programmer
Learning how to read source-code, so I can download the source to a program like SharpDevelop and make a decent attempt at understanding it
Learning that programming isn't actually that hard, it just takes time! :D
But the question, "Do I feel like a good programmer?" Well no, the more I've learned the more I realise I don't actually know anything. I find the world of programming incredibly large and daunting, and I feel very, very small. :)
Silox
18th July 2009, 18:23
I think it's time for my to give it a try.
At this moment, I'm only 17 years old. I started working with a computer about 10 years ago. Well, working is a big word. It was more like driving around with a handcart and collecting apples and avoiding bombs.
When I became 12-year old I discovered an old "Webdesign" (read HTML) book from my auntie. I started to make some simple websites and after a few months I could make my own, but still simple site in HTML, working with Notepad.
At a moment sites became too easy so I learned JavaScript, PHP and MySQL and started to configure my own criminal game.
Until then, I never followed any lessons on (night)school. Then the moment came, I think it was 2 years ago, I followed the basics of VB.Net and eventually I started playing LFS with my clan. I came up with the idea of creating a Ranking System so I started with almost no knowledge of Visual Basic. After some weeks the first version was online and it ran fine.
Again 1 - 2 years later the system had allot of updates and I'm trying to learn C# with recoding the system into C# language.
Good moments:
My first site
Now the system is (almost) completed in VB.Net we have a server continuously running full 24/24 7/7. It's great to see all those users having fun.
I make sites on regular basis for factories, stores, restaurants, ... It's great to earn something with your knowledge!
It's also great when you start to understand the new language and the notation of it. Programming is not Chinese. It has something logical and that's great to discover.
Bad moments:
Hours of testing, more testing and even more testing always result into new bugs and failures and errors... At some point you'll get enough of those bug-fixing and you don't see it anymore. If you encounter this moment, I suggest you take a shower and go to bed. The morning after, when you have fresh energy, it will all go allot better.
It always annoys me that when people have a problem and they post it on a forum they expect you to write their program. It's like, I can't do it, so you do it for me! But at this way they'll never learn it.
To answer on your question:
No, not really. The world of programming languages is growing as we speak. There still is so much to learn but indeed, if you get better at something it's nice to see the progress you made in a relative short time.
dawesdust_12
18th July 2009, 18:48
I basically have the biggest self confidence issue of maybe any developer ever. Every idea I ever have to get something to work, I second and triple guess myself. I ask several people I trust to be smart with this stuff about what I'm gonna do, and then I'm extremely self conscious that the code I'm writing isn't complete crap.
Then when it works, I am convinced it doesn't actually work, so I test it like mad. Then I think I'm done so I move on but then realize that I've forgotten something when I need to use it.
GeForz
18th July 2009, 19:36
Add to bad moments:
- When you have to work with huuuge software projects which are poorly documented... ^^
Victor
6th August 2009, 18:32
One thing's been bugging me for a while. I want to do a fgrep for all .php files in 'all' directories.
But doing "fgrep -r searchstring *.php" doesn't work because it will not go into any folders, due to the *.php restriction (unless there's a folder name ending in .php).
Doing a "fgrep -r searchstring *" will search through the sub dirs, but it will also search in every single file of all dirs, which is undesirable.
So how to search through subdirs but only .php files?
dawesdust_12
6th August 2009, 18:36
Just a shot in the dark.. couldn't you just pipe that into another grep (or fgrep) that searches for the .php?
(Not too sure if that will work, but worth a shot?)
Victor
6th August 2009, 18:39
i'd still have to be able to somehow look in all subdirs and pipe only the .php files' contents to grep. Don't know how to do that.
MadCatX
6th August 2009, 19:13
This nasty trick seemed to work for me. I used "grep -r -v * | grep -F moose" which found all lines containing "moose" in all files and subdirs. Note that the "-v" switch makes grep to find anything that does not contain the given string, here the asterisk. So change the asterisk to a char that is definitely not any of your .php files and give it a shot.
madcat@Ath3000 ~/fgtest $ ls -R
.:
aaa a.php a.php~ xxx yyy
./aaa:
b.php b.php~ c.php c.php~
./xxx:
a.php a.php~ mm.php mm.php~
./yyy:
a.php~ e.php
madcat@Ath3000 ~/fgtest $ grep -r -v * | grep -F moose
a.php:root moose
a.php~:x moose
xxx/a.php~:x moose
xxx/mm.php~:x moose
xxx/mm.php:digital moose
yyy/a.php~:x moose
madcat@Ath3000 ~/fgtest $
EDIT: Just found out that it does not filter out files without .php extension, so it still needs some polishing...
EDIT2: I got it, "grep -r -v * | grep -F .php | grep -F moose" does the trick.
madcat@Ath3000 ~/fgtest $ ls -R
.:
aaa a.php a.php~ test.txt xxx yyy
./aaa:
b.php b.php~ c.php c.php~ test.txt
./xxx:
a.php a.php~ mm.php mm.php~
./yyy:
a.php~ e.php
madcat@Ath3000 ~/fgtest $ grep -r -v * | grep -F .php | grep -F moose
a.php:root moose
a.php~:x moose
xxx/a.php~:x moose
xxx/mm.php~:x moose
xxx/mm.php:digital moose
yyy/a.php~:x moose
madcat@Ath3000 ~/fgtest $
GeForz
6th August 2009, 20:58
Uhm...
man fgrep:
fgrep is the same as `grep -F'
all other options are the same as grep
man grep:
--include=PATTERN
Recurse in directories only searching file matching PATTERN.
shouldn't that work? :o
-> grep -rF --include="*.php" searchstring .
works ;p
MadCatX
6th August 2009, 21:15
Kinda weird, GeForzes trick doesn't work for me, but "grep searchstring * -Fr --include=*.php" does...:shrug:
Victor
6th August 2009, 21:15
Uhm...
man fgrep:
man grep:
shouldn't that work? :o
-> grep -rF --include="*.php" searchstring .
works ;p
sweeet! (using : fgrep -ir --include="*.php" searchstring .)
bunder9999
6th August 2009, 21:34
find . -name '*.php' -print | xargs grep string
also works :shrug:
Woz
9th August 2009, 04:29
regex is my pet hate, like others here :)
I have a problem. I know I will use regex... Now I have two problems :)
NotAnIllusion
28th September 2009, 15:25
Hi, I've been dabbling with various VS 08 Express versions, but I've encountered an annoying problem. I want to show the current time in an "hh:mm" format like 18:22. In VC# it works, but I can't get my head around what is the VC++ equivalent of
aLabel.Text = DateTime.Now.ToShortTimeString();
Any hints? :)
Edit: actually nevermind.
aLabel->Text = DateTime::Now.ToShortTimeString(); *facepalm*
Dygear
28th September 2009, 21:11
Edit: actually nevermind.
aLabel->Text = DateTime::Now.ToShortTimeString(); *facepalm*
Yeah, we all know how that is. You ask for help, you search some more, and find the answer. Then you fell like an idiot, I do that twice, three times a day. :)
NotAnIllusion
28th September 2009, 21:16
Well, I got my first multi-threaded socket app working the way I wanted (in vb.net though, but I'm eventually going to port it to c# for practice), so I don't mind looking like an idiot today :D
NotAnIllusion
3rd October 2009, 11:16
I'm back, oh joy! :) I'm currently having a problem getting custom CSS working in FireFox, using userContent.css located in \users\<user>\appdata\roaming\mozilla\firefox\profiles\<random>.default\chrome.
I have the following code in the file, but the links are still blue. Any idea how to get LFSF links to be red using this method?
@-moz-document url-prefix(http://www.lfsforum.net/)
{
a:link {color:red}
a:visited {color:red}
a:active {color:red}
a:hover {color:red}
}
wien
3rd October 2009, 15:41
Most likely your new CSS rules have the same or lower specificity (http://htmldog.com/guides/cssadvanced/specificity/) than the forum CSS rules. That means they get overridden by the forum's own rules. Try adding the body tag to your selectors and see if that helps. You may need to be even more specific depending on how the forum rules are constructed. Something like so:
body a:link {color:red}
EDIT: According to my web-developer toolbar, the links are styled by the following rules:
a:link, body_alink
{
color: #22229C;
}
a:visited, body_avisited
{
color: #22229c;
}
a:hover, a:active, body_ahover
{
color: #ff4400;
}
Adding the body tag in front of these rules should do the trick.
NotAnIllusion
3rd October 2009, 16:24
Adding the body tag in front of these rules should do the trick.
This appears to have an effect. Got to be really careful selecting elements under a bunch of other tags. Red links really hurt my eyes now :(
Thanks :tilt:
edit: actually, it also required appending !important to override cascade rules.
body a:link, .body_alink { color: red !important;}
Dygear
5th October 2009, 01:59
edit: actually, it also required appending !important to override cascade rules.
body a:link, .body_alink { color: red !important;}
!important should work with out having a higher specificity.
Dygear
11th October 2009, 14:58
A (My)SQL Question for you all.
Does anyone know of a way of making one field's SET / ENUM (http://dev.mysql.com/doc/refman/5.0/en/constraint-enum.html) datatype depend on another tables values?
For example, if I have one table `members` that has another field in it called `status`, I want the status to be built off and cross checked against the table `status`.
CREATE TABLE `members` (
`id` TINYINT UNSIGNED NOT NULL COMMENT 'Members Unique Id',
`name_first` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'Members First Name',
`name_last` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'Members Last Name',
`status` TINYINT UNSIGNED NOT NULL COMMENT 'Members Status Flags',
PRIMARY KEY (`id`)
) ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_bin COMMENT = 'Members Root (Id in this table links to ALL other Root Tables).'
CREATE TABLE `status` (
`id` TINYINT UNSIGNED NOT NULL COMMENT 'Members Unique Id',
`class` VARCHAR ( 32 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'Members First Name',
`display` TINYINT( 1) NULL COMMENT 'Is this a required field to maintain status?'
PRIMARY KEY (`id`)
) ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_bin COMMENT = 'Status Root Connects to `members`.`status`.'
INSERT INTO `status` (
`id`, `class`, `display`
) VALUES (
1, 'Active', TRUE,
2, 'Class 1', TRUE,
4, 'Class 2', TRUE,
8, 'Student', FALSE,
16, 'Medical', FALSE,
32, 'Military', FALSE,
64, 'Leave of Absence', FALSE,
128, 'Disvowed', FALSE
);
the_angry_angel
11th October 2009, 19:14
Sounds like you're after Foreign Keys (http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html) :) Only works with innodb under MySQL tho.
Dygear
11th October 2009, 21:23
Sounds like you're after Foreign Keys (http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html) :) Only works with innodb under MySQL tho.
It's funny, I was looking at this, and there examples don't work.
CREATE TABLE product (
category INT NOT NULL,
id INT NOT NULL,
price DECIMAL,
PRIMARY KEY(category, id)
) ENGINE=INNODB;
CREATE TABLE customer (
id INT NOT NULL,
PRIMARY KEY (id)
) ENGINE=INNODB;
CREATE TABLE product_order (
no INT NOT NULL AUTO_INCREMENT,
product_category INT NOT NULL,
product_id INT NOT NULL,
customer_id INT NOT NULL,
PRIMARY KEY(no),
INDEX (product_category, product_id),
FOREIGN KEY (product_category, product_id)
REFERENCES product(category, id)
ON UPDATE CASCADE ON DELETE RESTRICT,
INDEX (customer_id),
FOREIGN KEY (customer_id)
REFERENCES customer(id)
) ENGINE=INNODB;
It's on that very paged that you linked to, and as far as I can tell, it does not work. I try to insert a value into customer and it balks. I try to insert something into product and it has no baring WHAT SO ever on anything else. I don't see the point of this, or I don't see any point of why I just can't get something that really in retrospect be very simple.
the_angry_angel
12th October 2009, 17:22
Hmm, FKs definately do work (I know, I use them in a legacy app at work under MySQL). I'm curious that the example doesn't work for you though.. Have you checked to see that foreign_key_checks (http://dev.mysql.com/doc/refman/5.1/en/server-session-variables.html#sysvar_foreign_key_checks) aren't set to 0?
If they are enabled I'd be surprised and interested enough to do some testing.
Dygear
12th October 2009, 20:47
Hmm, FKs definately do work (I know, I use them in a legacy app at work under MySQL). I'm curious that the example doesn't work for you though.. Have you checked to see that foreign_key_checks (http://dev.mysql.com/doc/refman/5.1/en/server-session-variables.html#sysvar_foreign_key_checks) aren't set to 0?
If they are enabled I'd be surprised and interested enough to do some testing.
Using PHPMyAdmin I went to the engine tab and then on InnoDB.
It states "Supports transactions, row-level locking, and foreign keys".
But searching the website using the Ctrl+F string search no other "foreign" was found.
I don't think my hosting copy has allowed support for this. Not sure why that is ...
Dygear
1st November 2009, 10:07
I just found this out, and I wanted to share with the rest of the world, as I thought it was pretty god damn cool of the PHP engine to be able to handle things such as this. It turns out that PHP can take any UTF-8 charater as a function name. So consequently, this works:
function Δ($a, $b) {
return $b - $a;
}
echo Δ(0x20, 0x50); # 48
echo dechex(Δ(0x20, 0x50)); # 30
How cool is that! And it out puts the correct answer of 48 when 'cast' to hex it returns 30. I think this is awesome, but that's just me I'm sure. Never the less, a delta (Δ) function in PHP.
function ƒ($args, $code) {
return create_function($args, $code);
}
$lambda = ƒ('$a,$b', 'return "ln($a) + ln($b) = " . log($a * $b);');
$lambda(2, M_E);
GeForz
1st November 2009, 10:45
Oh that's cool! :)
Someone should write a library to wrap functions to mathematical symbols ^^
function ∑(array $values) {
return array_sum($values);
}
function ∩(array $array1, array $array2) {
return (array_uintersect($array1, $array2, "strcasecmp")
}
etc.
Ivo Georgiev
1st November 2009, 11:01
i'd still have to be able to somehow look in all subdirs and pipe only the .php files' contents to grep. Don't know how to do that.
grep [something] $(find . -name "*.php")
Dygear
2nd November 2009, 14:20
A (My)SQL Question for you all.
I understand Foreign Keys (FK) now, thanks to http://www.lfsforum.net/images/buttons/viewpost.gifTAA pointing me in the right direction (http://www.lfsforum.net/showthread.php?p=1282030#post1282030), but now I've discovered something interesting that I've never seen in MySQL. Sub-Query's, and I think I can do some things that I've wanted to do for some time now, Dynamic Foreign Keys.
I have 4 tables (appointed, class, elected, status) that I want to cross reference into a single table's (members) column. The values of the of 4 tables are time sensitive based off a history table (members_history). The desired result is that the query should output all members and the current appointed position or current elected position, class, and status within the members row and include additional information obtained from the foreign rows.
So instead of returning
`id`, `username`, `password`, `salt`, `name_first`, `name_last`, `date_join` & `date_leave`;
The query would return
`id`, `username`, `password`, `salt`, `name_prefix`, `name_first`, `name_last`, `hours_extra` `date_join`, `date_leave`, `appointed`, `class`, `elected` & `status`;
Wherever an added column does not have a current value in history it's result should be NULL.
Now I think I can do this with sub-querys, but have been so far banging my head against the keyboard. I'll take another swing at it later, but until then, anyone else willing to give it a shot, or attempt to point me in the right direction?
The structure of my SQL (no pun intended) tables is as follows:
CREATE TABLE IF NOT EXISTS `members` (
`id` mediumint(3) unsigned NOT NULL auto_increment COMMENT 'Members Unique Id',
`username` varchar(32) collate utf8_bin NOT NULL COMMENT 'Mebers Username',
`password` varchar(64) collate utf8_bin NOT NULL COMMENT 'Members Password Hash',
`salt` varchar(32) collate utf8_bin NOT NULL COMMENT 'Members Password Salt',
`name_first` varchar(32) collate utf8_bin NOT NULL COMMENT 'Members First Name',
`name_last` varchar(32) collate utf8_bin NOT NULL COMMENT 'Members Last Name',
`date_join` date NOT NULL COMMENT 'Members Join Date',
`date_leave` date default NULL COMMENT 'Members Resgination Date (If Applicable)',
PRIMARY KEY (`id`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Members id in this table = mid in other tables';
CREATE TABLE IF NOT EXISTS `members:apointed` (
`id` tinyint(3) unsigned NOT NULL auto_increment COMMENT 'Unique value',
`name_prefix` varchar(8) collate utf8_bin NOT NULL COMMENT 'Prefix Added to Members Name',
`hours_extra` decimal(4,2) NOT NULL COMMENT 'Hours Given as Bonus for Holding this Posision.',
`posisiton` varchar(40) collate utf8_bin NOT NULL COMMENT 'Name of the Posisiton',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Undefined within the SOP or By-Laws.';
CREATE TABLE IF NOT EXISTS `members:class` (
`id` tinyint(3) unsigned NOT NULL auto_increment COMMENT 'Unique Id',
`class` varchar(8) collate utf8_bin NOT NULL COMMENT 'Unique Value',
PRIMARY KEY (`id`),
UNIQUE KEY `value` (`class`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Article I, Section 1 Subsection B: Classes of Membership';
CREATE TABLE IF NOT EXISTS `members:elected` (
`id` tinyint(3) unsigned NOT NULL auto_increment COMMENT 'Unique value',
`name_prefix` varchar(8) collate utf8_bin NOT NULL COMMENT 'Prefix Added to Members Name',
`hours_extra` decimal(4,2) NOT NULL COMMENT 'Hours Given as Bonus for Holding this Posision.',
`posisiton` varchar(40) collate utf8_bin NOT NULL COMMENT 'Name of the Posisiton',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Article II';
CREATE TABLE IF NOT EXISTS `members:status` (
`id` tinyint(3) unsigned NOT NULL auto_increment COMMENT 'Bit''s Place',
`status` varchar(16) collate utf8_bin NOT NULL COMMENT 'Categorie''s Name',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Article I, Section 1, Subsection A: Categories of Membership';
CREATE TABLE IF NOT EXISTS `members_history` (
`id` int(10) unsigned NOT NULL auto_increment COMMENT 'Unique Id',
`mid` tinyint(3) unsigned NOT NULL COMMENT 'Members Unique Id.',
`table` enum('class','elected','appointed','status') NOT NULL COMMENT 'Name of Table that was Edited.',
`value` tinyint(3) unsigned NOT NULL COMMENT 'Value',
`start` date NOT NULL COMMENT 'Value''s Effect Date',
`end` date default NULL COMMENT 'Value''s Expiration Date',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Member History';
`members_history`.`mid` is a FK for `id` in the members table, not every member will have history on them (but eventually they all will, as every member will have to have a class and status). `members_history`.`value` is a FK for `members:{`members_history`.`table`}`.`id`;
the_angry_angel
2nd November 2009, 14:59
I have 4 tables (appointed, class, elected, status) that I want to cross reference into a single table's (members) column. The values of the of 4 tables are time sensitive based off a history table (members_history). The desired result is that the query should output all members and the current appointed position or current elected position, class, and status within the members row and include additional information obtained from the foreign rows.Sounds what you want is an outer join (http://en.wikipedia.org/wiki/Join_%28SQL%29#Outer_joins), but I will admit that I've not had the time to read your post properly... If I'm barking up the wrong tree I'll either add to this post after work or add a new one in ;)
Stuff
2nd November 2009, 17:50
Well, I don't see any foreign keys. They would go after to your PRIMARY KEY constraint near the bottom. The foreign key tells which primary key of another table to connect to so you can join them. Something like..
CREATE TABLE class (
id integer,
class_name text,
PRIMARY KEY (id)
);
CREATE TABLE member (
id integer,
first_name text,
last_name text,
class_id integer,
PRIMARY KEY (id),
FOREIGN KEY (class_id) REFERENCES class (id)
);
SELECT m.id, m.first_name, m.last_name, c.class_name
FROM member m, class c
WHERE m.class_id = c.id;
SELECT m.id, m.first_name, m.last_name, c.class_name
FROM member m
OUTER JOIN class c ON m.class_id = c.id;
Above is just an example and of course may not work. I'm a little rusty and TAA might have a better way but this will get you started/thinking. Note, make the foreign keys the same data type as the primary keys they reference. And of course placing them in the right spot to have logical flow all depends on your data. Just do some more reading into keys, joins, etc and we'll be OK. :)
Dygear
2nd November 2009, 19:01
The foreign key tells which primary key of another table to connect to so you can join them.
[...]
Note, make the foreign keys the same data type as the primary keys they reference. And of course placing them in the right spot to have logical flow all depends on your data. Just do some more reading into keys, joins, etc and we'll be OK. :)
Yeah, I've been reading, and reading and reading trying to brute force programming (typing statements, into the phpMyAdmin query window pressing submit and preying that it works.) So far no joy. The question really does fall back onto a question I've asked before: Is there a way to get data from one database based of the query from another database?
In this case the `member_history`.`table` tells me what other table I have to query to get the data I want. The possible values of `member_history`.`table` are 'class','elected','appointed','status', telling me to query either of these tables: `member:class`, `member:elected`, `member:appointed`, and `member:status`. From there we know that `member_history`.`value` will be the `id` from one of those tables.
Where this query gets only the current (not expired) values for all users.
SELECT
*
FROM
`members_history`
WHERE
NOW() > UNIX_TIMESTAMP(`start`) AND
UNIX_TIMESTAMP(`end`) < NOW() OR ISNULL(`end`);
I would like a query that get joins this data with the data from the other tables into the members table.
dawesdust_12
2nd November 2009, 19:09
So, hurray for this being off topic...
I offer everyone something of advice... Never try to interact directly with a USB HID device... It's gross as the documentation is few and far between, and it's very picky as to everything (particularly in windows, where it needs a specific set of Libraries, Include files, and everything)...
It made me >|this|< close to suicide... until I finally got it to work by performing some sort of exotic voodoo rituals around printed copies of source code.
/head explosion.
Ian.H
2nd November 2009, 19:25
For using multiple sources in databases, I normally specify the data source within the FROM and WHERE clauses, for a simplified example:
SELECT
a.id
a.foo,
a.bar,
otherdb.b.a_id,
otherdb.b.baz
FROM tablea a,
otherdb.tableb b
WHERE b.a_id = a.id
ORDER BY b.baz
Seems to work the same as the various JOIN statements without the confusion between inner, outer, "overthere", "round_the_corner" variations.
Regards,
Ian
Blas89
2nd November 2009, 19:30
Geeks!
/me Runs! ->
Haha I couldnt resist... xD
Stuff
2nd November 2009, 19:52
Ahh.. sorry I misunderstood your original question. Yeah, a subquery should be able to do what you want. You've probably tried:
SELECT m.id, history.something
FROM members m, (SELECT table FROM members_history WHERE mid = m.id) AS history
WHERE ...
If you have tried or it doesn't work, then this is all I can think of on short notice. You'll probably get it soon enough though.
amp88
2nd November 2009, 20:41
Just posted this on Java forums but figure I might as well try here too :)
I'm writing an application and trying to use SLF4J 1.5.8 (with Log4J 1.2) for application logging. I am packaging my application (including all appropriate libraries) into a Fat Jar file and running it from the command line with the standard "java -jar <filename>". Now, that goes perfectly well if I include the "log4j.properties" file for Log4J in the jar file, but what I'd like to do is to keep the properties file outside of the jar file (so I can edit it without having to rebuild the jar) and also have several differently named configuration files which I can load when I initialise my application (the filename for the configuration I want to load being kept in a configuration file I can edit). This is not going so well. What I have tried to do is to user the System.setProperty() method to force Log4J to use the specific class (in the main method of my application before the logger is used) as such:
System.setProperty("log4j.configuration", log4JPropertiesFile.getAbsolutePath());
However, this doesn't appear to work because when I run my application I get the following warning:
log4j:WARN No appenders could be found for logger (examplepackage.Example).
log4j:WARN Please initialize the log4j system properly.
Can I accomplish what I want to, and if so how?
Secondly I have another problem related to the configuration of the properties file itself. I want to specify the file name for the log file with a relative path (e.g. just put the filename in there and for it to be written in the same directory where my jar file is being executed from), but everything I've seen in examples etc has shown that you need to specify the full path in the properties file. This isn't hugely convenient if you move the application for whatever reason. Is there a way to just specify a the log filename and have the log written in the folder the jar is executing from?
Any help or advice would be much appreciated :)
GeForz
8th November 2009, 14:33
did you try one of these?
a) java -Dlog4j.configuration=<path-to-config-file>/log4j.properties MyApp ...
b) Place the directory name in the class path. It will work fine.
MyBoss
22nd November 2009, 21:02
Just a quick question.
Can I use the LFS banners and icons on my website? Its just a temporarily site that I am making for a project at college.
Dygear
23rd November 2009, 00:53
Just a quick question.
Can I use the LFS banners and icons on my website? Its just a temporarily site that I am making for a project at college.
I don't see why not as long as your crediting the devs for the work they did, I really don't see the devs biting your head off for doing that, they are reasonable people. On the other hand make sure it's cool with your professor that it's ok to use someone elses work.
the_angry_angel
23rd November 2009, 20:22
Can I use the LFS banners and icons on my website? Its just a temporarily site that I am making for a project at college.The best place to ask would be via the http://www.lfs.net/index.php?page=mailus
Dygear
26th November 2009, 04:53
We've talked many times about learning regular expression within this thread, I was thinking, how about we use the context of normal program flow constructs to explain regular expressions.
For example an if (expression) is equivalent to /expression/ ... I really don't know regular expression that well to make examples ... so I'm hope that you all know what I mean and can make your own examples and post them here. As 99% of the people who are going to learn regular expression are programmers, so why not then talk in the same language as them to explain it?
GeForz
26th November 2009, 18:06
because regular expressions are used to avoid writing huuuge "program flow constructs" :o
dawesdust_12
26th November 2009, 18:35
I've got it!
You write the regular expression using normal code, then develop a regular expression that will convert that code into a regular expression.
Efficient?! :p
GeForz
26th November 2009, 19:15
but regular expressions dont convert anything :o
dawesdust_12
26th November 2009, 19:50
but you can replace... It was a retarded satirical idea, and wasn't meant to be taken seriously... but it COULD be done :p
amp88
26th November 2009, 20:13
but regular expressions dont convert anything :o
I hate regular expressions:
package tester;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegExExample {
public static void main(String[] args) {
new RegExExample();
}
private RegExExample() {
String inputDigits = "123foo456";
System.out.println("inputDigits: "+inputDigits);
Pattern p = Pattern.compile("\\d");
Matcher m = p.matcher(inputDigits);
StringBuilder outputWords = new StringBuilder();
while(m.find()) {
outputWords.append(getNumberWordForInputInt(Intege r.parseInt(inputDigits.substring(m.start(), m.end())))+" ");
}
System.out.println("outputWords: "+outputWords);
}
private String getNumberWordForInputInt(int input) {
switch(input) {
case 0: { return "zero"; }
case 1: { return "one"; }
case 2: { return "two"; }
case 3: { return "three"; }
case 4: { return "four"; }
case 5: { return "five"; }
case 6: { return "six"; }
case 7: { return "seven"; }
case 8: { return "eight"; }
case 9: { return "nine"; }
default: { return "?"; }
}
}
}
Program output:
inputDigits: 123foo456
outputWords: one two three four five six
GeForz
26th November 2009, 20:54
dont hate them :(
dawesdust_12
26th November 2009, 23:05
They're evil. I've never had a valuable use for them yet, but I still hate them because I have no idea where to use them.
the_angry_angel
27th November 2009, 12:41
They're evil. I've never had a valuable use for them yet, but I still hate them because I have no idea where to use them.They're good for validating complex input, such as telephone numbers. They're also good for quickly grabbing stuff from strings of input, or for manipulating strings.
To give 2 real world examples -
Many years ago I used to play a game called Planetarion - a web based online space strategy game. In it you could scan other planets to determine if they were worth attacking. Groups of players would form alliances and you'd want to share these scans. Unfortunately the only way to get them was to copy and paste from the browser. To deal with this many alliances would write little web based tools that their members could paste the scan into to update the database. Although each browser would copy a table into plain next in roughly the same format, it wasn't exact - some would place tabs between columns, others spaces. Regular expressions were the most sane and sensible way of getting the required data from these pasted scans and into a relational database for analysis.
I use regex's most days at work. At work I'm employed to be an outsourced sysadmin, but I also code for internal projects and so forth. For both elements of my job I will use regexs. For instance, using ldifde you can query an Active Directory server to get various bits of information about stuff in the AD (such as getting a list of users in an OU [organisational unit]). Unfortunately it normally returns a load of extra stuff you don't want and can't trim out through ldifde itself. Using regex's you can reliably remove these additional bits of guff. In our internal projects regex's are use for some of the more complex form validation, such as post/zip codes, email addresses and phone numbers.
For the coding aspect of my job it's handy when moving blocks of code or for refactoring. For instance I recently had to convert from using the Zend_Date object to our own. There were about 3 affected files, and about 4 instances created in each. I could've manually gone through and edited each file and each instance. However, using regex's I could simply perform :%s/Zend_Date/Better_Date/g (This is an example of using Vim's regex support to subsitute Better_Date for Zend_Date, through out the entire file, even if it occurs multiple times in the same line).
Unfortunately it becomes exceptionally easy to over use regexs.
For instance although you could use a regex to screen scrape from a website, it's a bad idea and you should really be using something that understands the DOM and allows you to query based on that - such as XPath or CSS selectors - the reason being that although a regex will probably work, it'll break if the website introduces new lines or additional attributes that your regex doesn't have support for. Something that understands the DOM will just continue working.
As I've said before, regex's are something you will absolutely hate. Until you get used to them.
Dygear
27th November 2009, 13:20
As I've said before, regex's are something you will absolutely hate. Until you get used to them.
So it's like perl, a one line wonder tool for those willing to learn it.
the_angry_angel
27th November 2009, 13:23
I've written some pretty nasty (read: long) regexs, so describing them as one line wonders isn't 100% accurate, but you're pretty much right :)
Ian.H
27th November 2009, 19:19
I must be strange.. I actually like RegEx! I find them an interesting challenge (for want of a better phrase). Granted, they can cause hair loss, but still provide more fun to me than trying to do a Rubik Cube for example :)
It bugs me when coding in C++ as it's not a language I'll claim to be fluent in at all that I haven't yet grasped the use of RegEx construction and normally have to resort to using various split() type calls and arrays to finally drill down to the data I need to access.
One task I've been asked to resolve at work is to fix some things in a CSV file. The 2 fields clearly labelled 'first_name' and 'last_name' seem to occasionally get filled with 'Miss Blogs' and 'Miss Joe' or the 'first_name' field with 'Jack or Jill' and the 'last_name' field left blank (don't ask.. we're talking about the acting industry.. not renowned for their intelligence). If I had to do this with C++, due to my lack of knowledge, I'd have to split each line at the ',' char, then process the fields working on splitting at spaces and the likes. Using RegEx will make the task very simple as I only need to split the row at the ',' char, then work on the relative field with some simple RegEx. I expect nothing more than 20 lines of code to read in a file, process and write an updated version.
Maybe sadistic, but I find them fun to work with (although my usage is pretty much limited to Perl and PHP) :)
Regards,
Ian
dawesdust_12
27th November 2009, 19:23
Ahh, the effortless way of baiting Ian out of his hole... mention RegEx's :p
Ian.H
27th November 2009, 19:31
Ahh, the effortless way of baiting Ian out of his hole... mention RegEx's :p
Heh.. have been sorting out trying buy a house and spend more time round my fiancé's place than I do in front of the screen after work these days... not a bad thing though :D
Regards,
Ian
wien
27th November 2009, 19:48
It bugs me when coding in C++ as it's not a language I'll claim to be fluent in at all that I haven't yet grasped the use of RegEx construction and normally have to resort to using various split() type calls and arrays to finally drill down to the data I need to access.Boost.RegEx (http://www.boost.org/doc/libs/1_41_0/libs/regex/doc/html/index.html)? I personally prefer Spirit (http://www.boost.org/doc/libs/1_41_0/libs/spirit/doc/html/index.html) for my string parsing needs though.
the_angry_angel
27th November 2009, 20:10
Boost.RegEx (http://www.boost.org/doc/libs/1_41_0/libs/regex/doc/html/index.html)? I personally prefer Spirit (http://www.boost.org/doc/libs/1_41_0/libs/spirit/doc/html/index.html) for my string parsing needs though.Maybe I'm just not getting it from the Spirit introduction page, but is Spirit a (better|different) objective version of Lexx?
wien
27th November 2009, 20:28
Maybe I'm just not getting it from the Spirit introduction page, but is Spirit a (better|different) objective version of Lexx?I've never used Lex, so I can't really comment on that in any detail, but it's basically a library that allows you to write the language grammar directly in EBNF form as plain C++ code. Lex requires preprocessing if I'm not mistaken? From what Wikipedia tells me Spirit fills the role of Yacc as well (parser generator), so Spirit = Lex + Yacc I guess you could say.
DarkTimes
21st December 2009, 18:44
I've been playing around with VS2010 and it's really good actually. I was concerned, like many people were, about it being ported to WPF, but it runs very smoothly and the font rendering in the editor is crisp and sharp. If anything I'd say it runs a bit faster than VS2008.
In terms of the new features in .NET 4.0, I've not had time to play around with much of it yet, but I'm enjoying some of the new additions to C# 4.0 (SortedSet is awesome), and the WPF editor has received a lot of work and is much more robust.
I think the best thing though has to be the improvements to the WPF font rendering, the text looks perfect now and makes me actually want to write WPF apps.
All in all it looks like a good step forward. :)
dawesdust_12
21st December 2009, 18:51
I think the only thing I'll want in C# 4 is the ability to have optional parameters for functions. Kind of a pain in the ass what they currently have.
wien
21st December 2009, 23:09
If anything I'd say it runs a bit faster than VS2008. Are you kidding, or are the .NET bits really that different from the C++ ones?
In my experience 2010 beta 2 is slow as molasses and horribly buggy to boot. Things like "go to declaration/definition" are completely unusable since they usually lock up the entire IDE for many seconds while it fails to find the declaration I asked for. Intellisense is still completely broken, even though they bragged that they had fixed it this time. It also uses more than twice the memory doing the same thing as VS2008, which on my 2GB laptop means even a simple compile of my framework leads to massive disk swapping.
Quite frankly I find it an unusable mess. If it weren't for the C++ compiler improvements (which are also rather buggy) I'd stay with VS2008.
Dygear
21st December 2009, 23:25
In my experience 2010 beta 2 is slow as molasses and horribly buggy to boot.
Yeah, that was another thing that put me off VS, I could type faster then it could render on the screen. I needed something lightweight and fast, so I use a NotePad2 (http://www.flos-freeware.ch/notepad2.html) Modification / Extension / Enhancement by Kai Liu (http://code.kliu.org/misc/notepad2/) for my programming needs.
Woz
22nd December 2009, 06:38
I am looking forwards to the DLR integration with C#.
Covariance and contravariance are the big things I want as they really P me off being missing from C#
Why I could not cast
List<ClassA> to an IEnumerable<IMyInterface> when ClassA implements IMyInterface was beyond me. The hoop jump to solve was just dumb.
DarkTimes
22nd December 2009, 15:42
Are you kidding, or are the .NET bits really that different from the C++ ones?
In my experience 2010 beta 2 is slow as molasses and horribly buggy to boot. Things like "go to declaration/definition" are completely unusable since they usually lock up the entire IDE for many seconds while it fails to find the declaration I asked for. Intellisense is still completely broken, even though they bragged that they had fixed it this time. It also uses more than twice the memory doing the same thing as VS2008, which on my 2GB laptop means even a simple compile of my framework leads to massive disk swapping.
Quite frankly I find it an unusable mess. If it weren't for the C++ compiler improvements (which are also rather buggy) I'd stay with VS2008.
Well I can only talk from my own experience, the C# editor is not any slower than in VS2008 for me, and the WPF editor is much, much better. That being said, the WPF support was awful before. I can understand that other potions of VS may not be all hugs and puppies, but for what I mainly use it for I'm pretty satisfied. Of course it is still a beta, and it does have a few bugs, but then that's what betas are for.
Woz
24th December 2009, 05:26
Well I can only talk from my own experience, the C# editor is not any slower than in VS2008 for me, and the WPF editor is much, much better. That being said, the WPF support was awful before. I can understand that other potions of VS may not be all hugs and puppies, but for what I mainly use it for I'm pretty satisfied. Of course it is still a beta, and it does have a few bugs, but then that's what betas are for.
Depends how aggressive your are with your use of intellisense :)
Dygear
23rd January 2010, 19:08
Ever read some of your old source code and become, like REALLY embarrassed by it? You think to yourself, how where you ever that stupid? I bring this up, because I'm looking at SimFIA's code base, as I was just going to release it, then I realized that it was really, really bad code, and I would hate it if anyone picked up some bad programming habits from it.
Echoing huge blocks of raw HTML ... Oh, it was bad!
DarkTimes
26th January 2010, 18:08
Yes, every time. I think that it's a good thing though, as to me it means I'm still improving. If I ever look back and think my old code is perfect, then it may well be time to give up. That doesn't mean I'm not embarrassed by it! Most of it. :p
One thing though that it took me a long time to learn, is that when you release code no one really notices how badly written it is. No one really cares. I guess cause everyone secretly thinks all their code is badly written too and doesn't want to draw attention to themselves.
In my view, no matter how something was written, if it works well and is useful to people, then it's something you should be proud of and you shouldn't hide away. Plus, I guarantee you that pretty much every other programmer in the world has definitely seen, and probably written, worse.
Flame CZE
29th January 2010, 10:30
Guys, I need some help from some people who know MySQL.
I have two tables - users and layouts. Here are the structures (example):
Users
----------------------------------------
| id | int, auto_increment |
| username | varchar |
| etc...
----------------------------------------
Layouts
----------------------------------------
| id | int, auto_increment |
| user_id | int |
| etc...
----------------------------------------
Explanation - all users are stored in "users" table. Each user can have some layouts uploaded, so each layout is stored in "layouts" table also with the user ID of the uploader. All I want to do is, to do a SELECT query that would look like this and should be orderable by all columns.
Select all users and number of rows in layouts table with their ID
----------------------------------------
| username | number_of_layouts |
----------------------------------------
| Flame | 3 |
| Jack | 5 |
| Peter | 0 |
----------------------------------------
blackbird04217
29th January 2010, 10:36
I have minimal MySQL experience but I believe it would be;
"SELECT number_of_layouts FROM _layout_table_here_ WHERE username = 'Flame'";
EDIT: I don't think this is what you were asking for anymore. But I believe that would give you the number of layouts for a particular user.
de Souza
29th January 2010, 10:54
@Flame
Has been a while since I don't mess with SQL but it might be something along these lines:
SELECT U.username, COUNT(L.user_id) AS number_of_layouts
FROM Users U, Layouts L
WHERE U.id = L.user_id
This "count" thing returns the number of rows that match the condition. I guess. Never used it.
:tilt:
Flame CZE
29th January 2010, 12:59
de Souza: I edited your query a little bit (yours didn't work as expected, returned one user and total number of all layouts). Now it returns all users and no. of layouts, but only from the users, who have at least 1 layout uploaded. I want this query to show a list of all users, so those, who have 0 layouts too. Here is my query so far:
SELECT U.username, COUNT(L.user_id) AS number_of_layouts
FROM users U, layouts L
WHERE U.id = L.user_id
GROUP BY U.id
Edit: As I am thinking about it, it isn't necessary to show all registered users on my site, so I will use the query above for now. You can still post any thoughts :)
de Souza
29th January 2010, 14:55
If you still want to show all users (or use a similar query to something else, or just out of curiosity), try changing from...
FROM users U, layouts L
WHERE U.id = L.user_id
to...
FROM users U
LEFT JOIN Layouts L ON U.id = L.user_id
That way, if I'm not mistaken, the two tables are joined even if the second table has no corresponding value.
Flame CZE
29th January 2010, 15:17
It returns me the same...
SELECT U.username, COUNT(L.user_id) AS number_of_layouts
FROM users U
LEFT JOIN layouts L ON U.id = L.user_id
WHERE U.id = L.user_id
GROUP BY U.id
de Souza
29th January 2010, 15:31
:worried:
Oh well I'll have a better look when I can then... if no one else comes here and tell us what's wrong.
Flame CZE
29th January 2010, 15:32
Okay, thanks. And if you wanted, I could post a sql document of all my tables, if it helps...
de Souza
29th January 2010, 15:36
Probably, but I'd rather not do this at work. :)
Flame CZE
29th January 2010, 15:40
That's for sure :) You can tell me when you want it. The site's server suddenly stopped working (free hosting), so I can't view my site, I can only test the queries in phpMyAdmin.
morpha
29th January 2010, 15:41
What about if you extend the WHERE clause with OR number_of_layouts = 0I'm heavily tangled up in C++ right now so my mind might mess up SQL a bit, but in my currently somewhat confused state that should return users with layouts and users without any, but not duplicates.
Flame CZE
29th January 2010, 15:46
What about if you extend the WHERE clause with OR number_of_layouts = 0I'm heavily tangled up in C++ right now so my mind might mess up SQL a bit, but in my currently somewhat confused state that should return users with layouts and users without any, but not duplicates.
I don't know why but it says unknown column 'number_of_layouts', although I have set this name as the alias.
morpha
29th January 2010, 15:47
I don't know why but it says unknown column 'number_of_layouts', although I have set this name as the alias.
Which MySQL version are you running? Try the COUNT() just to test the theory, then we can set about finding out why the alias doesn't work :)
Flame CZE
29th January 2010, 15:59
Which MySQL version are you running? Try the COUNT() just to test the theory, then we can set about finding out why the alias doesn't work :)
The MySQL version is 5.0.81-community. What do you mean by testing the count()?
Edit: I don't want to spam it here much, if you want to, you can add me on MSN.
tmehlinger
29th January 2010, 16:07
SELECT U.username, COUNT(L.user_id)
FROM users U, layouts L
WHERE U.id = L.user_id GROUP BY U.id
I'm assuming this is for a web application... you should consider an object-relational mapper so you don't have to write SQL. :)
Flame CZE
29th January 2010, 16:21
SELECT U.username, COUNT(L.user_id)
FROM users U, layouts L
WHERE U.id = L.user_id GROUP BY U.id
I'm assuming this is for a web application... you should consider an object-relational mapper so you don't have to write SQL. :)
But I don't know anything about objects in PHP :(
morpha
29th January 2010, 16:22
SELECT U.username, COUNT(L.user_id)
FROM users U, layouts L
WHERE U.id = L.user_id GROUP BY U.id
I'm assuming this is for a web application... you should consider an object-relational mapper so you don't have to write SQL. :)
This would still only return users with at least one layout uploaded though, right? Because U.id would never be L.user_id if L does not contain the U.id. Hence my suggestion of ORing for COUNT(L.user_id) = 0.
Stuff
29th January 2010, 16:27
It returns me the same...
SELECT U.username, COUNT(L.user_id) AS number_of_layouts
FROM users U
LEFT JOIN layouts L ON U.id = L.user_id
WHERE U.id = L.user_id
GROUP BY U.id
To me this looks close but I think you need the keyword OUTER when doing the join. ie LEFT OUTER JOIN layouts L ON U.id = L.user_id. I'm pretty sure the default join type is inner, which will throw away all rows that don't match whereas outer won't. Also take out the WHERE clause as thats exactly what the join replaces :)
Flame CZE
29th January 2010, 17:03
Thanks, it works now! Now I must wait for the server to run :schwitz:
de Souza
29th January 2010, 18:03
Great. :)
@Stuff: thanks for pointing that up. :tilt:
tmehlinger
29th January 2010, 18:17
This would still only return users with at least one layout uploaded though, right? Because U.id would never be L.user_id if L does not contain the U.id. Hence my suggestion of ORing for COUNT(L.user_id) = 0.
Yeah, you're right. Silly mistake on my part. I whipped up some test tables and it worked, but I didn't consider the zero case.
Either way, he's got it working now so woooooo. :)
morpha
29th January 2010, 18:22
Either way, he's got it working now so woooooo. :)
Well if both queries work, he should go for the better performer, which Stuff's solution probably is anyway :razz:
Flame CZE
29th January 2010, 20:38
Yes, I will use the Stuff's one :)
And by the way, the "server problem" is probably just a feature, when if one IP reaches 2000 page views, it gets blocked for the rest of the day. I was working so hard, that the refresh count was higher than expected :D
DarkTimes
12th April 2010, 17:11
Visual Studio 2010 is out today, including Visual C# 2010 Express Edition.
Of course, this also means that the .NET Framework 4.0 is out too, so everyone with a Windows system should download it post-haste. Contrary to popular belief, the .NET Framework client is actually a rather small download, normally just a few megabytes. You officially have no excuse. :)
Get Visual C# 2010 Express: http://www.microsoft.com/express/Downloads/
Get the best version of .NET for you: http://www.hanselman.com/smallestdotnet/
traxxion
12th April 2010, 17:33
Aah totally forgot! Cheers for the heads up mr. Faraday!
DarkTimes
12th April 2010, 19:44
A good tip for VS C# 2010 is to go into Tools > Settings and chose Expert Settings, which will give you back all the menu and toolbar options you would be familiar with from VS 2008.
Edit: Incidentally the release version of C# Express uses about 100mb of memory less than the beta, and appears to run much much faster.
Dygear
13th April 2010, 20:00
A good tip for VS C# 2010 is to go into Tools > Settings and chose Expert Settings, which will give you back all the menu and toolbar options you would be familiar with from VS 2008.
Edit: Incidentally the release version of C# Express uses about 100mb of memory less than the beta, and appears to run much much faster.
That's pretty cool, I wonder if the extra 100MB was for the debug code, and they just flipped the switch to remove the code in the compiled version.
DarkTimes
13th April 2010, 23:35
Nah, they just hadn't optimised the new code. It had quite a few issues, as well as some pretty horrendous memory leaks, which sadly seems to be a reoccurring theme with applications written in WPF. Obviously managed code doesn't remove the necessity to manage memory, but in WPF it seems there is a tendency to have orphaned XAML elements which never get garbage collected. Pretty much all of those issues have been fixed, plus a few old things, such as the Add References dialog, have been hugely improved. Well, I know there are always people who will never be happy with Visual Studio, but I do think it's a very nice upgrade.
the_angry_angel
18th April 2010, 18:33
Just spotted this on HackADay - http://hackaday.com/2010/04/18/racing-sim-with-real-car-parts/ (decided it was more OT than anything else).
Granted we've seen other smaller scale stuff like that before, but its nice to see someone's work with LFS featured on such a prominent hardware hackers website :)
Patrick_IRL
18th April 2010, 21:46
Does anyone know where I can get a Auto gearbox like ones found on real cars? Not like the one supplied on LFS that only changes up higher within the rev range?
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.