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
v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.

Biowarfare posted:

check error.log, probably has nothing to do with file itself

Place your bets now! My money is on an .htaccess mistake.

Adbot
ADBOT LOVES YOU

Impotence
Nov 8, 2010
Lipstick Apathy

v1nce posted:

Place your bets now! My money is on an .htaccess mistake.

Apache 2.4 breaks people that don't know how to use grant/deny, it's really funny too

But yeah probably htaccess typo or something

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

v1nce posted:

Place your bets now! My money is on an .htaccess mistake.

I'm going long shot money on parent directory set to 600 permissions.

hayden.
Sep 11, 2007

here's a goat on a pig or something

Lumpy posted:

Maybe your first result is cached: both are 500 errors for me. What do the Apache logs tell you?

I'm dumb, you're right.


Biowarfare posted:

check error.log, probably has nothing to do with file itself

[Sun Aug 09 11:55:33.736210 2015] [core:alert] [pid 16500] [client] /var/www/laravel/public/test3/.htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration, referer:

I guess I totally brain farted and didn't think 500 errors would show any more info in apache logs, I guess I learned something today! First google result for this error showed I didn't have the Header module enabled. Thanks folks.

Impotence
Nov 8, 2010
Lipstick Apathy

Lumpy posted:

I'm going long shot money on parent directory set to 600 permissions.

this should generally just show a 403 I would think

Data Graham
Dec 28, 2009

📈📊🍪😋



hayden. posted:

I guess I totally brain farted and didn't think 500 errors would show any more info in apache logs, I guess I learned something today! First google result for this error showed I didn't have the Header module enabled. Thanks folks.

Yup. Whether it's an Apache thing or a bug in your back-end web code (Django/Rails/PHP/whatever), a 500 error will always mean "poo poo's breaking on the server and you'll find out exactly what in a relevant log file".

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
Anyone know any solid tutorials for people not that great with PHP, but needs to make a contact form? I know I could use a template, but I'd rather learn myself.

hayden.
Sep 11, 2007

here's a goat on a pig or something
I would suggest Googling and finding one that fits your comfort level, it's going to be hard to know what level tutorial would work best for you. There are a lot of options, just look for a tutorial for forms in general with PHP. Sorry if this isn't super helpful.

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.

Grump posted:

Anyone know any solid tutorials for people not that great with PHP, but needs to make a contact form? I know I could use a template, but I'd rather learn myself.
You might want to cross-post or take this to the PHP thread.

Are you on any framework like Wordpress or Laravel or are you writing classic PHP? What do you want the form to do?
If we know the parameters then we can point you at a reasonable tutorial, and fill in any blanks you don't understand.

EmmyOk
Aug 11, 2013

Grump posted:

Anyone know any solid tutorials for people not that great with PHP, but needs to make a contact form? I know I could use a template, but I'd rather learn myself.

I had to do a registration system recently with no foreknowledge of PHP and I found the following useful. It has stuff on resetting passwords and activation emails so I am sure there is stuff there you can use

http://www.freezecoders.com/2012/11/confirmation-mail-for-user-registration-using-php.html

https://daveismyname.com/login-and-registration-system-with-php-bp

I also used something called PHP-Mailer instead of the way those tutorials sent emails. It's just some files you download and include in your folder and then you get some handy prebaked email functions.

kedo
Nov 27, 2007

Writing PHP mailers by hand isn't very difficult even if you aren't a PHP pro, but it's not a good idea to use one in practice unless the messages themselves don't matter all that much. Email is black magic and there are so many little tricks that you need to be aware of (depending on your web server and mail server and potentially your user's mail server) in order to have emails end up in the right inbox that it's not worth the effort.

If you want to code one as a learning exercise, that's grand. But ultimately you should use something like Gravity Forms if you're on WP, or some stand alone service like Formstack or what have you if you're not. At least then if the messages stop appearing in someone's inbox they're saved in a database somewhere and you're not left holding your dick, saying "well I don't know where they've gone, the form worked for me when I tested it!"

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
I'm hard-coding a personal site because I'm trying to get comfortable with back-end stuff and possibly learn more front-end stuff. I just want to learn some practical stuff.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
Not to dissuade, but practicality is also knowing when to defer hard problems to better equipped services and transactional email is definitely one of those hard problems with very poor feedback loops.

Most professionals who value their time would use Mandrill or something like it to send mail, rather than a local SMTP server which adds yet another thing to administer, debug, and fix if blacklisting occurs.

Maybe do both ways if you'd like to learn.

revmoo
May 25, 2006

#basta
Mandrill kicks rear end. I really like how you can log into the web interface and view a history of emails sent. Really helps with diagnostics.

kedo
Nov 27, 2007

Maluco Marinero posted:

Most professionals who value their time would use Mandrill or something like it to send mail, rather than a local SMTP server which adds yet another thing to administer, debug, and fix if blacklisting occurs.

If you still must code it by hand, do this. PHP mailers are crappy pieces of poo poo code and are not worth your effort to learn. Web servers are dumb when it comes to sending email, and email servers are the neanderthals of the internet. At least Mandrill takes care of all the nonsense work and allows you to focus on creating a useful form.

Here's a real world experience re: why you shouldn't make a PHP mailer:

10 years ago:
Client: kedo! We need a form on our website so people can send us email.
kedo: Okay, presto, here's a form that uses a PHP mailer. Enjoy!

9 years ago:
Client: kedo, gently caress! The form isn't sending email anymore, what the gently caress is going on!?
kedo: Hmmm. [spends five hours trying to figure out what the problem is] I have no idea, but now it's working again... :confused:
Idiot host: lol our mail server was down.

7 years ago:
Client: kedo, omg! Again with the form not working! Do you even know how to code things?!
kedo: Christ... [spends five hours trying to figure out what the problem is] oh, looks like your host updated their mail server and it now requires that emails be authenticated.
Idiot host: lol srry shoulda been reading our super-hidden admin blog where we talk about this poo poo, scrub

4 years ago:
Client: kedo for the love of god! The form is down again. We are losing business because of you. Make it work now!
kedo: loving hell. [spends five hours trying to figure out what the problem is] I have no idea. Did you change anything with your mail settings?
Client: Yes, now we're using Google apps! Are you saying you can't keep up with Google?!
kedo: Give me your admin credentials. [looks in the hidden spam queue no client can ever find] Look, your messages are all getting blacklisted. Let me ask your host.
Idiot host: no we don't want to do work
kedo: What the gently caress is going on? You're blacklisted by spamhaus.
Idiot host: well sum ppl like sending emails, okay a lot of emails, but they pay us good
kedo: Client, you need a new host. Honestly we could use this new service called Mandrill...
Client: That costs money! NO.

3 years ago:
Client: kedoooooooooo!!!!!!! :argh:
Idiot host: lol updated mail server again
kedo: :suicide:


Except less suicide and more me no longer working with the client. But you know, use a PHP mailer if you want.

revmoo
May 25, 2006

#basta
^^ Why I fired all my clients and stopped doing freelance work altogether.

Data Graham
Dec 28, 2009

📈📊🍪😋



That story sounds more like "why to do it yourself".

(And run automated tests)

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
Word. I'll check out Mandrill

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
Does anyone know why this ng-repeat seems to be applying some kind of minute gap between elements generated by the ng-repeat and elements declared before or after it?

This markup:
code:
<div class="text-left center-block shift-buttons">
    <!-- single button -->
    <button ng-if="ctrl.items.off" class="btn btn-default shift-button"><i class="fa fa-check"></i></button>

    <!-- ng-repeat -->
    <button class="btn btn-default shift-button" ng-repeat="item in ctrl.items">{{ item.title }}</button>
</div>
Generates layouts like this (I moved the checkmark button above and below the ng-repeat just to test it out):




Here's the LESS for this particular bit of layout
code:
.shift-buttons {
    display: inline-block;
    width: 165px;

    .shift-button {
        width: 3.5em;
        max-width: 3.5em;
        text-align: center;
        margin: 3px;
    }
}
And here's a working Plunker demonstrating the issue: http://plnkr.co/edit/63Qs7exRLxU7cFVil1BL?p=preview

Depressing Box
Jun 27, 2010

Half-price sideshow.

Karthe posted:

Does anyone know why this ng-repeat seems to be applying some kind of minute gap between elements generated by the ng-repeat and elements declared before or after it?

It's picking up the whitespace in the generated HTML, since inline-block makes elements flow like an inline element, which includes being affected by font rules.

You should be able to fix it by putting:
CSS code:
font-size: 0;
on your .shift-buttons container class, then explicitly setting the font size on the child elements (which I think you already do).

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
I'm on mobile so I can't properly test but I'm very certain that it's just white-space collapsing to a single space in between the check button and the ng-repeat, and it works like this because they're inline-blocks (so around them standard textual rules apply)

You need to do one of:

- render the HTML with absolutely no whitespace between the button elements

- set the container to font-size: 0 and then reset it in shift-button

- use float left on shift buttons to make them position without regard for spacing

IAmKale
Jun 7, 2007

やらないか

Fun Shoe

Depressing Box posted:

It's picking up the whitespace in the generated HTML, since inline-block makes elements flow like an inline element, which includes being affected by font rules.

You should be able to fix it by putting:
CSS code:
font-size: 0;
on your .shift-buttons container class, then explicitly setting the font size on the child elements (which I think you already do).
That did the trick, thank you very much. Mercifully Bootstrap's .btn class sets a font-size so I won't have to worry about setting one myself. I'll keep that in mind for the future, though, if this comes up again.

Opulent Ceremony
Feb 22, 2012
Since Browsersync isn't meant to work with a live site (https://github.com/BrowserSync/browser-sync/issues/163), are there any tools that offer similar functionality (mirroring user action through multiple browsers simultaneously) that do?

Ghost of Reagan Past
Oct 7, 2003

rock and roll fun
I don't know if this is the right thread to ask in, but it's worth a shot.

I've got a Flask app I'm trying to run on AWS (the server is running Apache on Ubuntu), and it needs a data file. The file is located in the root directory of the app. On the local Flask development server, things are fine, but after getting most of the difficulties deploying worked out, I'm now staring at a problem that doesn't make sense. The file location is hard-coded into the app, so it appears in the Python file as
code:
filename = 'testdata.json'
The error log tells me that it can't find the file. It's located in the same (relative) location as it is on the local server, so I wasn't expecting it to not find the file. But I've tried a bunch of things: '/var/www/app/testdata.json', 'app/testdata.json', I've tried moving it into the static directory, and many such variations, to no avail.

What am I doing wrong?

EDIT: it was a weird permissions problem.

Ghost of Reagan Past fucked around with this message at 06:52 on Aug 17, 2015

Suicide Watch
Sep 8, 2009
Hey, not sure if this is a simple HTML/CSS problem or not, but I'll ask it anyway. Is there any way to make a webpage start in the middle of the page, such that you can click an arrow at the top to scroll to content that's hidden above, and a bottom arrow to content that's hidden below?
What I'm thinking of is using something like fullPage.js (http://alvarotrigo.com/fullPage/) except with the site starting on the second section instead of the first one.

Rubies
Dec 30, 2005

Live Forever
Die Every Day

:h: :s: :d: :c:

Suicide Watch posted:

Hey, not sure if this is a simple HTML/CSS problem or not, but I'll ask it anyway. Is there any way to make a webpage start in the middle of the page, such that you can click an arrow at the top to scroll to content that's hidden above, and a bottom arrow to content that's hidden below?
What I'm thinking of is using something like fullPage.js (http://alvarotrigo.com/fullPage/) except with the site starting on the second section instead of the first one.

Yes, the easiest way is to use an anchor but unless you have something super specific why would you that? Unless there's a massive UI revolution in the next two weeks the top of your page is where all of your visitors are expecting to start.

nexus6
Sep 2, 2011

If only you could see what I've seen with your eyes
Do HTML5 video backgrounds not work on mobile devices? I could swear they used to but I set up a video tag with a webm and mp4 video and it does not show on Android chrome nor on an iPad but works perfectly fine on desktop browsers.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
How do I get started with testing? I'm a one-man army out of necessity and so I need to learn how to write tests for both Django/Rest Framework and Angular. The testing libraries and whatnot are already in place - I just need to start writing the actual tests. But every time I think about starting I get overwhelmed because it feels as though it'll take me forever to write multiple tests for every single function I've written thus far.

So how do I get started? Do I start with basic functions first, then move on to more complex ones? Are there things that don't need testing? How complex should a test be? I've never done this stuff before and I'd appreciate a point in the right direction.

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

Suicide Watch posted:

Hey, not sure if this is a simple HTML/CSS problem or not, but I'll ask it anyway. Is there any way to make a webpage start in the middle of the page, such that you can click an arrow at the top to scroll to content that's hidden above, and a bottom arrow to content that's hidden below?
What I'm thinking of is using something like fullPage.js (http://alvarotrigo.com/fullPage/) except with the site starting on the second section instead of the first one.

This is a stupid idea.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

nexus6 posted:

Do HTML5 video backgrounds not work on mobile devices? I could swear they used to but I set up a video tag with a webm and mp4 video and it does not show on Android chrome nor on an iPad but works perfectly fine on desktop browsers.

Didn't in a recent project so we just did a feature test and fell back to images (which you should have prior to lading anyway). I didn't implement so I don't know what test. To be honest it's probably better we don't have auto playing video on mobile, we can't be trusted to use it responsibly. :p

Data Graham
Dec 28, 2009

📈📊🍪😋



Karthe posted:

How do I get started with testing? I'm a one-man army out of necessity and so I need to learn how to write tests for both Django/Rest Framework and Angular. The testing libraries and whatnot are already in place - I just need to start writing the actual tests. But every time I think about starting I get overwhelmed because it feels as though it'll take me forever to write multiple tests for every single function I've written thus far.

So how do I get started? Do I start with basic functions first, then move on to more complex ones? Are there things that don't need testing? How complex should a test be? I've never done this stuff before and I'd appreciate a point in the right direction.

The best way to get yourself into the groove of it (I think) is to write tests that you know will be immediately helpful to you. Like, you know that one finicky function or layout that you're genuinely worried about it breaking if you gently caress with something? Write a test for it and set up the hooks to run it automatically. Then let it do its job, which is to take a load off your mind while you develop and to tell you when you broke something. Then think of the next most important thing you need to keep tabs on, and write a test for that, only now you don't have to set up any automated testing hooks because you already did that. And so on and so on.

At some point you'll find yourself with several small libraries of tests covering a variety of functional areas, all of them performing a valuable function for you because you know why you wrote them. At that point you get to start writing proactive unit tests that cover functional areas you haven't even coded for yet, and then you can decide how deep and broad you want to go in fleshing them out formally.

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.

Karthe posted:

The testing libraries and whatnot are already in place - I just need to start writing the actual tests. So how do I get started?

Data Graham posted:

Test stuff that scares you
This is great advice and is exactly the approach we used for unit testing on our mammoth "its working, right?" project. We have unit tests for those parts of the system that could go haywire or are very sensitive to input and change.
You can easily identify the parts you absolutely want to be testing because when you run them and say "well, that seems to be working". Usually this kind of code gives me an itch in the back of my mind anyway, and unit tests are a great way to stop you worrying.

Besides complex or ropey code, you should also definitely write tests for any reusable code. This means you know these parts are reliable and you can safely build on their foundations.
In the course of testing reusable code you'll often figure out a new way you want to use that code, discover it doesn't handle that case, and then you can create a failing test which you can fix. Welcome to TDD.
For example, we had a pagination class which we expanded to handle the various sort options of "Asc", "asc", "ASC", and SORT_ASC. It used to only handle the last two, before we made the unit tests.

Karthe posted:

Do I start with basic functions first, then move on to more complex ones?
Are there things that don't need testing?
How complex should a test be?

For your own sanity, start with the most basic stuff and move on from there.
Sometimes the easiest code to test isn't actually the simplest, but rather the one that accepts and returns the most basic data types and structures.
It can be a royal pain in the rear end to mock up a ton of fixtures just to test something like a recursive delete function, but testing a static filter which accepts a User and returns a bool is super easy.

What you don't need to test really depends on the framework and the language. Seeing as you're just starting, it's unlikely you'll get to a point where you're wondering "do I need to test that?" because there's going to be complex stuff all over the shop you want to build tests for, and there aren't enough hours in the day.
That said, one of the usual "why would I test that?" items is getters/setters on objects, for which I usually don't bother in application code. The exception to that rule is if it's reusable code - because so much will rely on it - or if the getter/setter manipulates data, or handles various types.

As for complexity, unit tests should be as basic as possible. You're trying to test a unit of code, which may just be part of a function.
This is why you build code which has minimal dependencies and single responsibilities - so you can take a tiny tiny chunk of it, and verify it does the one thing it's supposed to do.

spacebard
Jan 1, 2007

Football~

v1nce posted:

What you don't need to test really depends on the framework and the language. Seeing as you're just starting, it's unlikely you'll get to a point where you're wondering "do I need to test that?" because there's going to be complex stuff all over the shop you want to build tests for, and there aren't enough hours in the day.
That said, one of the usual "why would I test that?" items is getters/setters on objects, for which I usually don't bother in application code. The exception to that rule is if it's reusable code - because so much will rely on it - or if the getter/setter manipulates data, or handles various types.

I like to start with a coverage report and look at the complexity/major gaps. So basically any function or method with lots of logic, which could also lead to being broken down later anyway.

For JavaScript I recently found Plato for generating coverage reports. It isn't as good as Junit or phpunit in my opinion, but worked well enough to identify what code to write tests for first.

fuf
Sep 12, 2004

haha
My Wordpress permalinks are giving a 404 in nginx if I use the standard:
code:
  try_files $uri $uri/ /index.php?$args;
BUT, if I add:
code:
error_page 404 = /index.php?$args;
then they start working.

I don't understand the difference between the index.php?$args in try_files and the one in error_page - why would one work and not the other?

The only difference is that try_files is in the "location /" block:
code:
        location / {
        try_files $uri $uri/ /index.php?$args;
        }

        error_page 404 = /index.php?$args;
So I guess it's something to do with that? Moving error_page into the same block breaks permalinks again.

Any ideas? :(

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
No Nginx expert, but I imagine it's because when try_files exhausts itself it triggers it's standard 404 behaviour. The problem is it calls index.php?$args and receives a 404, so then it goes right, didn't find anything so I'm gonna show my 404 page, which unless you override it is going to be the default. All that said, Wordpress is better set up on Apache because it automatically sets up its own htaccess, which is likely a horror but IS the way it rolls.

If you insist on setting up with nginx, read this, https://codex.wordpress.org/Nginx, because try_files is not the way you should be executing php, it should be going through php-fpm.

streetlamp
May 7, 2007

Danny likes his party hat
He does not like his banana hat

fuf posted:

Wordpress and nginx
...
Any ideas? :(

Try something like this out
https://github.com/Varying-Vagrant-Vagrants/VVV/blob/develop/config/nginx-config/nginx-wp-common.conf

fuf
Sep 12, 2004

haha

Maluco Marinero posted:

No Nginx expert, but I imagine it's because when try_files exhausts itself it triggers it's standard 404 behaviour. The problem is it calls index.php?$args and receives a 404, so then it goes right, didn't find anything so I'm gonna show my 404 page, which unless you override it is going to be the default. All that said, Wordpress is better set up on Apache because it automatically sets up its own htaccess, which is likely a horror but IS the way it rolls.

If you insist on setting up with nginx, read this, https://codex.wordpress.org/Nginx, because try_files is not the way you should be executing php, it should be going through php-fpm.

That try_files line actually comes from the nginx Codex page.

I think it's meant to work like this: it looks for the file directly, then it looks for a directory, then it falls back to the WP index.php (which goes through php-fpm) and passes the url so WP can figure out what page to show.

I figured out that it was this restriction rule that was causing the problem:

code:
location ~ /(.|wp-config.php|readme.html|licence.txt) {
    return 404;
}
Specifically the "." which is supposed to restrict access to dot files. Removing it fixes everything. I have no idea why this would cause a problem.

revmoo
May 25, 2006

#basta
Maybe it's parsing the . as "current directory" rather than "files that begin with ."

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
Ruby question:

I'm looking for a service that can connect to private github repos and automatically build gems therein and be a gem source for said gems. Ideally this would be something I can pay for rather than host myself. I've looked around to no avail. I guess github used to do something like this for free but it was discontinued several years ago. Gemfury has this concept but will be a git remote themselves rather than connecting to github. I'm very surprised this isn't a thing. Anyone know of anything like this?

Adbot
ADBOT LOVES YOU

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

I'd like to get some opinions on something - let's say you were tasked with creating a website builder like SquareSpace, Wix, Weebly, etc. Performance and scalability are paramount. Which DBMS and back-end language would you choose? Would you use a front-end framework?

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