• Web Dev Questions That Don't Need Their Own Thread v4
    5,001 replies, posted
[QUOTE=Svenskunganka;46764871][URL="http://gionkunz.github.io/chartist-js/"]ChartistJS[/URL] any day[/QUOTE] If I use that one, how will I make the series not "connected" to each other? In my project, USD and EUR aren't supposed to be compared, but it's rather going to see the change over time. (Dual y-axis ?)
[QUOTE=BoXHocK;46764960]If I use that one, how will I make the series not "connected" to each other? In my project, USD and EUR aren't supposed to be compared, but it's rather going to see the change over time. (Dual y-axis ?)[/QUOTE] There really is no limit to what you can do with CartistJS. Toy around with it for a while and you'll get the result you want.
[QUOTE=Svenskunganka;46765839]There really is no limit to what you can do with CartistJS. Toy around with it for a while and you'll get the result you want.[/QUOTE] Takk så mye. I'll see what I can do :)
Most well made website have URLs like these [CODE]website.com/module/option/1/[/CODE] instead of regular arguments like [CODE]website.com/?module=XXX&page=1[/CODE] and I was wondering how it was called so I could learn how to do it.
if you're using apache, look into [url=http://httpd.apache.org/docs/2.0/misc/rewriteguide.html]mod_rewrite[/url]
[url=https://github.com/chriso/klein.php]klein.php[/url] is pretty decent.
[QUOTE=_FR_Starfox64;46778750]Most well made website have URLs like these [CODE]website.com/module/option/1/[/CODE] instead of regular arguments like [CODE]website.com/?module=XXX&page=1[/CODE] and I was wondering how it was called so I could learn how to do it.[/QUOTE] mod_rewrite if using Apache and try_files if using Nginx. I really like the code in [URL="https://github.com/NoahBuscher/Macaw"]Macaw[/URL] - simple and just works. Klein as JohnWallace said is pretty good too though. Just Google URL Rewrite and you will find more detailed explanations. But basically you just convert the URI into a string that get's handled through the index. In PHP: [B]domain.com/some/page/here[/B] [code] <?php $uri = $_SERVER['REQUEST_URI']; var_dump($uri); // string(/some/page/here) [/code] As I said, you will probably understand it more if you look at some code like Klein or Macaw.
I need images for a gallery. The gallery images needs to be a specific size. Let's say 300x300 (pixels). Some of my pictures are 500x1500 and some others are 1500x500. Therefore I need to resize them to be exactly 300x300, but I still need them to be in proportion. Does anyone have a program / tool that can resize images to an exact size and then add a background color to it for it to keep its proportion? (Either transparent, white or something) I guess it is the same function as the one some Instagrammers use to create some sort of white frame around the image. We are talking around 300 images, so it would be nice if there is an automatic tool? Anyone's ever heard of one? Thanks ^this, but without Photoshop
[url]http://www.imagemagick.org/[/url] can do that [url]http://www.imagemagick.org/discourse-server/viewtopic.php?t=20846[/url] here's a topic on the subject
So, If I wan't to have different names for methods that essentially do the same thing, how can I compress/simplify/improve this code? As in, the calculation is the same for calculating time dilation and relative mass, so I'm basically writing the same thing over again with different variable names. [CODE]namespace Relativity { public class Special { private const double c = 299792458; public static double LorentzFact(double vel) { return 1/(Math.Sqrt(1 - (Math.Pow(vel, 2) / Math.Pow(c, 2)))); } public static double TimeDial(double vel, double time) { return time * LorentzFact(vel); } public static double LengthCont(double vel, double length) { return length / LorentzFact(vel); } public static double RelMass(double mass, double vel) { return mass * LorentzFact(vel); } } } [/CODE]
[QUOTE=Demx;46795395]So, If I wan't to have different names for methods that essentially do the same thing, how can I compress/simplify/improve this code? As in, the calculation is the same for calculating time dilation and relative mass, so I'm basically writing the same thing over again with different variable names. [CODE]namespace Relativity { public class Special { private const double c = 299792458; public static double LorentzFact(double vel) { return 1/(Math.Sqrt(1 - (Math.Pow(vel, 2) / Math.Pow(c, 2)))); } public static double TimeDial(double vel, double time) { return time * LorentzFact(vel); } public static double LengthCont(double vel, double length) { return length / LorentzFact(vel); } public static double RelMass(double mass, double vel) { return mass * LorentzFact(vel); } } } [/CODE][/QUOTE] It's just 6 lines of code so you shouldn't feel the need to do that, and there's nothing to improve there really. Also, are you sure you are in the right section of the forum?
[QUOTE=Demx;46795395][CODE] public static double TimeDial(double vel, double time) { return time * LorentzFact(vel); } public static double RelMass(double mass, double vel) { return mass * LorentzFact(vel); } [/CODE][/QUOTE] I guess you could remove one of these and rename the other to something generic, but it might not be worth it (just 3 lines)
[QUOTE=Coment;46797014]I guess you could remove one of these and rename the other to something generic, but it might not be worth it (just 3 lines)[/QUOTE] It could probably do some semantic justice some time in the future.
At this point Rasmus Lerdorf is going to get arrested for involuntary manslaughter. Fucking session upload progress... First things first, I'm talking about Ubuntu on a virtual server (with port forwarding, so I can access it on my computer) with php 5.5.9, so version shouldn't be a problem. session.upload_progress.enabled is on (and phpinfo says so), and I can't get it to display the damn upload progress (even on big files where it takes some seconds, so it's not a speed problem). And if it's important for someone, [code] session.upload_progress.cleanup On On session.upload_progress.enabled On On session.upload_progress.freq 1% 1% session.upload_progress.min_freq 1 1 session.upload_progress.name os_fs_progress os_fs_progress session.upload_progress.prefix os_progress_ os_progress_ [/code] Once the user fills the form (where I have religiously put [code]<input type="hidden" name="<?php echo ini_get("session.upload_progress.name"); ?>" value="upload" />[/code] ), I put a javascript function on the submit button to start getting with jQuery progress_bar.php which content is [code]<?php session_start(); var_dump($_SESSION); var_dump($_SESSION[ini_get("session.upload_progress.name")]); [/code] As far as I understand, that whould work, right? Well, the first dump only displays the normal session variables (userid, username, etc etc etc), but the second one doesn't display anything. No json, no percentage, nothing. And at this point I'm clueless, every link somewhat related to upload progress bars is purple, and I can't get this damn simple thing to work. Any ideas on what could be happening
[QUOTE=Coment;46851458]At this point Rasmus Lerdorf is going to get arrested for involuntary manslaughter. Fucking session upload progress... First things first, I'm talking about Ubuntu on a virtual server (with port forwarding, so I can access it on my computer) with php 5.5.9, so version shouldn't be a problem. session.upload_progress.enabled is on (and phpinfo says so), and I can't get it to display the damn upload progress (even on big files where it takes some seconds, so it's not a speed problem). And if it's important for someone, [code] session.upload_progress.cleanup On On session.upload_progress.enabled On On session.upload_progress.freq 1% 1% session.upload_progress.min_freq 1 1 session.upload_progress.name os_fs_progress os_fs_progress session.upload_progress.prefix os_progress_ os_progress_ [/code] Once the user fills the form (where I have religiously put [code]<input type="hidden" name="<?php echo ini_get("session.upload_progress.name"); ?>" value="upload" />[/code] ), I put a javascript function on the submit button to start getting with jQuery progress_bar.php which content is [code]<?php session_start(); var_dump($_SESSION); var_dump($_SESSION[ini_get("session.upload_progress.name")]); [/code] As far as I understand, that whould work, right? Well, the first dump only displays the normal session variables (userid, username, etc etc etc), but the second one doesn't display anything. No json, no percentage, nothing. And at this point I'm clueless, every link somewhat related to upload progress bars is purple, and I can't get this damn simple thing to work. Any ideas on what could be happening[/QUOTE] This is probably due to your web server's buffering settings or running PHP using FastCGI. Double check those two options. [editline]edited[/editline] [URL="http://socket.io/"]Socket.io[/URL] makes this really easy for NodeJS if you want an alternative.
Anyone have any idea what library might be used for the map and the cool glowwy beam things? [url]http://map.ipviking.com/[/url]
[QUOTE=Richy19;46856380]Anyone have any idea what library might be used for the map and the cool glowwy beam things? [url]http://map.ipviking.com/[/url][/QUOTE] This? [url]http://d3js.org/[/url]
[url]https://josm.uk[/url] Working without giving a security error? Also, if you go to my site via normal http:// does it just show the default apache page? Cheers.
Not the best with arrays, I need help with this, here's the array: [code] var attackers = [ pln1, pln2, pln3, pln4, pln5, pln6, ]; [/code] Now, I need this to clean this up: [code] if (37 in keysDown) { // Player holding left if (!(hero.x <= 15)){ hero.x -= hero.speed * modifier; pln1.x += hero.speed * modifier; pln2.x += hero.speed * modifier; pln3.x += hero.speed * modifier; pln4.x += hero.speed * modifier; pln5.x += hero.speed * modifier; pln6.x += hero.speed * modifier; posx -= 1;//this is a variable, not a mistype } else { pln1.x += hero.speed * modifier; pln2.x += hero.speed * modifier; pln3.x += hero.speed * modifier; pln4.x += hero.speed * modifier; pln5.x += hero.speed * modifier; pln6.x += hero.speed * modifier; posx -= 1;//this is a variable, not a mistype } if(disabled == false){heroImage.src = "images/pll.png";} } if (39 in keysDown) { // Player holding right if (!(hero.x >= 1000)){ hero.x += hero.speed * modifier; pln1.x -= hero.speed * modifier; pln2.x -= hero.speed * modifier; pln3.x -= hero.speed * modifier; pln4.x -= hero.speed * modifier; pln5.x -= hero.speed * modifier; pln6.x -= hero.speed * modifier; posx += 1;//this is a variable, not a mistype } else { pln1.x -= hero.speed * modifier; pln2.x -= hero.speed * modifier; pln3.x -= hero.speed * modifier; pln4.x -= hero.speed * modifier; pln5.x -= hero.speed * modifier; pln6.x -= hero.speed * modifier; posx += 1;//this is a variable, not a mistype } if(disabled == false){heroImage.src = "images/plr.png";} } if (38 in keysDown) { // Player holding up if (!(hero.y <= 30)){ hero.y -= hero.speed * modifier; pln1.y += hero.speed * modifier; pln2.y += hero.speed * modifier; pln3.y += hero.speed * modifier; pln4.y += hero.speed * modifier; pln5.y += hero.speed * modifier; pln6.y += hero.speed * modifier; posy += 1; } else { pln1.y += hero.speed * modifier; pln2.y += hero.speed * modifier; pln3.y += hero.speed * modifier; pln4.y += hero.speed * modifier; pln5.y += hero.speed * modifier; pln6.y += hero.speed * modifier; gem.y += hero.speed * modifier; posy += 1;//this is a variable, not a mistype } } if (40 in keysDown) { // Player holding down if (!(hero.y >= 450)){ hero.y += hero.speed * modifier; pln1.y -= hero.speed * modifier; pln2.y -= hero.speed * modifier; pln3.y -= hero.speed * modifier; pln4.y -= hero.speed * modifier; pln5.y -= hero.speed * modifier; pln6.y -= hero.speed * modifier; posy -= 1;//this is a variable, not a mistype } else { pln1.y -= hero.speed * modifier; pln2.y -= hero.speed * modifier; pln3.y -= hero.speed * modifier; pln4.y -= hero.speed * modifier; pln5.y -= hero.speed * modifier; pln6.y -= hero.speed * modifier; posy -= 1; //this is a variable, not a mistype } } } [/code] I'd like to only have one line that calls everything in the array (pln), I've tried every thing, no results.
[QUOTE=somedev;46895295]Not the best with arrays, I need help with this, here's the array: ~~~ I'd like to only have one line that calls everything in the array (pln), I've tried every thing, no results.[/QUOTE] Not sure what you mean but don't you mean a for loop to go through all the elements in the array? Like this: [code] for (var attacker = 0; attacker < attackers.length; attacker++) { attackers[attacker].x += hero.speed * modifier; } [/code]
[QUOTE=somedev;46895295] [code] if (37 in keysDown) { // Player holding left if (!(hero.x <= 15)){ hero.x -= hero.speed * modifier; pln1.x += hero.speed * modifier; pln2.x += hero.speed * modifier; pln3.x += hero.speed * modifier; pln4.x += hero.speed * modifier; pln5.x += hero.speed * modifier; pln6.x += hero.speed * modifier; posx -= 1;//this is a variable, not a mistype } else { pln1.x += hero.speed * modifier; pln2.x += hero.speed * modifier; pln3.x += hero.speed * modifier; pln4.x += hero.speed * modifier; pln5.x += hero.speed * modifier; pln6.x += hero.speed * modifier; posx -= 1;//this is a variable, not a mistype } if(disabled == false){heroImage.src = "images/pll.png";} } [/code][/QUOTE] Lots of repetition. You only need to calculate "hero.speed * multiplier" once, and then you could loop through the array like Superkipje said. Also you could just remove the "else" part of your if statements and put the loop after that, considering you're doing the calculations for the attackers regardless of the result. Maybe something like this? [code] var move = hero.speed * modifier; // Put this before all the "keysDown" checks so you can always use it if (37 in keysDown) { if (!(hero.x <= 15) { hero.x += move; } for (var attacker = 0; attacker < attackers.length; attacker++) { //attackers move regardless of whether hero moves, no point listing it twice attackers[attacker].x -= move; } posx -= 1; //no point listing this twice either } [/code]
Should somebody contact a mod to get the title renamed to specify web development, or should we make a new thread since this is at 117 pages?
[QUOTE=AndrewPH;46921824]Should somebody contact a mod to get the title renamed to specify web development, or should we make a new thread since this is at 117 pages?[/QUOTE] I believe threads get autolocked at a certain postcount again. It will sort itself out.
What's a good resource place for android/java? I'm writing an app (my first ever, it's a basic calculator) and I got the XML down but the Java code is a bit confusing and hard for me to get around, are there any good resources? (because there's all these things that the device can do and I don't know what or how to use them) [editline]18th January 2015[/editline] is there anything that says 'Public means... Static means... Void means... Global means.. ' it tells you what the main things are and what they mean and what they can do, so I can go off that and use all the different things with the code or am i going abotu this totally wrong [editline]18th January 2015[/editline] also this is my first time doing any real programming the only other real programming i've ever done was lua (and doubtt that even counts that much, it was in computercraft a mod for minecraft) [editline]18th January 2015[/editline] shiiit this is web dev
I know this isn't programming related, but there once was a certain reverse engineering game that was posted in some of the threads (WAYWO to be more exact). It was web based where you had access to a cpu and memory debugger and the goal was to unlock a lock of some kind. Does anyone remember how was it called?
[QUOTE=343N;46958750]What's a good resource place for android/java? I'm writing an app (my first ever, it's a basic calculator) and I got the XML down but the Java code is a bit confusing and hard for me to get around, are there any good resources? (because there's all these things that the device can do and I don't know what or how to use them) [editline]18th January 2015[/editline] is there anything that says 'Public means... Static means... Void means... Global means.. ' it tells you what the main things are and what they mean and what they can do, so I can go off that and use all the different things with the code or am i going abotu this totally wrong [editline]18th January 2015[/editline] also this is my first time doing any real programming the only other real programming i've ever done was lua (and doubtt that even counts that much, it was in computercraft a mod for minecraft) [editline]18th January 2015[/editline] shiiit this is web dev[/QUOTE] Looks like you need to start at the basics. I suggest picking up a book on java and working trough it.
is there a way to make the middle of the letter 'X' stay in the same position even when changing the font size of the x?
Anybody know of a good place to host an API? My one DO server is getting quite a lot of requests, and I had to stop storing statistics in the DB because it took so long time. Basically what I'm looking for is a cheap place to either host, or only get analytics, for my API.
[QUOTE=BoXHocK;46975144]Anybody know of a good place to host an API? My one DO server is getting quite a lot of requests, and I had to stop storing statistics in the DB because it took so long time. Basically what I'm looking for is a cheap place to either host, or only get analytics, for my API.[/QUOTE] A VPS would be a good place to host it on. [URL="https://hosthatch.com/openvz-ssd-vps"]HostHatch[/URL] has 99.97% - 100% uptime and I got a couple of servers with them. The $4 package should bring you all the power you need. What language is the API written in and what kind of DB does it utilize (if any)? [editline]20th January 2015[/editline] [QUOTE=Lizart;46975010]is there a way to make the middle of the letter 'X' stay in the same position even when changing the font size of the x?[/QUOTE] Just add static padding to the top, the result is going to be the same across all devices. Otherwise you might be able to tinker with line-height?
[QUOTE=Svenskunganka;46975264]Just add static padding to the top, the result is going to be the same across all devices. Otherwise you might be able to [B]tinker with line-height[/B]?[/QUOTE] This
Sorry, you need to Log In to post a reply to this thread.