|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On October 23 2012 01:12 Ian Ian Ian wrote:Is there a way for an if statement to return nothing? My code looks like + Show Spoiler + n = 1 pmf = binomial(1,n,0.5) while pmf > 0 : n += 1 pmf = binomial(1,n,0.5) if pmf == 0: print n else:
I'm supposed to find what value n needs to be to have pmf = 0. It is n = 1075. I don't want to see python print n every single time the loop is ran so I threw in an if statement. But it keeps giving me an error because the else statement has nothing there, but I don't want it to do anything either! Also, how are people writing their code in those white boxes? :S Can you just remove the else?
To write code:
Wrap it in a [code] block.
|
Hey TL, I dropped out of University with these classes done right...
Introduction to Computing I and II (Java programming) Introduction to Databases Introduction to Networks Calculus I and II Discrete Mathematics Data Structures Algorithms: Analysis and Design Logic
Do you guys recommend anything for further self-study as far as it relates to computer science? CS programs often give Linear Algebra as a required class, would that be useful? What about operating systems? AI?
|
Hyrule19031 Posts
Linear is very helpful for a lot of different stuff
OS and AI were the final year tracts at my university rather than specific classes, and were designed as a few classes each + a project.
|
On October 23 2012 01:15 Tobberoth wrote:Show nested quote +On October 23 2012 01:12 Ian Ian Ian wrote:Is there a way for an if statement to return nothing? My code looks like + Show Spoiler + n = 1 pmf = binomial(1,n,0.5) while pmf > 0 : n += 1 pmf = binomial(1,n,0.5) if pmf == 0: print n else:
I'm supposed to find what value n needs to be to have pmf = 0. It is n = 1075. I don't want to see python print n every single time the loop is ran so I threw in an if statement. But it keeps giving me an error because the else statement has nothing there, but I don't want it to do anything either! Also, how are people writing their code in those white boxes? :S Can you just remove the else? To write code: Wrap it in a [code] block.
I thought if statements had to have an else?! Will try
Works. Thank you! I feel pretty stupid right now
|
On October 23 2012 00:39 CecilSunkure wrote:Show nested quote +On October 22 2012 20:20 mmp wrote:The algorithm converts a string sentence "a b {c d} e" and converts it to a list of words and nested sentences, ["a", "b", "{c d}", "e"]. def tokenize_line(self, line): out = [] block = [] nest = 0 line = line.strip() grams = line.split(' ') for word in grams: nested = nest > 0 if word[0] == '{': if nest == 0: word = word[1:] nest = nest + 1 nested = True if word[-1] == '}': nest = nest - 1 if nest == 0: word = word[:-1] nested = True if nested: block.append(word) else: out.append(self.scan_word(word)) if nest == 0: if len(block) > 0: out.append(self.scan(' '.join(block))) nest = 0 block = [] if nest != 0: error.fail('unbalanced {}') return sentence.Sentence(out)
It works, but is terrible to read. Can someone help simplify this? I don't get how the nested sentences are supposed to work. How are multiple nested sentences supposed to work? The algorithm recurses through 'scan' and 'scan_word'. So a nested sentence like '{a {b c}}' appends scan('a {b c}') to the current sentence. You end up with a tree of sentences, where every item/token in the sentence is a word or a nested sentence.
scan('a {b {c {d e} } }') => Sentence([Word('a'), scan('b {c {d e} }')]) ==> Sentence([Word('a'), Sentence( [Word('b'), scan('c {d e}') ] ) ] ) ...
Some background:
This generates an abstract syntax tree. At evaluation, a Word can take on several types (function, argument, or literal), depending on the context. Similarly, a Sentence evaluates to different types of expressions (define/call a function) in the language.
The language is very simple (you're looking at the only non-trivial code), so going for an off the shelf grammar parser is overkill.
|
Does anyone have any idea / resources on how to pull data directly from the League of Legends score screen (that appears after games end)?
|
So I've got a question again...
We've got a project in school that we're working on at school. There are four of us in our group. We're currently still in the planning stages/learning stages (learning JavaScript and all the required libraries).
So here is the problem: I ... I don't have a laptop. So far, any time we ever had any group work at school I'd code at home or on the school computers, and this worked out just fine. I won't really be able to continue using the school computers the way they are in this project as setting everything up every time would be a pain in the ass (installing Node.js, etc).
Do you guys know of any... portable solutions? The computers at school have PuTTY and I've used that before but it's sort of shitty to code on. Something like 'buy a laptop' or 'always code at home' isn't exactly helpful. ^.^
Any ideas/input is appreciated!
|
On October 23 2012 10:48 Craton wrote: Does anyone have any idea / resources on how to pull data directly from the League of Legends score screen (that appears after games end)? You'll have to do some reversing (Get a memory searcher like http://memoryhacking.com/ and a debugger like http://www.ollydbg.de/ and you should be in business). Although I guess all of the LoL stuff is in Adobe Air so it'd probably be a pain in the ass. Your other option, since its likely retrieved from a webservice, is to hook the socket functions for the launcher and catch that request/parse the response. I think that'd probably be the easiest/most reliable, but if you don't have experience doing that sort of thing you may have a hard time getting started.
|
On October 23 2012 12:59 Crazyeyes wrote: The computers at school have PuTTY and I've used that before but it's sort of shitty to code on.
What problems are you having?
I use PuTTY all the time for work, and I don't mind because I'm used to hacking in a terminal.
The 'screen' program helps you share the single terminal. CTRL+A C to create a new screen. CTRL+A + N to move to the next screen, etc. Pick a powerful text editor like vim or emacs and learn it well. Your effort will be rewarded.
I like vim, and I prefer gvim (nicer fonts / syntax highlighting) when I'm not in a terminal to any point-and-click text editor.
tldr; make the most of a shitty situation and you might be surprised.
|
So I am just starting my programming classes for my college major and I have an intro to programming teacher who does not know the difference between java and javascript. How concerned should I be?
|
I had 4 programming classes from a PhD in Philo that could not write code.
Change professors or schools.
|
On October 24 2012 12:14 Azerbaijan wrote: So I am just starting my programming classes for my college major and I have an intro to programming teacher who does not know the difference between java and javascript. How concerned should I be?
Incredibly concerned. Its not like those are unknown languages. He could even look on wikipedia to find out whats different.
|
On October 24 2012 12:14 Azerbaijan wrote: So I am just starting my programming classes for my college major and I have an intro to programming teacher who does not know the difference between java and javascript. How concerned should I be? That's really bad. So bad that I don't think you're going to want to stay in that school bad. You're throwing money away bad.
|
On October 24 2012 12:14 Azerbaijan wrote: So I am just starting my programming classes for my college major and I have an intro to programming teacher who does not know the difference between java and javascript. How concerned should I be?
Mind sharing some more details? What exactly did they say re: java and javascript that let you reach that conclusion?
|
Technologies involved: Oracle 10g Java 1.4.2 Perl
Background: + Show Spoiler +I work as a contractor for a government institution (most accurately, my company is a contractor). For the work I do, we receive large data files of real data (i.e. real information about people), which we then use to modify (for testing purposes, i.e. "dirtying" up the data) or to manufacture additional test data. The data is all kept within the same division and on secure servers, so the realness of it is not an issue.
More about the files: These are ASCII files with very large line lengths (biggest so far has been 60,000 characters a line, though there is one more type of file that I believe is worse). Additionally, these are all fixed length and padded with spaces. The meaning of these characters is derived from their position on each line. Example, someone's first name might be found at positions 500 through 550. If it's shifted at all, everything is ruined.
Because these are completely non-normalized flat files, we have over 5,000 "columns" worth of data.
Given the brief span of time these are in our system, we do not make an effort to normalize them, as they go back out the same way as they came in (just with different characters).
Oracle has a column limit of 1,000 per table. Sensible if you have a properly normalized (or even remotely normalized...) database, but this isn't. Our current implementation is basically to make multiple tables (each with ~900 columns) until all the data has been read in. There is a column that maintains the line number of each record that came in, which can then be used to join everything together when it's time to kick it back out.
Amusingly, the UTL_FILE of Oracle that is used to write tables to files has a character limit of 32767 bytes. We were never able to get around this limit, even by breaking things up and trying to do puts (over putline), flushing buffers, manually adding carriage returns, etc). Eventually, we went another route; instead of trying to output all the tables as one file, we output each related table as a separate file and then generate a Perl script which joins them (the server runs on Unix).
This works, but it isn't very elegant. There was a lot of headache involved in even getting this far, including getting permissions from the DBAs and Unix admins.
Hoping to improve on this, I wrote up a Java stored procedure that tries to accomplish the original goal: output everything at once, nice and neat. For those who don't know, you can run Java classes through Oracle as Stored Procedures.
I got this Java method working finally, but it's very slow. It grinds to a snails pace when trying to handle the fully joined resultset (i.e. 100,000 records of ~6,000 columns comprising of ~60,000 characters per record) .
My question is simply, what, if anything, can be done to make this thing outperform my initial method. I suspect it might not be possible.
In any event, my program logic is pretty simple. It uses JDBC to grab a resultset via a SQL statement that's passed in (which is really just select * from all the tables). It then iterates each record. Within each record, it iterates each column. Our control fields are all numerics and those get stripped out when iterating the resultset (i.e. if the column type <> CHAR/VARCHAR, go to the next field). NULL fields get padded with blanks, such that a null field in a column width of 10 would become 10 blanks. This is necessary to keep everything fixed length as intended.
Beyond that, there really isn't much logic. Any ideas?
The only thing I've come up with would be to replicate the Oracle tables and then basically update every single column programmatically to replace nulls with padded blanks (so I wouldn't have to iterate/process so much in Java) but I don't know if I'm going to get any performance increase.
|
On October 23 2012 12:59 Crazyeyes wrote: Do you guys know of any... portable solutions? The computers at school have PuTTY and I've used that before but it's sort of shitty to code on. Something like 'buy a laptop' or 'always code at home' isn't exactly helpful. ^.^
Any ideas/input is appreciated! So you are telling me you are writing code on a ssh client ? Yes it has an xterm terminal inside but that's because it's more convenient that bringing up the correct terminal in the machine you are using. To translate that into words, you are using a cryptography bridging application to write a code.
Are you in front of the machine when you are using the program ? Or do you access it from your personal computer at home ?
I'll be more than happy to give you a few sentences to shout out to the person who thought teaching people to write code with PuTTY would be a good idea.
|
On October 24 2012 12:14 Azerbaijan wrote: So I am just starting my programming classes for my college major and I have an intro to programming teacher who does not know the difference between java and javascript. How concerned should I be? Most likely your teacher is not a software engineer, but just someone who uses computers for particular needs; perhaps a researcher in the physical/mathematical sciences, where web technologies are outside of their neighborhood.
That said, I would be very concerned...
|
On October 25 2012 08:10 Craton wrote:Technologies involved: Oracle 10g Java 1.4.2 Perl Background: + Show Spoiler +I work as a contractor for a government institution (most accurately, my company is a contractor). For the work I do, we receive large data files of real data (i.e. real information about people), which we then use to modify (for testing purposes, i.e. "dirtying" up the data) or to manufacture additional test data. The data is all kept within the same division and on secure servers, so the realness of it is not an issue.
More about the files: These are ASCII files with very large line lengths (biggest so far has been 60,000 characters a line, though there is one more type of file that I believe is worse). Additionally, these are all fixed length and padded with spaces. The meaning of these characters is derived from their position on each line. Example, someone's first name might be found at positions 500 through 550. If it's shifted at all, everything is ruined.
Because these are completely non-normalized flat files, we have over 5,000 "columns" worth of data.
Given the brief span of time these are in our system, we do not make an effort to normalize them, as they go back out the same way as they came in (just with different characters).
Oracle has a column limit of 1,000 per table. Sensible if you have a properly normalized (or even remotely normalized...) database, but this isn't. Our current implementation is basically to make multiple tables (each with ~900 columns) until all the data has been read in. There is a column that maintains the line number of each record that came in, which can then be used to join everything together when it's time to kick it back out.
Amusingly, the UTL_FILE of Oracle that is used to write tables to files has a character limit of 32767 bytes. We were never able to get around this limit, even by breaking things up and trying to do puts (over putline), flushing buffers, manually adding carriage returns, etc). Eventually, we went another route; instead of trying to output all the tables as one file, we output each related table as a separate file and then generate a Perl script which joins them (the server runs on Unix).
This works, but it isn't very elegant. There was a lot of headache involved in even getting this far, including getting permissions from the DBAs and Unix admins.
Hoping to improve on this, I wrote up a Java stored procedure that tries to accomplish the original goal: output everything at once, nice and neat. For those who don't know, you can run Java classes through Oracle as Stored Procedures.
I got this Java method working finally, but it's very slow. It grinds to a snails pace when trying to handle the fully joined resultset (i.e. 100,000 records of ~6,000 columns comprising of ~60,000 characters per record) . My question is simply, what, if anything, can be done to make this thing outperform my initial method. I suspect it might not be possible. In any event, my program logic is pretty simple. It uses JDBC to grab a resultset via a SQL statement that's passed in (which is really just select * from all the tables). It then iterates each record. Within each record, it iterates each column. Our control fields are all numerics and those get stripped out when iterating the resultset (i.e. if the column type <> CHAR/VARCHAR, go to the next field). NULL fields get padded with blanks, such that a null field in a column width of 10 would become 10 blanks. This is necessary to keep everything fixed length as intended. Beyond that, there really isn't much logic. Any ideas? The only thing I've come up with would be to replicate the Oracle tables and then basically update every single column programmatically to replace nulls with padded blanks (so I wouldn't have to iterate/process so much in Java) but I don't know if I'm going to get any performance increase. Cool 
Couple of clarifying questions:
1) What's the overall task you need help on here? I wasn't hugely clear on that by the time I got done reading your blurb. Do you need a better way to do the whole flat file -> X -> flat file computation? Or do you simply need the flat file -> X format (settled on oracle?), and then someone else is handling the later parts? Or are you doing only X -> flat file, where something else is handling the first part? How much of the existing implementation can you change? 2) (The relevance of this depends on the answer to #1, so feel free to ignore if not applicable) Can you use technologies other than the ones listed at the start?
~60GiB (100k records * 60k bytes / record) is really not much data. Can you just throw more hardware at the problem (assuming we clear up ? If you can use other technologies, I'd honestly just say throw it into AWS.
3) What state is necessary to know what computations you need to do on a given row? (i.e. is each row independent, or do you need to do operations on a single row that depend on other rows? If so, what rows?)
4) What state is necessary to know what computations you need to do within a single row? (dependent on other entries? if so, which ones?)
And finally, having been previously forced to adhere to strange data formats for the gov't, my condolences.
On October 24 2012 12:14 Azerbaijan wrote: So I am just starting my programming classes for my college major and I have an intro to programming teacher who does not know the difference between java and javascript. How concerned should I be? It's intro to programming. All that really matters is whether or not your prof is enthusiastic enough to get you hooked. You can sort everything else out later.
|
I wonder if anyone can help me, im running win7 enterprice and i want to make a logonscript, I have no idea how to do that thou.
The scipt needs to check if there is a networkdrive called "z:/somthingsomthing" else make it. I want it to apear in the "computer" folder as a normal folder to click on and save stuff"" is this posible and if so how to get started. and i know i suck at english but i did my best
|
On October 25 2012 07:11 JeanLuc wrote:Show nested quote +On October 24 2012 12:14 Azerbaijan wrote: So I am just starting my programming classes for my college major and I have an intro to programming teacher who does not know the difference between java and javascript. How concerned should I be? Mind sharing some more details? What exactly did they say re: java and javascript that let you reach that conclusion?
She was asking students about previous programming experience. I mentioned that I had been teaching myself C for a few months but was interesting in learning an interpreted language like javascript. She says "Java is just a subscript of C", I say "Well I suppose that is true in a sense but I'm talking about javascript not java"; She just gave me a blank look I tried explaining the distinction further but nothing she said indicated she knew what I was talking about. I found it extremely disconcerting.
It's intro to programming. All that really matters is whether or not your prof is enthusiastic enough to get you hooked. You can sort everything else out later.
I got myself hooked using this:
![[image loading]](http://upload.wikimedia.org/wikipedia/en/thumb/5/5e/The_C_Programming_Language_cover.svg/220px-The_C_Programming_Language_cover.svg.png)
This class is actually killing my motivation to keep learning this stuff. I've started looking at other schools.
|
|
|
|