• Web Dev Questions That Don't Need Their Own Thread v4
    5,001 replies, posted
How would I make an array with 10 different random unique numbers gotten from a rand($min,$max);?
[QUOTE=gokiyono;42475783]How would I make an array with 10 different random unique numbers gotten from a rand($min,$max);?[/QUOTE] [CODE] for ($i = 0; $i < 10; ++$i) { if(is_array($rand_numbers)) { array_push($rand_numbers,rand($min,$max)); } else { $rand_numbers = array(rand($min,$max)); }; }[/CODE] [editline]10th October 2013[/editline] Although mt_rand [URL="http://stackoverflow.com/questions/7808021/whats-the-disadvantage-of-mt-rand"]uses a better algorithm[/URL], and I've heard it's faster. I'd use it rather than rand.
[QUOTE=gokiyono;42475783]How would I make an array with 10 different random unique numbers gotten from a rand($min,$max);?[/QUOTE] @Coment I'd do it like this to remove the unnecessary comparison and function calls as well as greater clarity. [CODE] $numbers = array(); for ($i = 0; $i < 10; $i++) { $numbers[] = rand($min,$max); } [/CODE]
But doesn't he say he wants 10 different rands? That way you get 10 random numbers, and they can be the same.
When writing a description about yourself for an about page, would you speak in 3rd person? ie. Graduate at X He Demonstrated great skills in Y... It never really sounded right to me, also sorry its not particularly web devvy
[QUOTE=eternalflamez;42479771]But doesn't he say he wants 10 different rands? That way you get 10 random numbers, and they can be the same.[/QUOTE] Then you'd do that like this. [code] $numbers = array(); while(count($numbers) < 10) { $new = rand($min,$max); if(!in_array($new, $numbers)){ $numbers[] = $new; } } [/code] The problem with this though is that if you are rounding the numbers there must be a difference of 10 between $min and $max for it to not result in an infinite loop. Another thing you can do if you want a sequence of numbers, eg. 0 to 9, in a random order is take a list of numbers then shuffle it. [code] $numbers = array(); for($i = 0; $i < 10; $i++){ $numbers[] = $i; } shuffle($numbers); // it doesn't return the array like you'd expect, it just modifies $numbers [/code]
Anyone recommend a good resource for getting up-to-date with responsive web design, or something grid-based? I haven't properly learnt anything new in a long time (4 years) and all my sites are breaking on mobile, and the really high resolution screens, namely those sexy retina's. And just discovered [url="brackets.io"]brackets.io/[/url]. Actually updates what your doing live to your browser. Only works with chrome atm but I love the idea. Also, without any knowledge of Javascript or whatever, is it possible to implement interesting/advanced features such as RSS feeds, Twitter, Music players etc. into a website?
[QUOTE=whatthe;42483368]Anyone recommend a good resource for getting up-to-date with responsive web design, or something grid-based? I haven't properly learnt anything new in a long time (4 years) and all my sites are breaking on mobile, and the really high resolution screens, namely those sexy retina's. And just discovered [url="brackets.io"]brackets.io/[/url]. Actually updates what your doing live to your browser. Only works with chrome atm but I love the idea. Also, without any knowledge of Javascript or whatever, is it possible to implement interesting/advanced features such as RSS feeds, Twitter, Music players etc. into a website?[/QUOTE] I'm not sure if I understood you correctly but you want your site to be responsive? Possibly a framwork like [URL="http://getbootstrap.com/"]Bootstrap[/URL] can help with that.
Downloading this file results in one line of continuous text. [url]http://www.circleprefect.com/serverparams.cmd[/url] It must be my download method. ?
[QUOTE=Duze;42494466]Downloading this file results in one line of continuous text. [url]http://www.circleprefect.com/serverparams.cmd[/url] It must be my download method. ?[/QUOTE] How are you downloading it and what does the continuous text contain?
Something like: [code]string remoteUri = "http://www.contoso.com/library/homepage/images/"; string fileName = "ms-banner.gif", myStringWebResource = null; using (WebClient myWebClient = new WebClient()) { myStringWebResource = remoteUri + fileName; myWebClient.DownloadFile(myStringWebResource, fileName); }[/code] Using C#, and the file contains all the information as one line.
That's because it's in a pre tag pre tags will make it look like it's got line breaks even though it doesn't the data is unchanged. <pre>set players=8 set worldsize=1 set worldname=Test set password=The set motd=Hey welcome to a test server. set language=1 set email= set forumid=Refuzed</pre>
So, I will have to write it as an html file, then convert it...
- snip -
I'm pretty good with the coding of a website, but I'm absolutely horrible at the design. [url]https://dl.dropboxusercontent.com/u/70126709/Design.png[/url] I'd really appreciate it if I could get some help by making this as great as it could be for the subject
[QUOTE=Xenoyia v2;42497831]I'm pretty good with the coding of a website, but I'm absolutely horrible at the design. [url]https://dl.dropboxusercontent.com/u/70126709/Design.png[/url] I'd really appreciate it if I could get some help by making this as great as it could be for the subject[/QUOTE] I'd try switching to sans-serif fonts.
I'm making this website that is supposed to help people revise for religious studies exams. [IMG]http://vrondakis.com/radiostation.png[/IMG] But I can't figure out how to make this part look nice, everything looks horrible. [IMG]http://vrondakis.com/radiostation2.png[/IMG] Any suggestions?
[QUOTE=Coffeee;42498326]Any suggestions?[/QUOTE] Left align all the text and headings, tighten it up make the text something like 33% of the width and the image 66% or the other way around.
I'm just messing around and trying to figure this stuff out, and I'm having tons of trouble. I'm following a tutorial for Tampermonkey, and the end result works, but when I try to change things to make it yield similar results on another site, it just doesn't work. this is the tutorial i'm following: [url]http://hibbard.eu/tampermonkey-tutorial/[/url] and this is the code it contains: [code] // @name Open CodeProject Links // @namespace http://hibbard.eu/ // @version 0.1 // @description Opens all of the links from the CodeProject newsletter in one go // @match http://www.codeproject.com/script/Mailouts/* // @copyright 2012+, hibbard.eu // @require http://code.jquery.com/jquery-latest.js // ==/UserScript== $(document).ready(function() { var hrefs = new Array(); var elements = $('.headline > a'); elements.each(function() { hrefs.push($(this).attr('href')) }); $('body').append('<input type="button" value="Open Links" id="CP">') $("#CP").css("position", "fixed").css("top", 0).css("left", 0); $('#CP').click(function(){ $.each(hrefs, function(index, value) { setTimeout(function(){ window.open(value, '_blank'); },1000); }); }); }); [/code] I changed it to this: [code] // ==UserScript== // @name welp // @namespace y // @version 0.1 // @description Opens all of the posts from Facepunch // @match http://facepunch.com/* // @copyright y // @require http://code.jquery.com/jquery-latest.js // ==/UserScript== $(document).ready(function() { var hrefs = new Array(); var elements = $('.posthead > a'); elements.each(function() { hrefs.push($(this).attr('href')) }); $('span').append('<input type="button" value="Open Links" id="CP">') $("#CP").css("position", "fixed").css("top", 0).css("left", 0); $('#CP').click(function(){ $.each(hrefs, function(index, value) { setTimeout(function(){ window.open(value, '_blank'); },1000); }); }); }); [/code] so it turns Facepunch into a mess of buttons that are supposed to open every post in a new window, except it doesn't do anything. I'm assuming I'm missing a crucial part that I was supposed to change. I changed where the button shows up which I realize is a terrible way to change it, but that wasn't really what I was after, I was mostly worried about the functionality. I changed which sites the script runs on, as well as the CSS element it looks under, and that's it.
Sublime is annoying me with it's "buy now". Should I?
[QUOTE=Moofy;42511189]Sublime is annoying me with it's "buy now". Should I?[/QUOTE] Of course, it's great software.
Alright I got my problem sorted out. I'm pretty sure it was related to the fact that the button in the example had an id and I made it show up on the page more than once.
[QUOTE=Killervalon;42511569]Of course, it's great software.[/QUOTE] I really want to, but I'm a poor college student :(
[QUOTE=Agent766;42512612]I really want to, but I'm a poor college student :([/QUOTE] There's this free alternative to Sublime called "Vim", which is consequently available on [i]virtually every[/i] installation of a UNIX-like OS. I'm sure this discussion has been done to death, but what does Sublime have that (G)vim doesn't? (Also, vim is technically Charityware, but it isn't rammed down your throat; if you don't have the money to justify it, you won't be looked down upon by the developer or community.)
[QUOTE=Rayjingstorm;42512822] what does Sublime have that (G)vim doesn't?[/QUOTE] An excellently user-friendly UI and a super easy-to-use in-program package management system? Fair warning: I haven't used (G)vim much.
[QUOTE=Rayjingstorm;42512822]There's this free alternative to Sublime called "Vim", which is consequently available on [i]virtually every[/i] installation of a UNIX-like OS. I'm sure this discussion has been done to death, but what does Sublime have that (G)vim doesn't? (Also, vim is technically Charityware, but it isn't rammed down your throat; if you don't have the money to justify it, you won't be looked down upon by the developer or community.)[/QUOTE] Sublime does have a vim mode. I love vim. I'm just saying that I want to support Sublime, but I can't.
[QUOTE=Agent766;42512612]I really want to, but I'm a poor college student :([/QUOTE] Save up cash my friend!
Does anyone know of any good CMS that I can easily integrate into a template? I'm looking to make it easier for my client to edit sites on his own rather than having to contact me about some issue that I'd rather he do himself. Suggestions? Would prefer if they were mostly free and/or don't require a external site ( aka internal hosted ty )
Eh nevermind, I went with [url]http://www.silverstripe.com[/url] From what I've seen so far, it's great and is exactly what I need
What's the best non-shitty ecommerce software? I feel like most solutions are shit.
Sorry, you need to Log In to post a reply to this thread.