|
Boris Galerkin posted:That ' mark completely messes up my syntax highlighting. Everything changes color, possibly because it's waiting for a closing ' mark. I'm using the Solarized theme if this makes any difference. Set fortran_dialect so the syntax highlighter knows you're using Fortran77.
|
# ? Jul 28, 2012 01:27 |
|
|
# ? Jun 5, 2024 01:28 |
|
The Collector posted:I started learning sql a while back by using this site http://sqlzoo.net/ (among other things). I had to stop for a bit, and I'm starting to pick it up again. Are there any similar/better sites out there or is this my best bet? It is, in fact, the wrong thread (although there's probably some people in here who can help you regardless). You probably want the SQL Megathread.
|
# ? Jul 28, 2012 01:33 |
|
I hope this is the right thread for this: I'm building a small website and I'd like to display 6 random images from a list of images on every page reload. Of those 6 displayed images, there shouldn't be any duplicates though. Does anybody have a JavaScript code for that? All I can find online is code for one random image and I've never done a JS programming myself. EDIT: V V V Thanks a lot guys Das MicroKorg fucked around with this message at 14:08 on Jul 28, 2012 |
# ? Jul 28, 2012 11:14 |
|
FLX posted:I hope this is the right thread for this: I'm building a small website and I'd like to display 6 random images from a list of images on every page reload. Of those 6 displayed images, there shouldn't be any duplicates though. Does anybody have a JavaScript code for that? All I can find online is code for one random image and I've never doen a JS programming myself. I don't have a full code example handy, but it may be helpful to know you can use images.splice(n,1) to remove the n'th element from the list (in-place). So, you can select an element at random, display it, and remove it from the list so it won't be selected again. Repeat until you've displayed as many images as you want. You could also shuffle the entire list* and then just take the first six images from it. * there is no builtin function for this in JS, so you'd have to write one. Don't do it by using sort() with a random comparison function, as some sites will recommend.
|
# ? Jul 28, 2012 13:43 |
|
^^^ drat, beaten! Anyway, see below for my suggestion of a shuffling algorithm. It's trivial to implement in any language and the wikipedia article includes both pseudocode and a couple of language specific examples. FLX posted:I hope this is the right thread for this: I'm building a small website and I'd like to display 6 random images from a list of images on every page reload. Of those 6 displayed images, there shouldn't be any duplicates though. Does anybody have a JavaScript code for that? All I can find online is code for one random image and I've never doen a JS programming myself. If you don't want duplicates then, as you've recognised, you can't just generate 6 random choices. One way to approach it is to rephrase the problem as taking the first 6 images from a randomly ordered set. This could be achieved by performing a Fisher-Yates shuffle on your list of images and then selecting the first 6 results from the resulting shuffled list. If you don't want to be performing the shuffle every time you reload the page (for example, if you have a very large list of images) you could store the shuffled list some manner and keep an offset into it which is incremented by 6 whenever the page is loaded. When offset + 6 > listSize, you reshuffle the list, store it again and set the offset back to zero. rolleyes fucked around with this message at 14:03 on Jul 28, 2012 |
# ? Jul 28, 2012 13:59 |
|
rolleyes posted:If you don't want duplicates then, as you've recognised, you can't just generate 6 random choices. One way to approach it is to rephrase the problem as taking the first 6 images from a randomly ordered set. This could be achieved by performing a Fisher-Yates shuffle on your list of images and then selecting the first 6 results from the resulting shuffled list. Do this. rolleyes posted:If you don't want to be performing the shuffle every time you reload the page (for example, if you have a very large list of images) you could store the shuffled list some manner and keep an offset into it which is incremented by 6 whenever the page is loaded. When offset + 6 > listSize, you reshuffle the list, store it again and set the offset back to zero. Don't do this. Shuffling a list is laughably easy work for a browser.
|
# ? Jul 28, 2012 21:16 |
|
KARMA! posted:Don't do this. Shuffling a list is laughably easy work for a browser. I more meant from a data transmission standpoint rather than it being processor intensive. If you've got a large image list you could be transferring tens of kb every time the page loads, whereas if you database your shuffled list and keep selecting the next 6 results you've probably cut it down to less than 1kb. I doubt his website is going to be dealing with enough visitors for that to be a concern, but it's a valid bandwidth saving technique for high-traffic situations.
|
# ? Jul 28, 2012 23:54 |
|
I'm starting a computer science course later this year and I was wondering, since I am wet behind the ears on programming, what stuff I could read up on to begin with? A list of other general stuff related to the course would be swell.
|
# ? Jul 29, 2012 15:14 |
|
Rigged Death Trap posted:I'm starting a computer science course later this year and I was wondering, since I am wet behind the ears on programming, what stuff I could read up on to begin with? Less reading, more coding. Make Python programs.
|
# ? Jul 29, 2012 15:24 |
|
shrughes posted:Less reading, more coding. Seconded.
|
# ? Jul 29, 2012 15:29 |
|
Rigged Death Trap posted:I'm starting a computer science course later this year and I was wondering, since I am wet behind the ears on programming, what stuff I could read up on to begin with? If you want a leg up on your course, it probably wouldn't hurt to read up on a few sorting algorithms. Try quick sort and bogo sort and please skip bubble sort. vvv If you want real-time, free is mutually exclusive to good. Actually free+good basically doesn't exist for market data at all.. leper khan fucked around with this message at 20:58 on Jul 29, 2012 |
# ? Jul 29, 2012 15:38 |
|
Anyone know of a good (free) API for stock data (quotes, prices, high/low), or even better one that would also let me get chart data, or enough historical data to make my own charts.
|
# ? Jul 29, 2012 20:02 |
|
I presume you actually mean service, as even both the Bloomberg and Reuters API's are actually free now. You can get delayed data free: free meaning without Exchange costs. The pricing is only network and management costs. I do actually know how much MSN and & co. are spending per month for their data, it is not insignificant.
|
# ? Jul 30, 2012 00:35 |
|
MrMoo posted:I presume you actually mean service, as even both the Bloomberg and Reuters API's are actually free now. Basically, I need a simple way to grab the basic info for some stocks. (Last Trade Price, Bid, Ask, Open, Close, etc.), as well as hopefully some historical data or a chart service. Also needs to support foreign markets (in particular Toronto Stock Exchange)
|
# ? Jul 30, 2012 00:45 |
|
Rigged Death Trap posted:I'm starting a computer science course later this year and I was wondering, since I am wet behind the ears on programming, what stuff I could read up on to begin with? Python the Hard Way. Get comfortable with it. Followed by SICP if you want to challenge yourself in the long term.
|
# ? Jul 30, 2012 01:12 |
|
A Computer Science course I'll be taking in the fall is using Ada '95. This might sound stupid, but, I'm not sure where to find a (Compiler? IDE?) to write and run programs in this language. The links on my school's website are all dead, similar to the websites I've tried on Google. What should I do?
|
# ? Aug 1, 2012 01:26 |
|
Nighttheii posted:A Computer Science course I'll be taking in the fall is using Ada '95. This might sound stupid, but, I'm not sure where to find a (Compiler? IDE?) to write and run programs in this language. That's an interesting choice of language. Anyway, this looks like a good place to start.
|
# ? Aug 1, 2012 01:30 |
|
ultrafilter posted:That's an interesting choice of language. Anyway, this looks like a good place to start. I thought all the links on this site were dead, but the one mirror link for NYU works. I guess I need to click more thoroughly. Thanks!
|
# ? Aug 1, 2012 01:42 |
|
Also, if you're on linux, debian (and probably other distros as well) has an ada compiler in the repositories. Might also want to tell the prof/TA/IT/whoever that the course website is busted.
|
# ? Aug 1, 2012 01:44 |
|
Does this help? http://en.wikibooks.org/wiki/Ada_Programming/Installing
|
# ? Aug 1, 2012 02:39 |
|
It does, Thank you!
|
# ? Aug 1, 2012 05:11 |
|
This also sounds kinda interesting~ http://blog.spacesocket.com/2012/07/23/learning-ada/
|
# ? Aug 1, 2012 18:07 |
|
Was reading about the pop (mail) library python has here and came across this line in the example:code:
Ahh duh a list is the return value. sorry, been a while. Thanks! VVV Feral Integral fucked around with this message at 04:55 on Aug 2, 2012 |
# ? Aug 2, 2012 04:08 |
|
It's referencing the second item in M.list().
|
# ? Aug 2, 2012 04:39 |
|
Feral Integral posted:Was reading about the pop (mail) library python has here and came across this line in the example: M.list(), per the manual, returns a 3-tuple. The [1] is an index into the tuple, accessing the second element in it (tuples, like all indexed data structures in python, are 0-indexed).
|
# ? Aug 2, 2012 04:56 |
|
Nighttheii posted:A Computer Science course I'll be taking in the fall is using Ada '95. This might sound stupid, but, I'm not sure where to find a (Compiler? IDE?) to write and run programs in this language. Ada-for-school buddy. It was recommended that we use AdaGIDE as an IDE on Windows (after installing GNAT) but I ended up just ssh'ing into our campus's Ubuntu machine and doing everything that way so I didn't really worry about local configuration. Might be easier if you have that option?
|
# ? Aug 2, 2012 09:51 |
|
More Eclipse related than actually related, but... Well, I hit a key on my keyboard, and now instead of the typical stick-thin marker that's used to mark the place in the document where I'm typing, it's become a big, thick block. It highlights one character, but only affects the characters to the left or right (when I delete something, or add a character). I can't figure out how to undo it, and it's very annoying and disorienting. tia
|
# ? Aug 2, 2012 21:49 |
Sounds like you are in insert mode. Just tap the insert key on your keyboard to get out of it. There should be an indicator in the bottom right of eclipse that says whether you are in insert or overwrite mode.
|
|
# ? Aug 2, 2012 21:53 |
|
When you use POST as a html form submission method, what does the submitted document look like? Say your html page is like code:
|
# ? Aug 2, 2012 23:06 |
|
I guess it's more a question about programming structure, but I'm tinkering around in Python with a roguelike module (libtcod) mainly to learn the language. As my code's getting bigger I'm wondering whether it is important to start moving things to their own modules, and what exactly the benefits of this are. Moreover, is there a clean way to do this? A lot of things (e.g. in handling keyboard input) refer to specific objects that, I suspect, will break a bit if I move them to their own module.
|
# ? Aug 2, 2012 23:21 |
|
stubblyhead posted:When you use POST as a html form submission method, what does the submitted document look like? Say your html page is like Someone will doubtless answer in more detail and/or fix inaccuracies in this, but something like the following: this assumes that the full URL to farts.php is your.subdomain.yoursite.com/path/to/farts.php, and that you entered "Some text about beans" in the text input, and submitted the form by clicking the submit button. code:
I am not sure whether a variable is sent for the submit button, because you didn't give it a name. I'm pretty sure that if you do give it a name, then it sends a variable for the submit button, and its value is the "value" attribute on the button (so in this case, "Toot") Bear in mind that anyone can craft any HTTP request they like (or even craft a malformed request) and send it to your script, so don't rely on requests looking the way they are supposed to look, and also there might be all sorts of different headers like a user-agent header, "accept" headers, etc. etc. Hammerite fucked around with this message at 23:31 on Aug 2, 2012 |
# ? Aug 2, 2012 23:26 |
|
Hammerite posted:Bear in mind that anyone can craft any HTTP request they like (or even craft a malformed request) and send it to your script, so don't rely on requests looking the way they are supposed to look, and also there might be all sorts of different headers like a user-agent header, "accept" headers, etc. etc. Heh, I'm actually the person trying to create this http request, I just don't know how to form the post document. Why they used post instead of get I'm not sure, cause it's just pulling some data from somewhere and displaying it. edit: and that actually worked perfectly. I was basically doing the same thing in my first quick test, but I was posting to the html page instead of the script. stubblyhead fucked around with this message at 23:49 on Aug 2, 2012 |
# ? Aug 2, 2012 23:42 |
|
stubblyhead posted:Heh, I'm actually the person trying to create this http request, I just don't know how to form the post document. Why they used post instead of get I'm not sure, cause it's just pulling some data from somewhere and displaying it. In general you probably want to find a library that will make the request in whatever language you are using. There are a few extra things that need to be handled that a library will probably do for you, it will also make your code simpler.
|
# ? Aug 3, 2012 15:25 |
|
So I've been working on a small encryption project/proof-of-concept and I've hit a snag. Please bear in mind that my previous experience with crypto is extremely limited, so if it looks like I'm doing something dumb here you're probably right. Essentially, I have a ruby script and a nodejs script that do a Diffie-Hellman key exchange. The ruby script sends its public key, and the node script calculates the private key, then MD5 digests the key and uses it to encrypt a piece of text using AES-128-CBC (I've also tried this with SHA256/AES256 with the same results). Node then concatenates the IV and ciphertext, and sends them back in the response. Ruby then decrypts/prints the message. This all works great when I use a 16 character string like '1234567890abcdef' for the IV: code:
code:
code:
|
# ? Aug 3, 2012 21:19 |
|
You have some issues in your code and you probably have some issues in your encryption too, my bet is you aren't actually encrypting more than the first block. Edit: Your problem is that you aren't authenticating your message, and there's a man in the middle on your machine twiddling its bits.
|
# ? Aug 3, 2012 21:36 |
|
shrughes posted:You have some issues in your code and you probably have some issues in your encryption too, my bet is you aren't actually encrypting more than the first block. I'm fully ready to admit that my knowledge here is lacking and I'm more or less learning as I go. Obviously none of this is going anywhere near production. That being said, the output of the encryption and what I get back on the other side from the HTTP response are byte-for-byte identical. Also, if only the first block were being encrypted, I would tend to think the encrypted output would be the same after 16 bytes from run to run, correct?
|
# ? Aug 3, 2012 22:27 |
|
You probably can't be helped unless you show the code.
|
# ? Aug 3, 2012 23:51 |
|
Redhat shell script question! Right now, I conduct audits on a linux machine by doing the following steps
Now, I follow all these steps because I can't figure out how to write an umbrella .SH file that will do these steps for me. I notice that if I am not precisely in the right folder and run the scripts, for example if I am not precicely in /isso/logs_rotated when I run auditprocess.sh, it will blow up. Even if I am in the root \ folder and I manually run ./isso/logs_rotated/auditprocess.sh it still blows up. So, I am pretty newb to shell scripting, but I am failing to google these issues properly. Any tips on how I can take those 4 steps and make them into a single shell script that can be run anywhere? This is what I do by hand now
I have to do that to many machines. I can do it fast, but I think its about time I learn how to really use Shell.
|
# ? Aug 4, 2012 01:22 |
|
shrughes posted:You probably can't be helped unless you show the code. Happy to: Ruby: http://hastebin.com/cunihinuma.rb java script: http://hastebin.com/penolufube.js
|
# ? Aug 4, 2012 01:33 |
|
|
# ? Jun 5, 2024 01:28 |
|
Lamont Cranston posted:Happy to: Oh, it's corrupt differently each time! Here are some outputs I got, except for the first line which is for reference. code:
What if I set the iv to this: code:
Let's look at how CBC works: http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29 You can see that the IV is supposed to get XORed with the output of the block cipher to create the plaintext. However, it works correctly for future blocks because the IV only affects the output of the first block, on the Ruby side. (It affected the values of the ciphertext blocks on the JS side.) So I'm guessing the Ruby OpenSSL library is loving things up, maybe it depends on what Ruby version you're using.
|
# ? Aug 5, 2012 01:44 |