|
Ideas
Last post 05-18-2007 11:52 AM by phaedrus. 65 replies.
-
-
phaedrus


- Joined on 03-19-2007
- Seattle Ex-Pat living in the Bay Area
- Posts 111
|
asuffield: Badr Z.:With that kind of knowledge, where can you get a work? Visual Studio team, intel, ...?
Nothing that you know about computers or software will ever get you a job. Almost nobody bothers to check what you know when recruiting, and the few who do, recruit almost nobody.
Now there's some hard core cynicism. There's some truth there. It's basically impossible to truly verify a candidate during the hiring process, but you can get an idea whether someone is competent. So, being compentent and having that knowledge should get you through the hiring process (although, as this site has proven time and time again, being good with the bs works equally well, if not better). It's what happens afterwards that is important. If you have the skills, your peers and management will notice, if your company isn't disfunctional (mine isn't. I'm a system software guy for a small Silicon Valley set top box company, good coders are appreciated and given raises around my neck of the woods). You'll get moved on to bigger, better things within the company and get to perpetrate cool hacks on your software. We just had a guy quit who does Linux kernel code and hardcore performance optimization stuff. We had him running around working on low-level performance enhancements for our embedded systems. He did quite a bit of work tweaking GCC, Linux and what have you. His skillset is reasonably similar to asuffield's (at least, as far as the intimate compiler knowledge and low-level architecture knowledge stuff goes). There's lots of places for someone like that. As for learning that stuff? I started programming QBASIC on DOS 5.something when I was nine. I wasn't any good at bird-dogging the ladies in school, so I messed around with my computer at night instead. I was also the "That Guy(tm)" in my microcomputer class (you know, the class where you build a microcomputer from TTL logic and an MC68008 processor? I was "That Guy(tm)" who went out to the library and grabbed the MC68k programming manual during the first week... For the record, I have a BS in physics). I picked most of it up on my own by reading and playing. The playing is really important. I also found that part impossible on MicroSoft's Operating Systems. The big advantage of Linux to me is that as far down the stack as I want to dig, I can. I regularly rip open the code on programs that are misbehaving and see how they tick.
Of course, it means that this is a good example of some of the solutions I come up with.
All men are frauds. The only difference between them is that some admit it. I myself deny it. -- H. L. Mencken
|
|
-
-
asuffield


- Joined on 05-31-2006
- Posts 2,137
|
phaedrus:However, what you could do is buffer overrun your own code to get it to run in place, eg, #include <stdio.h>
char buf[1024];
void overrun_myself(void) { int stack[1];
*(stack+0x02) = buf;
return; }
int main(void) { /* code to setup buf with your machine code goes here */
overrun_myself();
return 0; } I actually use this trick extensively in my submission.
That's a form of the hack I described earlier - it won't work if your platform actually has limits on executable pages (eg, NX bit and an operating system that supports it), and it only works otherwise due to CPU/OS design flaws. That does make it kinda appropriate.
|
|
-
-
asuffield


- Joined on 05-31-2006
- Posts 2,137
|
phaedrus:So, being compentent and having that knowledge should get you through the hiring process (although, as this site has proven time and time again, being good with the bs works equally well, if not better).
I find that since it's so hard to check, most people don't bother at all, and the hiring process is almost always purely a test of how well you can lie to managers.
It's what happens afterwards that is important. If you have the skills, your peers and management will notice, if your company isn't disfunctional (mine isn't. I'm a system software guy for a small Silicon Valley set top box company, good coders are appreciated and given raises around my neck of the woods). You'll get moved on to bigger, better things within the company and get to perpetrate cool hacks on your software.
Sure, that happens. My point was merely that you don't get hired that way. We just had a guy quit who does Linux kernel code and hardcore performance optimization stuff. We had him running around working on low-level performance enhancements for our embedded systems. He did quite a bit of work tweaking GCC, Linux and what have you. His skillset is reasonably similar to asuffield's (at least, as far as the intimate compiler knowledge and low-level architecture knowledge stuff goes). There's lots of places for someone like that.
Surprisingly few, actually - I've never been employed doing that kind of stuff, it's just a hobby for me (dating back to when I was a student, and I spent six months doing grotesque things in the guts of gcc as part of my undergrad course). The number of people who have a need to deal with that level of detail turns out to be pretty small. Unless you're actually implementing a compiler or operating system, or building a hardware platform from scratch, you don't really need it, and there's probably only a few dozen companies doing those things - most people just use what already exists. My day job skillset is entirely different, sysadmin stuff. You can actually find people who need that.
|
|
-
-
phaedrus


- Joined on 03-19-2007
- Seattle Ex-Pat living in the Bay Area
- Posts 111
|
asuffield: phaedrus:It's what happens afterwards that is important. If you have the skills, your peers and management will notice, if your company isn't disfunctional (mine isn't. I'm a system software guy for a small Silicon Valley set top box company, good coders are appreciated and given raises around my neck of the woods). You'll get moved on to bigger, better things within the company and get to perpetrate cool hacks on your software.
Sure, that happens. My point was merely that you don't get hired that way.
Yep. We're quite in agreement here. I just wanted to temper the cynicism a bit. I mean, I've had a great experience at my job, and I just wanted to instill some hope into the young'uns so that when they ran into a job worthy of a front page post, it would be just that much more soul crushing. ;) Surprisingly few, actually - I've never been employed doing that kind of stuff, it's just a hobby for me (dating back to when I was a student, and I spent six months doing grotesque things in the guts of gcc as part of my undergrad course). The number of people who have a need to deal with that level of detail turns out to be pretty small. Unless you're actually implementing a compiler or operating system, or building a hardware platform from scratch, you don't really need it, and there's probably only a few dozen companies doing those things - most people just use what already exists. My day job skillset is entirely different, sysadmin stuff. You can actually find people who need that.
I must admit, I'm pretty fresh out of school. However, the job I got hired for was actually a sysadmin position, but my manager eventually pulled me aside and said, "you've got a physics degree, right? So that means you aren't afraid of a 'scope?" I said yep, and he moved me into an engineering spot that's pretty close to the metal. Oh, and you described what my company does pretty solidly. We have a small hardware team that designs custom boards, and a system software team that ports Linux to those boards and tweaks the drivers to work just right. We've got a relatively large codebase and limited resources on our embedded systems, so low-level optimizations are pretty important.
All men are frauds. The only difference between them is that some admit it. I myself deny it. -- H. L. Mencken
|
|
-
-
phaedrus


- Joined on 03-19-2007
- Seattle Ex-Pat living in the Bay Area
- Posts 111
|
asuffield:That's a form of the hack I described earlier - it won't work if your platform actually has limits on executable pages (eg, NX bit and an operating system that supports it), and it only works otherwise due to CPU/OS design flaws. That does make it kinda appropriate.
Yeah, I'm not using it exactly like that, but I rewrite my return address as a way of overriding the call stack structure. As my earlier post indicated, the raw-code-in-a-buffer trick was good for the IOCCC in 1984, which, per the rules, makes it bad for OMGWTF 2007, so I'm not doing it. Although, it is pretty WTFy.
All men are frauds. The only difference between them is that some admit it. I myself deny it. -- H. L. Mencken
|
|
-
-
groovy2shoes


- Joined on 05-15-2007
- Posts 2
|
billbrasky:I implemented my code, but it's entirely too neat and I don't have the time to make it "Enterprisey" enough. But, here's some ideas I came up with. 1) Operations may need to be added/removed/modified at any time. Therefore, they should all be implemented in configuration files. These files, of course, should be written in HTML (yes, I worked for a company that actually stored configuration files in HTML). 1a) (optional) Since performance is extremely important, the configuration files should implement the operations in assembly language. Therefore, your application will need to implement an assembler. 1aa) Since MASM can't possibly assemble as fast as you can, implement your own assembler. 2) For ease of use, all values should be stored in strings. Any mathematical operations should parse these strings into floats or doubles-- your choice. When writing them back to strings, keep in mind that the testcases only require 6 digits before and 1 after the decimal point. 2a) Be sure to write your own functions to convert to and from floats so you can optimize them. 3) Your application should provide help functionality, but the tech writer is on vacation till next month. You can either have the intern who got a 'D' in grammar write the help or just leave it @todo. 4) Be sure to internationalize your application. Be sure to leave all the message catalogs empty. 5) C++ exceptions can return values in a pinch.
You stole my idea! Except my assembler targets a custom virtual machine implemented in my calculator, which delegates all operations to assembled assembly language files!
|
|
-
-
-
EvanED


- Joined on 08-22-2005
- Posts 114
|
So the first idea that I came up with was to have a database with the results of each operation on every pair of numbers up to 600,000. It would have been essentially a 600,000 x 600,000 array of 12-byte ASCII numbers, so the code could be pretty easy: add (a, b) { fd = open("add.db"); lseek(fd, 600000 * 12 * a + 12*b); read(fd, buf, 12); return buf; } Unfortunately, this would be several terabytes. (Though I'm sure it would compress *really* well.)
A related idea is to use the file system. Create directories such as add/, sub/, ... and into those put a number of subdirectories with the first operand, then into THOSE directories put a number of subdirectories with the second operand, then into those put the answer in a file named with the answer. So you would have, add/1/1/2, add/1/2/3, add/5/12/17, etc. Then we have: add (a, b) { directory = concatenate( "add/", a, "/", b "/'); for each entry in directory { if entry is a file { fd = open(entry); read(fd, buf, 12); return buf; } } } This is likely worse than the first option in terms of disk space if you include everything, but it would also be possible to not include most of the database. For instance, if 13 is never added to anything, then add/13/ can be empty.
The other idea I had was completely different. I would have used a SAT solver. If you are adding two numbers with binary digits a_31,a_30,a_29,...,a_1,a_0 and b_32,..,b_0, then you can figure out the answer d by solving the usual adder formulas (c is carry and is used for simplification): c_0 = a_0 and b_0 d_0 = a_0 xor c_0 c_i = (a_i and b_i) or (a_i and c_{i-1}) or (b_i and c_{i-1}) d_i = a_i xor b_i xor c_{i-1} Bonus points if you remove the explicit carries, instead wrapping them up into the successive formulas, and of course you have to do this with floating point numbers instead of integers.
|
|
-
-
Massimo


- Joined on 04-25-2007
- Posts 84
|
EvanED:A related idea is to use the file system.
Create directories such as add/, sub/, ... and into those put a number of subdirectories with the first operand, then into THOSE directories put a number of subdirectories with the second operand, then into those put the answer in a file named with the answer. So you would have, add/1/1/2, add/1/2/3, add/5/12/17, etc.
That's almost exactly what I did for my first entry, submitted mainly as a joke (my "real" entries are the three next ones); the only difference is I used a file for the second operand, containing the answer inside.
Of course, I only put the files for the test cases in the submission... if you try to execute anything other than them, you get a good old "File Not Found".
|
|
-
-
Welbog


- Joined on 02-08-2007
- Posts 434
|
I feel that my entry is inadequate compared to most other ideas outlined here.
I had a very simple goal in mind: use way too much object abstraction with an n-tiered design as well as avoiding the use of all arithmetic operations. The result is an enterprisey model that has the future expandability of n-ary operations (through the nifty use of polymorphism) because parameters are passed as vectors of number objects (which store unsigned ints as string objects) instead of explicitly as two parameters. The problem with this brillant foresight is nowhere in the application are floats used, so you have to fake them by coming up with decimal expansions as strings and concatenating them together with a period in the middle to display them.
I'm most proud of the fact that there is no explicit use of +, -, /, ++, -- or * (except as a pointer) anywhere in my implementation. Only <<, ^ and & are used. Addition is defined based around the following observation: a+b = (a&b)<<1 + (a^b), which is, of course, recursive. The other operations are most just calls to Addition: Subtraction just finds the two's complement of one operand and then adds the results; Multiplication uses a modified high-school algorithm to repeatedly add bitshifted sums; and Division uses a lookup table to compare the two operands and, using a modified high-school algorithm, finds the integer division result of the two, and if there is a remainder it recursively calls Division again to find the decimal places.
Up against stack overflows and hand-writing recognition I don't stand a chance, but it sure was fun trying. At least I got to make an enterprisey design document in the process. :)
|
|
-
-
-
Einsidler


- Joined on 11-15-2006
- Posts 99
|
EvanED: A related idea is to use the file system. Create directories such as add/, sub/, ... and into those put a number of subdirectories with the first operand, then into THOSE directories put a number of subdirectories with the second operand, then into those put the answer in a file named with the answer. So you would have, add/1/1/2, add/1/2/3, add/5/12/17, etc.
Reminds me of a funny story. I have a watch that plays videos (and music), and so naturally I wanted to put some porn on it, mainly so I could say to my friends "LOL I HAS A PR0N." However, I didn't want random people going into those kind of files. First I thought of just putting it in some music directory that nobody would want to go into, but what if someone actually wanted to listen to My Chemical Romance and found all my porn there instead? The solution was to create 10 directories, labed 0-9, in each of those the same, in each of those the same and so on; because "pffft, empty folders don't take up space." I created a program in C# using recursion and the function to make subdirectories, to generate this for me. I never got it to the watch. After the program finished running, set to four levels deep, I had generated about 5GB of absolutely nothing.
Download my OMGWTF entry, Romanorum Computus
|
|
-
-
phaedrus


- Joined on 03-19-2007
- Seattle Ex-Pat living in the Bay Area
- Posts 111
|
Einsidler: EvanED: A related idea is to use the file system. Create directories such as add/, sub/, ... and into those put a number of subdirectories with the first operand, then into THOSE directories put a number of subdirectories with the second operand, then into those put the answer in a file named with the answer. So you would have, add/1/1/2, add/1/2/3, add/5/12/17, etc.
Reminds me of a funny story. I have a watch that plays videos (and music), and so naturally I wanted to put some porn on it, mainly so I could say to my friends "LOL I HAS A PR0N." However, I didn't want random people going into those kind of files. First I thought of just putting it in some music directory that nobody would want to go into, but what if someone actually wanted to listen to My Chemical Romance and found all my porn there instead? The solution was to create 10 directories, labed 0-9, in each of those the same, in each of those the same and so on; because "pffft, empty folders don't take up space." I created a program in C# using recursion and the function to make subdirectories, to generate this for me. I never got it to the watch. After the program finished running, set to four levels deep, I had generated about 5GB of absolutely nothing.
You would have 10+10^2+10^3+10^4 or 11110 directories (spooky!). Under ext2/ext3, a directory requires one inode, which (by default) is associated with 4kiB of disk space. 11110*4096 is 43.4MiB. brb. ...
Huh. I just tried it.
$$ cat test.sh #!/bin/bash
function creatdirs () { local lvl=$1 if [ -z "$lvl" ]; then echo 'WAKKA WAKKA BLAH!' exit 1 fi
if [ "$lvl" -ge 5 ]; then return fi
for d in $(seq 0 9); do mkdir $d cd $d creatdirs $(( $lvl + 1 )) cd .. done }
creatdirs 1 ##EOF After running in an empty dir called ~/test: $$ cd ~/test $$ du -sh . 44M .
Also: $$ find . | wc --lines 11111 $$ find . | head . ./0 ./0/0 ./0/0/0 ./0/0/0/0 ./0/0/0/1 ./0/0/0/2 ./0/0/0/3 ./0/0/0/4 ./0/0/0/5
Dude. Fix your script or get a better filesystem.
All men are frauds. The only difference between them is that some admit it. I myself deny it. -- H. L. Mencken
|
|
-
-
phaedrus


- Joined on 03-19-2007
- Seattle Ex-Pat living in the Bay Area
- Posts 111
|
Einsidler: EvanED: A related idea is to use the file system. Create directories such as add/, sub/, ... and into those put a number of subdirectories with the first operand, then into THOSE directories put a number of subdirectories with the second operand, then into those put the answer in a file named with the answer. So you would have, add/1/1/2, add/1/2/3, add/5/12/17, etc.
Reminds me of a funny story. I have a watch that plays videos (and music), and so naturally I wanted to put some porn on it, mainly so I could say to my friends "LOL I HAS A PR0N." However, I didn't want random people going into those kind of files. First I thought of just putting it in some music directory that nobody would want to go into, but what if someone actually wanted to listen to My Chemical Romance and found all my porn there instead? The solution was to create 10 directories, labed 0-9, in each of those the same, in each of those the same and so on; because "pffft, empty folders don't take up space." I created a program in C# using recursion and the function to make subdirectories, to generate this for me. I never got it to the watch. After the program finished running, set to four levels deep, I had generated about 5GB of absolutely nothing.
But good idea though. Apparently, some people actually listen to My Chemical Romance, so the directory based PIN is definitely a better idea.
All men are frauds. The only difference between them is that some admit it. I myself deny it. -- H. L. Mencken
|
|
-
-
Einsidler


- Joined on 11-15-2006
- Posts 99
|
phaedrus:Dude. Fix your script or get a better filesystem.
I'm just using windows XP with about 10GB left (at that time)(also fragged up to buggery if that matters) and this is the C# code I used in its entirety: #define NUMERIC_ONLY using System; using System.IO; using System.Collections.Generic; using System.Text;
namespace pwfs { class pwfs { #if NUMERIC_ONLY static char[] options = new char[10]; #else static char[] options = new char[36]; #endif
static void Main(string[] args) { Console.WriteLine("Password File System\nHide files in complecated directory trees"); for (int i = 0; i < options.Length; i++) { options[i] = (char)(i < 10 ? i + 48 : i + 87); }
output_directories(get_directory(), get_levels()); }
static string get_directory() { #if DEBUG return "D:\\test\\"; #else Console.Write("Where do you want the Password File System? "); string directory = Console.ReadLine(); if (!directory.EndsWith("\\")) directory += '\\'; return directory; #endif }
static byte get_levels() { #if DEBUG return 2; #else Console.Write("How long a password do you want to allow? "); return Convert.ToByte(Console.ReadLine()); #endif }
static void output_directories(string path, int level) { DirectoryInfo dir = new DirectoryInfo(path); for (int i = 0; i < options.Length; i++) { Console.WriteLine("Creating directory " + path + options[i] + '\\'); dir.CreateSubdirectory(options[i].ToString()); if (level > 1) output_directories(path + options[i] + '\\', level - 1); } } } }
I think I may have been subconsciously preparing for this contest, even though this all happened months ago.
Download my OMGWTF entry, Romanorum Computus
|
|
-
-
phaedrus


- Joined on 03-19-2007
- Seattle Ex-Pat living in the Bay Area
- Posts 111
|
Einsidler: phaedrus:Dude. Fix your script or get a better filesystem.
I'm just using windows XP with about 10GB left (at that time)(also fragged up to buggery if that matters) and this is the C# code I used in its entirety: [... snip code ...] I think I may have been subconsciously preparing for this contest, even though this all happened months ago.
Well, I think the answer is get a better filesystem. Your code is almost exactly the same as mine algorithm wise (our level variable is opposite in sense, but that is hardly significant), and I don't see any bugs. Cheers.
All men are frauds. The only difference between them is that some admit it. I myself deny it. -- H. L. Mencken
|
|
|
|
|