Huh, interesting. Promising. ...But apparently not supported in MySQL.
|
|
# ? Mar 5, 2015 17:18 |
|
|
# ? May 9, 2024 10:59 |
|
Let postgres into your life~
|
# ? Mar 5, 2015 17:24 |
|
Postgres kicks rear end but dear god all the GUI apps available for it are garbage. I can tolerate Navicat but Sequel Pro runs circles around it in every way.
|
# ? Mar 5, 2015 19:31 |
|
Hi, it's me again. I've run into a problem. Basically, the point of this code is to make it load sequential images from a folder until it runs out of images to load. But this is apparently making an infinite loop, but I can't figure out why! That's what the "onerror" is supposed to catch, right?code:
|
# ? Mar 5, 2015 21:29 |
|
DrSunshine posted:Hi, it's me again. I've run into a problem. Basically, the point of this code is to make it load sequential images from a folder until it runs out of images to load. But this is apparently making an infinite loop, but I can't figure out why! That's what the "onerror" is supposed to catch, right? Because JS is asynchronous. Observe this fiddle: http://jsfiddle.net/veddermatic/oL1q92fq/ Note that both "The while loop" calls happen before any "the error handler" calls. So imageLoader is never set to false in your code because none of the onerrors ever get a chance to fire.. Also, make sure you aren't using globals for things like your imageLoader and c variables. Also also, in your snippet, you never define c, so it won't run at all. EDIT: A possible quick "fix" is to not use a while loop, and instead use a recursive call to loadImage in the onload handler. Lumpy fucked around with this message at 22:08 on Mar 5, 2015 |
# ? Mar 5, 2015 22:02 |
|
Any idea why an element with a single line of copy and equal heights and line-heights would be vertically aligned in Firefox but not Chrome? I can't just do a fiddle since it might be some other code conflicting. A simple test of the bare minimum is fine
|
# ? Mar 5, 2015 22:54 |
|
Lumpy posted:Because JS is asynchronous. Observe this fiddle: http://jsfiddle.net/veddermatic/oL1q92fq/ So, basically all I need to do is place the "onerror" before the other stuff, but after the img.src? By the way, the reason why I'm using a while loop is because each chapter folder might have a different number of pages. So I need it to just look for pages to load until it can't do it anymore. Thanks for the advice, by the way!
|
# ? Mar 5, 2015 22:56 |
|
The Merkinman posted:Any idea why an element with a single line of copy and equal heights and line-heights would be vertically aligned in Firefox but not Chrome? I can't just do a fiddle since it might be some other code conflicting. A simple test of the bare minimum is fine
|
# ? Mar 5, 2015 23:05 |
|
DrSunshine posted:So, basically all I need to do is place the "onerror" before the other stuff, but after the img.src? By the way, the reason why I'm using a while loop is because each chapter folder might have a different number of pages. So I need it to just look for pages to load until it can't do it anymore. No. If you are doing things in a while loop, none of you onerror calls will ever happen ever until the loop is done iterating. Since the only way your loop stops iterating is if an onerror call happens, you will always have an infinite loop. You will need to use recursion as I suggested. I will do up an example after I am done carting my kid around. EDIT: had some extra time. Here's a recursive version that does what you want: http://jsfiddle.net/veddermatic/oL1q92fq/1/ Lumpy fucked around with this message at 23:31 on Mar 5, 2015 |
# ? Mar 5, 2015 23:18 |
|
Ghostlight posted:Well if it works fine in isolation then the problem is other code, at which point it could be virtually anything. Yeah. Use the divide and conquer method, just start ripping code out until the problem goes away.
|
# ? Mar 5, 2015 23:20 |
|
Ghostlight posted:Well if it works fine in isolation then the problem is other code, at which point it could be virtually anything.
|
# ? Mar 5, 2015 23:20 |
|
Lumpy posted:No. If you are doing things in a while loop, none of you onerror calls will ever happen ever until the loop is done iterating. Since the only way your loop stops iterating is if an onerror call happens, you will always have an infinite loop. You will need to use recursion as I suggested. I will do up an example after I am done carting my kid around. Oh, I get it -- right, because the loop always iterates before the onerror call is triggered.
|
# ? Mar 5, 2015 23:22 |
|
DrSunshine posted:Oh, I get it -- right, because the loop always iterates before the onerror call is triggered. Correct. I edited in to my other post, but here's a recursive example: http://jsfiddle.net/veddermatic/oL1q92fq/1/
|
# ? Mar 5, 2015 23:32 |
|
Lumpy posted:Correct. I edited in to my other post, but here's a recursive example: http://jsfiddle.net/veddermatic/oL1q92fq/1/ Thanks! That's very enlightening. One more question -- you end the function with lol_improved(1); -- what does this do?
|
# ? Mar 6, 2015 00:26 |
|
revmoo posted:Yeah. Use the divide and conquer method, just start ripping code out until the problem goes away. It's the font? Has anyone had issues like this with Google Web Fonts?
|
# ? Mar 6, 2015 00:46 |
|
DrSunshine posted:Thanks! That's very enlightening. One more question -- you end the function with lol_improved(1); -- what does this do? Calls it for the first time so it starts looking for images.
|
# ? Mar 6, 2015 01:12 |
|
Lumpy posted:Calls it for the first time so it starts looking for images. Ah, okay, I see! Well, I tried it out and it works just fine! I added a little bit of code to prune the broken image that it creates when it gets to the end of the loop. Thank you so much!! Now there's one more thing I'm doing. Every time someone clicks a link to a chapter, it creates a cookie and gives it a value equal to the number of the chapter (so, 1, 2, ...). To advance to the next chapter, I want there to be a button you can click on. So that the button "knows" which chapter to advance to, it takes the value stored in the cookie, adds 1 to it, and sends the new value back into "loadChapter". Then it creates a new cookie with the new value. At least, that's the intention. For some bizarre reason, the nextButton function gives nextChapter a value of 11 instead of 2, if I start from chapter 1. This is baffling to me, because the "prevButton" function works just fine -- if I start from chapter 2 and go back, it loads chapter 1. code:
DrSunshine fucked around with this message at 02:02 on Mar 6, 2015 |
# ? Mar 6, 2015 01:36 |
Try var chapter = parseInt(document.cookie);
|
|
# ? Mar 6, 2015 02:25 |
|
Data Graham posted:Try var chapter = parseInt(document.cookie); Ahh, that fixed it perfectly!! Thank you so much!! I knew it had to be something of that nature, but since I'm kind of teaching myself all this as I go along, I sort of lacked the "vocabulary" to do what I needed to.
|
# ? Mar 6, 2015 02:34 |
Yup. You'll get a feel naturally over time for the esoteric little idiosyncracies that need to be massaged in JavaScript (as with any language). This one, as you can probably figure, stems from it being a not-strongly-typed language, meaning you don't tell it whether a variable is a string or an integer or whatever, so it has to sort of just guess based on context. It will always treat cookie values as strings, and when you're dealing with strings, 1 + 1 = 11 As to why it worked when going to the previous page, I can't say, but I would wager something along the lines of https://www.destroyallsoftware.com/talks/wat For your next trick you might want to try to combine those two functions, since you'll notice you're basically duplicating the exact same thing twice, with only one line of difference between them. DRY = Don't Repeat Yourself. Make it an incrementPage(num) or something, and use num instead of 1. That way you can pass in 1, -1, or any number you want depending on how you set up your controls. Incidentally I just want to say that your onload/onerror approach is a pretty neat trick. Very elegant/improvisational. I've been in DB land so long I'm pretty sure I wouldn't have come up with that in a million years.
|
|
# ? Mar 6, 2015 03:27 |
|
Data Graham posted:Yup. You'll get a feel naturally over time for the esoteric little idiosyncracies that need to be massaged in JavaScript (as with any language). This one, as you can probably figure, stems from it being a not-strongly-typed language, meaning you don't tell it whether a variable is a string or an integer or whatever, so it has to sort of just guess based on context. It will always treat cookie values as strings, and when you're dealing with strings, 1 + 1 = 11 Oh wow, that's true! I kept thinking that they had to be separate, since I have two separate buttons, so I didn't think at all that I could just use the same function and just pass -1 or 1 into it depending on which <div> was clicked! Oy! That's a clumsy beginner mistake right there, haha! quote:Incidentally I just want to say that your onload/onerror approach is a pretty neat trick. Very elegant/improvisational. I've been in DB land so long I'm pretty sure I wouldn't have come up with that in a million years. Thanks so much! Coming from someone with, like, decades more experience in coding than I have, that's a huge compliment.
|
# ? Mar 6, 2015 05:20 |
|
I'm maintaining a handful of sites on our company intranet, and one thing I've noticed is that people aren't always receiving new versions of pages when I update them. Is there such a thing as best practice for getting new builds out in this situation? Lately I've taken to changing the file names for linked css/js/json resources with new builds, but I've run into problems where the html (e.g. company.com/intranet/index.html) isn't even being refreshed. Our web server is probably a stock-ish IIS (nobody seems to own it) so anything server-side is probably a non-starter anyways.
|
# ? Mar 6, 2015 05:23 |
|
ItBurns posted:I'm maintaining a handful of sites on our company intranet, and one thing I've noticed is that people aren't always receiving new versions of pages when I update them. Is there such a thing as best practice for getting new builds out in this situation? Lately I've taken to changing the file names for linked css/js/json resources with new builds, but I've run into problems where the html (e.g. company.com/intranet/index.html) isn't even being refreshed. Our web server is probably a stock-ish IIS (nobody seems to own it) so anything server-side is probably a non-starter anyways. I believe that most people get around this by putting a unique query string on the end of the resource, e.g. main.css?v101 . Not sure how viable that is in your environment though.
|
# ? Mar 6, 2015 06:05 |
|
Scaramouche posted:I believe that most people get around this by putting a unique query string on the end of the resource, e.g. main.css?v101 . Not sure how viable that is in your environment though. That was the way it was done previously, it's no longer recommended because it was found out that using query strings causes cache misses for 5 - 25% of the users. Also, to quote the reasoning for Rails moving from query strings to file-name suffixes: "Query strings in particular do not work at all with some CDNs for cache invalidation." You should probably just append the unique string before the file extension. So instead if main.css?v101 do main-v101.css or something.
|
# ? Mar 6, 2015 08:46 |
|
I agree with Loezi. If you're not sure of your or anyone elses setup, just have the filename contain the version, and update that when you want to increment. If you can't do it properly, just do it the most basic way. Caching/invalidation is hard.
|
# ? Mar 6, 2015 09:13 |
Yeah, it's funny, if you go digging through the code of high-profile publicly-facing sites, you find interesting stuff likecode:
http://robandlauren.com/2013/08/14/busting-cache-with-grunt/
|
|
# ? Mar 6, 2015 12:55 |
|
Data Graham posted:Yeah, it's funny, if you go digging through the code of high-profile publicly-facing sites, you find interesting stuff like Those are most likely fingersprints (hashes) of the files that are recalculated every time the site is rebuilt/updated. That way if the file has the same contents, the postfix is the same no matter when the file was changed or created. This ensures you invalidate as few of the cached resources as possible. A previously popular automated alternative is to use file timestamps but that has some drawbacks on multi-server enviroments and you end up invalidating caches if you first make change A and then undo it without checking out the original file before A was changed. As for how to do it, some frameworks (Ruby on Rails) have a prepackaged asset pipeline that handles asset versioning, others (Django) have addons/packages that can handle it.
|
# ? Mar 6, 2015 14:11 |
That's a neato idea. Seems like in a better world, HTTP might work more like git or something—for each request for a cached file, the browser would send up the hash, and the server would make its 200/304 decision based on that. But then I suppose if all browsers implemented date checking properly, we wouldn't have caching problems to begin with.
|
|
# ? Mar 6, 2015 14:59 |
|
Data Graham posted:That's a neato idea.
|
# ? Mar 6, 2015 16:43 |
|
Hey guys, am I opening myself up to anything if I use a Firebase with read/write rules set to False at the top most level, and then authenticate as an admin in a Python script that's intended to interact with the database? As in, is that a bad habit to get into? I'll eventually open it up for reads from Angular but for now it'll just be a means of storing and retrieving API keys for another service.
|
# ? Mar 6, 2015 17:47 |
|
Data Graham posted:That's a neato idea. This is a thing! It's called a HTTP E-Tag and works essentially like this: code:
The actual mechanism is the server sending a header of the form ETag: "686897696a7c876b7e" when replying to a request. In the future, if the client sends a request that contains a header line of form If-None-Match: "686897696a7c876b7e". Now if the resource is unchanged, the server replies with 304 Not Modified and if a change has happened then it returns the new file and the new ETag. Weak ETags work just the same but have a prefix of W/, so a weak version of the above ETag would be W/"123456789". EDIT: The main difference between ETags and the aforementioned fingerprinted file names is that ETags still require a round trip to the server and waiting for the 302 response. Cache invalidation using file names allows the server to say to the client "Here is the CSS file, keep it forever" and then the client doesn't even bother checking for a new version from the server. When we change the fingerprint in the file name the client no longer recognizes that file and requests it from the server. So for semi-non-changing assets like images, CSS and JS fingerprinting is probably better, but for situations where you always need the round trip -- like an API or a HTML document -- ETags are better. Loezi fucked around with this message at 20:14 on Mar 6, 2015 |
# ? Mar 6, 2015 20:05 |
|
Anybody have Firefox poo poo the bed on SSL? I have my FF set to clear all cookies, cache, everything on shutdown, and yet if I load up a fresh instance of FF and browse to a number of sites I get untrusted connection error. I've had other people verify with their copies of FF and it only happens with my copy.
|
# ? Mar 6, 2015 21:33 |
|
revmoo posted:Anybody have Firefox poo poo the bed on SSL? I have my FF set to clear all cookies, cache, everything on shutdown, and yet if I load up a fresh instance of FF and browse to a number of sites I get untrusted connection error. I've had other people verify with their copies of FF and it only happens with my copy. Is your system clock correct?
|
# ? Mar 6, 2015 21:36 |
|
Good idea, but yeah it's set right (time.apple.com)
|
# ? Mar 6, 2015 21:58 |
|
Finally landed myself a lucrative web programming dayjob to support my habits, like trying to write for a living and playing games. My new boss is hot for me to get up to speed on PyroCMS. Are any goons familiar with Pyro? The streams aspect seems really interesting, and I'm diving into it a bit more this weekend. Anything I should be aware of before I get deep into the code?
|
# ? Mar 7, 2015 01:13 |
|
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.
|
# ? Mar 7, 2015 01:37 |
|
revmoo posted:Anybody have Firefox poo poo the bed on SSL? I have my FF set to clear all cookies, cache, everything on shutdown, and yet if I load up a fresh instance of FF and browse to a number of sites I get untrusted connection error. I've had other people verify with their copies of FF and it only happens with my copy. Do you have Fiddler running? This happens a lot and I always forget it's because I have Fiddler going.
|
# ? Mar 7, 2015 01:46 |
|
BlueInkAlchemist posted:Finally landed myself a lucrative web programming dayjob to support my habits, like trying to write for a living and playing games. My new boss is hot for me to get up to speed on PyroCMS. No, but for a framework that touts 'Responsive Design' as one of its features, their site sure is awful looking on mobile.
|
# ? Mar 7, 2015 01:47 |
|
Loezi posted:That was the way it was done previously, it's no longer recommended because it was found out that using query strings causes cache misses for 5 - 25% of the users. Also, to quote the reasoning for Rails moving from query strings to file-name suffixes: "Query strings in particular do not work at all with some CDNs for cache invalidation." Thanks for the info from everyone. I'm just going to stick with appending the date or something onto the file. It's not like I'm doing daily builds on it. All of the new stuff that I've made actually has something more like... Data Graham posted:Yeah, it's funny, if you go digging through the code of high-profile publicly-facing sites, you find interesting stuff like ...this because I'm using grunt and those pages don't seem to have the same issues. Good to know I'm not overlooking something obvious.
|
# ? Mar 7, 2015 02:03 |
|
|
# ? May 9, 2024 10:59 |
|
BlueInkAlchemist posted:Finally landed myself a lucrative web programming dayjob to support my habits, like trying to write for a living and playing games. My new boss is hot for me to get up to speed on PyroCMS. It's probably going to suck and you should tell him you want to use WordPress or Drupal.
|
# ? Mar 7, 2015 02:36 |