Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
hayden.
Sep 11, 2007

here's a goat on a pig or something
I know JavaScript and PHP somewhat well, enough to make some simple AJAX web apps. I want to add an ability for people to log in, though, and instead of building it from the ground up I figured there exists a framework out there already to make it easier. I looked at CodeIgniter and Laravel and didn't see any obvious mentions of having a login module or something. Do I need to use Django or Rails for this kind of thing?

Adbot
ADBOT LOVES YOU

hayden.
Sep 11, 2007

here's a goat on a pig or something
Thanks guys. I feel so primitive doing everything by hand and some jQuery. I have a lot to learn.

hayden.
Sep 11, 2007

here's a goat on a pig or something
I'm converting a simple app I have to Codeigniter and a MVC structure is all new to me. I'm trying to figure out how to best structure this app.

It's a pretty simple to-do list that uses the nestedSortable jQuery plugin. My PHP queries/prints all the root level items, and whenever it runs into a folder it also prints all of the items within the folder.

My question stems from the contents of the folder needing to be within <ol> tags. Is this how I should approach printing a folder (within a controller)?

$this->load->view('templates/folderStart.php', $item); //has <ol> tag
$this->print_folder_items($whatever);
$this->load->view('templates/folderEnd.php', $item); //has </ol> tag

Just seems kind of messy.

hayden. fucked around with this message at 22:46 on Jun 27, 2013

hayden.
Sep 11, 2007

here's a goat on a pig or something
I'm using codeigniter for a simple taks list app. It does some AJAX stuff, too. Is the correct way to implement AJAX to somehow tie it into the MVC structure, or is it okay to just have JavaScript calling a PHP file somewhere? It's difficult to Google the answer to this.

hayden.
Sep 11, 2007

here's a goat on a pig or something
Another CodeIgniter question. It's a simple to-do list app, and I have pages for viewing tasks, editing a task, and creating a task.

Is it acceptable practice to have each of these pages have their own function within the controller for displaying them? They each require somewhat unique coding, and for example the view page has no need for all code used in forms on the editing and creating pages.

I know the tutorial shows just having a single "view" function for displaying multiple pages regardless of the content, but all those pages are pretty much the same format and nothing unique about them other than the content being displayed.

hayden. fucked around with this message at 00:24 on Jul 18, 2013

hayden.
Sep 11, 2007

here's a goat on a pig or something
Thanks a bunch Lumpy. I'll give that book a look. I will probably need clarification soon but I'm too burned out at the moment to keep thinking about it.

hayden.
Sep 11, 2007

here's a goat on a pig or something
I'm trying to use JavaScript to pull in reddit submissions.

Using this works fine and pulls in the submissions, but it responds as though no one is logged in and uses the default subreddits:

code:
$.getJSON("http://www.reddit.com/hot/.json?jsonp=?", function(data) {
	$.each(data.data.children, function(i,item){
		$('#images').append(item.data.title + '<br><br>');
	});
});
If I just point my browser to http://www.reddit.com/hot/.json then it responds but including my default subreddits. When my code above runs (it's on a remote server, not my local machine) does it request it through the server it's hosted on or through my own connection?

I have almost no idea what I'm doing. Anyone have suggestions in how to make my code above pull in items as though I'm logged in? I've been looking around trying to figure out how to use the reddit API with JavaScript and have found nothing. I would guess logging in through the API first would fix it? No idea.

hayden. fucked around with this message at 19:39 on Jul 26, 2013

hayden.
Sep 11, 2007

here's a goat on a pig or something

tarepanda posted:

There's no way something run on a remote server would use your connection.

JavaScript running in a browser after a page has loaded isn't running on the remote server is it?

hayden.
Sep 11, 2007

here's a goat on a pig or something
Is there an elegant way to put space (margin) between rows in the new Bootstrap 3? Using margin-top etc doesn't seem to work. Right now I just have an empty row to take up space.

edit: I think I was just doing it wrong, I think it's working now

hayden. fucked around with this message at 02:09 on Aug 1, 2013

hayden.
Sep 11, 2007

here's a goat on a pig or something

Boosh! posted:

I started to implement this today with mobile-first development in mind.

Which brings me to this question regarding responsive development: How would you handle content images that you do not want to be loaded on mobile? We made this hacky jQuery function that replaces the src attribute of the IMG tag for mobile devices. I was thinking that there must be something a bit more elegant. What's the best practice for this?

I'm a total amateur but my approach would be to use use a mobile first approach like Bootstrap 3 does and use jQuery to only load the images if it's non-mobile. With your method, wouldn't it possibly start to download the images despite not being displayed?

hayden.
Sep 11, 2007

here's a goat on a pig or something
There's that and also you're one of those websites I hate and leave because you require JS to load images (I use NotScripts). Can't you do this in the PHP or whatever backend you're using?

hayden.
Sep 11, 2007

here's a goat on a pig or something
I'm making a sort of Harvest Moon game in HTML/Canvas and eventually want it to be multiplayer. In the meantime I want to be able to store map data (it's a tile structure). I want to be able to save and load this map data across multiple computers because I do dev work on three separate PCs, so that means the localstorage option is out doesn't it?

Another idea I had was using AJAX to a PHP page to get the data out of a MySQL database, but I am using GitHub to host my project and I'm not sure of an elegant way to have the database connection info not publicly available. This also has the downside of having to do a SQL query for data every single time a player needs it and it seems like that'd be really slow/resource intensive if there were a lot of people playing. This might be okay though because I don't really need real-time updating with a harvest moon like game, there can be a few second lag between updates and not really be a big deal.

The other option is using websockets or whatever to connect to a node.js server, but I'm only somewhat familiar with node and that'd be the most time consuming option and again run into the problem of storing database login/password in a file (to connect to a remote SQL database) on GitHub.

I also saw some possible options of having a local data storage solution with node.js, like maybe redis or a node package that stores data locally in JSON. That way the data would sync on GitHub.

I'm also concerned about the future of node because I know the lead guy left recently.

Can someone tell me what some good options are here?

hayden. fucked around with this message at 07:13 on Sep 3, 2014

hayden.
Sep 11, 2007

here's a goat on a pig or something
edit: nevermind, have a cute kitten

hayden. fucked around with this message at 05:29 on Jan 13, 2015

hayden.
Sep 11, 2007

here's a goat on a pig or something
I use PHP in a procedural fashion for all my projects because my goal is to "just make it work" and not really caring whether it's a beautiful example of coding craftsmanship. I am self taught and have only had a few classes of formal programming education, so doing it in an object oriented style isn't really natural for me.

If I was ever interested in using PHP professionally, would I need to change my style to properly use object oriented principles? Or is it acceptable with PHP, even in professional environments, to be procedural?

hayden.
Sep 11, 2007

here's a goat on a pig or something
I mean, I'm not writing operating systems or anything, but I've made sites with functionality similar to reddit, or ecommerce sites with shopping carts/checking out, and things of similar complexity and have never hated myself. I'm sure the code is terrible and my functions.php file is rather large and unorganized, but it's manageable. Worth noting I'm not selling my services/code, this is all just for my own projects.

hayden.
Sep 11, 2007

here's a goat on a pig or something

v1nce posted:

Come to the PHP thread, ask questions, drop us code samples and ask us how we would do it with OO. We're glad to help you not suck at the thing you like doing.

Hey man, thanks for your post, I know it was a lot of effort and it was helpful. I didn't see the PHP thread so thanks for the link. I'll try to convert some of my code to OO and post for feedback - thanks!

hayden.
Sep 11, 2007

here's a goat on a pig or something
I have a site I put together today for people to share game save files.

Here's an example file:

http://besiegedownloads.com/uploads/54d8027ee1979Bomber.bsg

Is there an easy way to force this to download when you click it, rather than showing in the browser? It's on a shared hosting account so I am not sure I can use an Apache solution I found (only have "Apache Handlers" option in cPanel).

Do I need to point to a PHP page that then has proper headers and then have it read the game save file? Or is there an easier way?

hayden.
Sep 11, 2007

here's a goat on a pig or something
Placed the htaccess in both root and upload directory with no luck (still there, you can test for yourself). I saw someone else say they tried that on stackoverflow without success so I skipped that step.

Random garbage did in fact lead to a 500 error.

Thanks a ton for the help, let me know if you can think of something else to try :)

edit: this is sweet, adding "download" to your anchor tag forces this. That helps for on-site links, but would still be very helpful for links on other sites to download correctly too.

edit2: Seems to work now, I changed it to "ForceType" then back to what it was, and suddenly it's working. Not sure why. Of course IE still doesn't save properly.

hayden. fucked around with this message at 03:29 on Feb 9, 2015

hayden.
Sep 11, 2007

here's a goat on a pig or something
Whenever I go to my site, it loads completely but the favicon in my browser remains the spinning circle like it's still loading. It also makes my browser much slower and the page is laggy. I'm not sure what's going on, anyone got feedback?

http://www.besiegedownloads.com/

The timeline in Chrome shows it takes about 3 seconds to long, but doesn't show anything going on after that. I know part of the slowness is that I have huge images, I'm working on the PHP to auto-size the images people upload.

Also, when you google "besiege downloads", it links to a random page on my site that has no content. What's up with that?

hayden. fucked around with this message at 05:15 on Feb 14, 2015

hayden.
Sep 11, 2007

here's a goat on a pig or something
It also probably doesn't help that my test site, on a different domain, somehow got a couple users instead of my live site. Which means Google probably indexed the test site too, and was like "welp this is identical". No idea how people managed to find it, I even emailed a guy who used it asking him how he found it and he said "youtube" but I have no referral traffic from Youtube so I don't know man. You'll be happy to learn that as a result of this, I finally made the transition to developing locally (XAMP) instead of doing everything remotely on test domains (which was already an improvement over just doing live updates [lol])

I'm working on the comment system now, so hopefully that will add more unique content to make Google happy. Thanks for the 404 heads up, never realized it mattered much.

Also the site isn't doing the infinite load for me either anymore, not sure what was up.

hayden. fucked around with this message at 07:33 on Feb 14, 2015

hayden.
Sep 11, 2007

here's a goat on a pig or something
In my case I left the analytics code in there, so I assume that's how.

hayden.
Sep 11, 2007

here's a goat on a pig or something
Font Awesome seems to mess up sometimes on my site:



but it's weird because it acts like it completely does not have the font with a few exceptions (the bug, cog, shield, etc) and if I just move my cursor over the error square, the font pops back normal. Any ideas?

hayden. fucked around with this message at 01:30 on Feb 15, 2015

hayden.
Sep 11, 2007

here's a goat on a pig or something
Hovering doesn't do anything other than change the background color the pill. I can't reliably replicate it despite plenty of trying. It also seems to happen more on my local copy running on XAMP.



If I uncheck the "font" attribute in this screenshot and recheck it, it also fixes the problem (for everything on the page of that class).

hayden. fucked around with this message at 03:23 on Feb 15, 2015

hayden.
Sep 11, 2007

here's a goat on a pig or something
http://jsfiddle.net/oasey9er/1/

Can anyone tell me why Firefox is not vertically aligning the thumbnail correctly, but Chrome (and IE) is doing it fine?

hayden.
Sep 11, 2007

here's a goat on a pig or something
Thanks a bunch, I forgot that trick existed.

hayden.
Sep 11, 2007

here's a goat on a pig or something
I'm using a JS script called masonry to give my site the same sort of layout as pinterest:

http://www.besiegedownloads.com/

The issue I have is for first time visitors without the images/JS in their cache, it takes a second to load everything and when the masonry JS loads, it resets their scrolling to the top of the page. Can anyone test this for me and let me know if it's as annoying as I am thinking it is? Any suggestions on how to prevent this?

hayden.
Sep 11, 2007

here's a goat on a pig or something

cbirdsong posted:

Same.

You could ditch the separate category pages and just do filtering on click with this fancier version of Masonry: http://isotope.metafizzy.co

It was more an issue when the site first started and there weren't many uploads in the less popular categories, but if I did filtering with JS then it might hide all but maybe one or two items on the page, and I'd need to write some code to make an AJAX call to populate more items. I am not a big fan of this because it makes browsers go slow to have a million items (which would happen with infinite-scrolling like behavior) and it's not good for SEO unless you do a lot more work and this website is sort of a bare-minimum-to-work approach.


Sedro posted:

It's weird that refreshing the page takes me to the top. I looked at the other examples on the Isotope website and they have the same problem.

This is related to my initial concern - when the javascript finishes loading, it forces the site back to the top of the page. The same effect will happen on refreshing the page.

I really nee to move the site off shared hosting though. I have like $100 in credit over at digital ocean, but it seems sort of daunting to launch a LAMP server and transition stuff over. I am not sure how I would make my domain names point to that, would I need to run a name server too I guess? Do I need to worry about keeping the server updated, or other stability issues? I would need to install monitoring software too I guess, to alert me if something blew up?

edit: looks like DO has their own name servers

hayden. fucked around with this message at 01:57 on Mar 1, 2015

hayden.
Sep 11, 2007

here's a goat on a pig or something
edit: nevermind, I think I just need to suck it up and learn linux better

hayden. fucked around with this message at 05:46 on Mar 1, 2015

hayden.
Sep 11, 2007

here's a goat on a pig or something
I like recommending PHP to beginners who just want simple stuff because it's the simplest option in my opinion. Make a text file, call it index.php, and just slap this in there:

code:
<div class="someHTML">
<?php
$query= mysql_query("SELECT * from sometable");

$row = mysql_fetch_assoc($query);

$textValue = $row['someColumn'];

echo $textValue; //prints to browser whatever the field value is
?>
</div>
Aside from a couple more lines to connect to the database before this, that's all there is to it for PHP. No other steps needed. If you want to loop through multiple rows that return from the query it's just one more line.

MySQL database is probably the most popular and works well. It's not 'trendy' and there are faster options but for what she needs it's fine.This is also commonly pared with Linux(Debian or Ubuntu) and Apache. All together this is referred to as a LAMP stack and probably the most common stack in use.

hayden. fucked around with this message at 03:09 on Mar 2, 2015

hayden.
Sep 11, 2007

here's a goat on a pig or something
Yeah my mistake on using mysql_query as the example, brain fart. Thanks.

I think frameworks are ideal but it's a whole lot to take in for someone who barely understands programming. Using objects, understanding MVC, and actually sticking to the best practices of the framework are going to be really difficult.

hayden. fucked around with this message at 16:22 on Mar 2, 2015

hayden.
Sep 11, 2007

here's a goat on a pig or something

quote:

Problem is, I'm a complete newb when it comes to web coding. I have no idea what I should do! I'm teaching myself as I go along. What sort of approach should I start with? Would I use Javascript for this?
The simplest way, if you stick to really strict naming standards for the images, is using JavaScript to just update the image URL of the comic to be whatever it should be based off a data-chapter tag on each of the links.

hayden. fucked around with this message at 16:36 on Mar 2, 2015

hayden.
Sep 11, 2007

here's a goat on a pig or something
.

hayden. fucked around with this message at 02:44 on Mar 5, 2015

hayden.
Sep 11, 2007

here's a goat on a pig or something
Since you're a partner, what happens if you ignore his opinions and just do things the right way? What's he going to do, fire you? Code it himself? Unlikely.

hayden.
Sep 11, 2007

here's a goat on a pig or something
Nothing wrong with it being an image, I think most sites use an image. Just set the alt text appropriately.

hayden.
Sep 11, 2007

here's a goat on a pig or something
Does anyone have a rule of thumb of a range of expected income per 1k page views for AdWords? I mean I know it can vary a ton, but any range at all would be helpful. Asking out of curiosity for my website where people upload save files for a video game if that helps at all.

hayden.
Sep 11, 2007

here's a goat on a pig or something
I checked their website now and it essentially doesn't load at all without javascript. lol like i'm gonna trust a site like that with JS.

hayden.
Sep 11, 2007

here's a goat on a pig or something
I think you might misunderstand what full-stack means. It's typically something LAMP, which are all things a back-end developer would be familiar with. A strictly front-end developer is not really going to have a "stack", at least in the traditional sense. A front-end developer doesn't really know to use anything in a back-end stack.

The structure of the team really depends on the company and the nature of the site (are you building the site for the company for the company's clients?).

Who decides what the website should be like? If it's a site for the company, this will be decided by whoever is calling the shots. If it's a small company, probably the executive team. Otherwise the client will be saying what they want. You will often have someone in a role called something like a business analyst - this person translates the requirements of the client (or executive staff, or whomever) and creates a technical specification detailing how it will be implemented using the skills and resources available. The project manager will, with the help of the BA, set timelines. The project manager also assign tasks, communicates and facilitates updates/changes/requirements with the client/stakeholder. The project manager also tracks progress and communicates that to everyone.

In short, there is usually a project manager that coordinates everyone's work. However, at the start, the coordination is defined by someone like a business analyst. The PM just makes sure it is carried out correctly.

hayden.
Sep 11, 2007

here's a goat on a pig or something
So I moved from shared hosting to a DigitalOcean VPS. A little annoyed because it's been 24 hours and the DNS still isn't updated for like 5% of visitors, notably my desktop PC refuses to update and I've tried all the regular options for refreshing my DNS without any luck.

Anyway, I'm using the smallest droplet size right now and it seems to be working fine. It loads quickly for me, and using a benchmarker online it's depressingly slightly slower than my shared hosting was.

How do I know when it's time to upgrade to a larger droplet size? It's biggest limiter I assume is going to be RAM usage, and it's currently using like 80-90% all the time, but I don't know if that means anything because Windows will use excess RAM it doesn't strictly need. It's just a LAMP website with maybe 5k unique visitors a day, though it's a bit image heavy.

hayden.
Sep 11, 2007

here's a goat on a pig or something
I live in Portland, OR (so cost of living is maybe a little higher than average) and my first "web development" job I got hired at 58k. I put web developer in quotes because it was pretty basic stuff and I had zero professional dev experience going into that job. The most senior person who was there who had the same job as me had been there maybe 2 years and she made 75k and knew even less than I did about web development (but knew the company systems a lot better). So as usual, your mileage may vary.

I credit at least 5k and as much as 10k of that salary to this article: http://www.kalzumeus.com/2012/01/23/salary-negotiation/

Adbot
ADBOT LOVES YOU

hayden.
Sep 11, 2007

here's a goat on a pig or something
If my TTFB is really slow on my PHP application, but if I upload a test.php file that just echos "hi" and it's TTFB is always really fast, does that definitively mean there's something wrong with my code and not my hosting? It's Digital Ocean, if it matters.

Mostly confusing because 70% of the time TTFB is really quick refreshing my main page, and the other 30% it's 3-9 seconds.

edit: mystery solved I think - I had a query run on almost every page that took 3+ seconds. The would sometimes be quick I assume because the query/results were cached.

hayden. fucked around with this message at 05:49 on Apr 26, 2015

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply