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
Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.
edit: ignore

Adbot
ADBOT LOVES YOU

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

DreadCthulhu posted:

Can someone in the know kindly summarize what's going on with all of the JS MVC frameworks that have sprouted in the past couple of years? Angular, Ember, Knockout, Backbone etc.. why does the world need so many and which ones should I be following?
I don't know your level - IANAWD (I am not a web developer) but here's the way I see it:

Say you want to do MVC. You have your model classes (where your data is.) You have your view - the thing that presents your data.

Your problem is that without a framework, you need to figure out yourself how to get your view to reflect the content of your model. You can do this yourself but it's boring and sucks rear end.

With a framework like knockout JS, you get stuff like

* Declarative Bindings - easily associate DOM elements with model data.
* Automatic UI refresh - when the data in your model changes, the UI will automatically update itself to reflect the state of the model for free.

So you get the ability to just annotate an HTML file with a tag indicating that the html element (like an item dropdown) is part of your model, and the framework will update the content of the dropdown accordingly, and change the values in the model when the value changes in the UI.

Regarding which framework is best, I have no idea because I am a C++ developer and know very little about front end development. Just pick the one that's least annoying - I liked knockout for what it's worth, but I bet people hate it because microsoft likes it.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

ManiacClown posted:

I'm trying to build a page that's going to dynamically look up systems from a database based on OEM, then power supplies compatible with those systems depending on OEM and type of system. I'm trying to do this with AJAX, but this is my first time using AJAX and I'm having trouble wrapping my head around it. Should I be using jQuery, or can I do it easily enough with vanilla AJAX?

You don't have to use jQuery, but jQuery has done the work of making it so XMLHTTPRequest is called the correct way on the different platforms so you don't need to do the cross-browser support yourself. I think there may be other frameworks may do that plumbing for you as well.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Tres Burritos posted:

Ugghh, I'm having a hell of a time wrapping my head around JQuery UI. It's like all of the components that I need are there, I can see them, I'm just not sure how to properly hook them together yet.

Anyways, what I'm trying to do is drag and drop tabs across multiple tab divs. I got something that sort of works, but it doesn't behave properly and I'm not sure what to do next. If I drag a tab into a different div, it's content still shows up in the original location and not in the new one. I was thinking the "out" event would do something for me on the source and the "create" event would do something on the destination.

Here's a fiddle that illustrates the problem: http://jsfiddle.net/Tpt4t/


It's like I can see that JQuery will do all the stuff I want but I'm missing some basic assumptions/concepts on the way stuff works. Web isn't really my forte and it's getting sort of frustrating.

Take a look at this reference: http://jqueryui.com/sortable/#connect-lists-through-tabs

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Tres Burritos posted:

Yeah, I was looking at that but my problem is that I can't parse what the hell is going on.

I get as far as

code:
var $tabs = $( "#tabs" ).tabs();
Then I look at the documentation and wonder what .tabs() returns. I'm ... not finding an explanation.

I guess it's just implicitly a "getter"?

I'm really struggling with the documentation.

http://jqueryui.com/tabs/

That line makes the html element with id 'tabs' start being tab-able (probably some stylesheet fuckery)

1. Use the F12 developer tools! Press F12, put a break point on any line you don't understand!
2. Use Google!

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Plorkyeran posted:

I have come to dread doing anything involving Google APIs or Google libraries. They're frequently shockingly bad, and when they aren't, the documentation is.

*cough google closure cough*

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

pliable posted:

I'm going to preface this by saying that I am a complete JS newbie...my forte are languages like Java, C, and Python.

With that being said, I cannot figure out for the life of me of how to get an image to animate according to a given interval (or more specifically, just loop and display a series of images according to a given time).

JavaScript code:
<img src="dancing_snoop/tmp-0.gif" id="SnoopCommander">

//relevant HTML above

var which=25;
function aniSnoop(){
   while(true){
      document.getElementById("SnoopCommander").src="dancing_snoop/tmp-" + which + ".gif";
      which=which+1;
      if(which > 57) {
         which=0;
      }
      setTimeout("aniSnoop", 1);
   }
}
I discovered that if I leave the while loop in there, the webpage will load forever due to JS's event driven nature :argh:. Then again, the setTimeout/setInterval functions do not want to seem to work at all and call the aniSnoop function.

I'm absolutely baffled, this should be trivial but I spent 3 hours trying to figure out different functions, and even adding different event actions like onmouserollover or onclick to get the loving thing to cycle through, but it just won't happen :(

Any advice would be great, thanks!
what's calling aniSnoop the first time? also, shouldn't the call be setTimeout('aniSnoop()'...

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

pliable posted:

Can you call it directly? Or do you have to surround it with <script> tags?

I would recommend putting it in an onload handler of your body element, just to simplify things.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

pliable posted:

What's the proper syntax for that?

code:
<body onload='aniSnoop()'>
?

I'll try making these specific modifications, and see if it does anything...

Here's a hint http://jsfiddle.net/BC8Yx/
(That url is to an image that changes every single time you access it.)

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

pliable posted:

Welp I'm confused all over again:

JavaScript code:
<script>
function aniSnoop(which, element){
   console.log(element);
   document.getElementById(element).src="dancing_snoop/tmp-" + which + ".gif";
   which=which+1;
   if(which > 57) { which=0; }
}
</script>
//various HTML poo poo here...also assume a table exists for the next line
<td><img src="dancing_snoop/tmp-0.gif" id="SnoopCommander"></td></tr>

<script>
var which_cmd=0;
var cmd=setInterval(function(){aniSnoop(which_cmd, 'SnoopCommander')},50);
</script>
I define my function at the top there, and I'm baffled because the function is executing perfectly (it's writing to the log with that console.log line multiple times), but now for some reason, the image isn't being updated on the webpage. What did I gently caress up?

EDIT: Bah god dammit nevermind, figured it out, that "which" variable isn't being updated...I was hoping JS would treat it like a pointer and update that var directly :(

Yep, that's the fun of javascript Passing parameters doesn't work like that. In browsers that aren't IE, your parameter can be your third/fourth argument, etc. I'd recommend just declaring a variable outside the scope of the settimeout and incrementing it.

The way settimeout works in javascript is totally weird. Wait until you get to the part where you realize the parameter for milliseconds is only the minimum time it'll take a timeout to execute, not a guarantee.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

bobua posted:

Yeah, knew about the security issue, was just really hoping having complete control of the browser would mitigate that. Guess not.

Really sucks, I'm shocked with all the web apps that printing like this hasn't been squared away. Thanks though.

The term 'web app' is a marketing thing - web applications are not first class citizens. It's very easy for desktop applications to do stuff like drag and drop between applications, print, save files to the hard drive, have keyboard shortcuts and accelerators and menu bars and floating toolbars, and a whole host of other poo poo that people take for granted in the desktop world that doesn't translate to the web/mobile experience.

The worst thing your marketing team can do is look at an existing desktop application and go
"Take this and make it be a webapp." That's why all that activex/client side java poo poo got super popular back in they day - people would just write lovely activex controls and voila, "webapp."

There has been some progress in providing richer web/mobile platforms, but the progress has been made primarily in understanding the target platforms better, keeping it simple, and not trying to recreate the desktop experience.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

OddObserver posted:

How exactly would self change on that recursive call?
(Unless you create a separate instance with captured self
for every object, I guess..)

Experience has shown that people like to use "var self = this;" when using closures, and sometimes they slip and do "self = this;"

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Misogynist posted:

So this is dumb, but I'm working on an application with my team that seems to have randomly stopped logging runtime error messages -- I can [].butt('fart') and the task will abort but not log an error. It's like something is globally catching exceptions. window.onerror is not set. The application is loaded and run through RequireJS.

Any ideas where to start looking?

Look to see if someone did:
code:
console.log = function() {}
somewhere. That would turn off all logging.

You can also just intentionally throw a loggable exception, put a breakpoint on it, and step through to see where it goes.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Dominoes posted:

Looking for thoughts on 'for in' loops in javascript, and this Stack Overlow question on the topic. The accepted answer is that
JavaScript code:
for (var i in myArray) {
    var item = myArray[i]
}
is bad because 1: A libary you loaded might have messed with the array class and 2: you might create an array with only some values filled in.

The way I'm looking at it, this:

JavaScript code:
for (var i=0; i < myArray.length; i++) {
    var item = myArray[i]
}
is enough of an eyesore that it's worth using the cleaner syntax. I have no intention of breaking the array class or defining an array with missing values.

the order of a for...in loop is also undefined in the standard. it's implementation specific what order the loop executes.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.
return overamt+recursion(etc) is returning a string that says "9898[object]".

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Raskolnikov2089 posted:

I'm working with different types of money with different strings attached, so when I started graphing out the nested for loops and if then statements that would be required, I thought recursion might be easier to unravel.

I might have thought wrong.

I tend to avoid recursion when I write javascript. In javascript, every time you make a recursive call, you make a new stack, and it's very easy to run into "max call stack size exceeded." Other languages avoid this using compiler optimizations, but in javascript you have to manually optimize to make fewer recursive calls.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Peanut and the Gang posted:

It's trying to convert it to a bool (null/undefined/0/"" would become false), but actually it's superfluous because if-statements already convert the condition to bools anyway.

Yeah that's bad js developer smell seeing the !!.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Wheany posted:

From what I can tell, once an image has been queued for downloading, it cannot be unqueued, so changing the src attributes is useless if the intention is never to download the images, or only download a certain subset of them.

You can stop an image (or anything else) download by doing something like:

code:
if(window.stop !== undefined)
{
     window.stop();
}
else if(document.execCommand !== undefined)
{
// ie
     document.execCommand("Stop", false);
}
This will trigger the onabort of everything that has an onabort (like ajax calls) so it's usually a Bad Idea to use.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Xenoveritas posted:

Well, or writing a local proxy running on the same domain. The great traditional solution to a problem that by all rights shouldn't exist in the first place. gently caress you, SOLR. Er, what were we talking about again?

You could always just roll with --disable-web-security in Chrome or enabling access to datasource across domains in IE security settings if this is just a personal thing.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Tomed2000 posted:

I'm working on a JS app that basically sits in other peoples' websites where we're compiling/minifying a local jQuery and various plugins into one file. This has been working fine but we've been trying to reduce the footprint of our app. The idea is to load jQuery only if the website we're in doesn't already have it. So basically I ended up with something like this when jQuery doesn't exist:

code:
var jqTag = document.createElement('script');
jqTag.type = 'text/javascript';
jqTag.src = 'https://code.jquery.com/jquery-1.10.2.min.js';
document.getElementsByTagName("head")[0].appendChild(jqTag);
The problem I'm having is that jQuery is now available at a later time than before thus the compressed/minified JavaScript plugins that I previously mentioned are trying to extend jQuery before it's being created. What is the usual solution to this problem? Do I need to move the declaration of our plugins into the jqTag.onload event? Usually I don't run into this because I'm just including JS in the HTML and the ordering matters but in this case all of the plugins and poo poo are compiled into one file.

You should start looking into a script loader - something like require.js (although there are many others.) A lot of work has been done on automating script loading and making it so pages load faster already, you probably shouldn't roll your own.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Wheany posted:

So, I learned about Douglas Crockford's DEC64 and was thinking: Does Javascript actually require float (or double) specifically, or is it an implementation detail?

Could someone make a standards compliant Javascript interpreter that used for example DEC64?

Or does something in the standards say (or imply at least) that "0.1 + 0.2 == 0.3" must be false?

The ECMAScript standard says that number type is "primitive value corresponding to a double-precision 64-bit binary format IEEE 754 value." A javascript implementation using DEC64 would violate the ECMAScript standard.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

huhu posted:

Could you elaborate in a full sentence?

Ideally, more than "Use node and file.js."
'
Node runs javascript. If you have node installed and(set up on your path) and type "node file.js" it will run the file provided on the command line in a node server. Window.console output will be logged to the command line.

If you're not big on node, phantomjs does the same thing.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

huhu posted:

Thanks.

Another question. My first idea for a larger project was to make a "dictionary" that hooked up to the MDN. People could take HTML they wrote, get it processed and have the dictionary terms they knew be marked so they could keep track of what tags and elements they have already learned. I started out building the code for processing a website and have gotten this far and you can see it live [url=https://htmlpreview.github.io/?https://github.com/TravisBumgarner/Codesaurus/blob/master/index.html]here.[/url]

I feel like I got pretty far with it yesterday but there's a lot of special cases such as single and double quotes, comments, other languages within an HTML document(such as PHP which I know nothing about yet) and the more I try and tackle these problems, errors start popping up that I'm clueless about their origin.

Did I bite off more than I could chew or is there an end in sight? Luckily, at the very least I learned a ton about dealing with strings.

It looks like you're trying to write an HTML parser in javascript. That... seems unnecessary.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

huhu posted:

Just looked up what a parser was... don't think that's what I'm doing.

My goal was to take this:

code:
<html>
     <head>
          <title>ss</title>
     </head>
     <body>
          <h1>sdfsdf</h1>
          <p>sdfsdf</p>
     </body>
</html>
Turn it into an
code:
array = [body,h1,head,html] 
Compare that array to an array with all html elements.

The end result would be a webapp that interacted with the Mozilla Developer Network that kept track of which HTML tags you've used before, which you haven't used yet, and stats about usage of each. I was going to add support for attributes and maybe some other tools. Its goal was to help as a sort of reference for me, and maybe others, as I learn HTML.

Just to be explicit, read this (http://stackoverflow.com/questions/8227612/how-to-create-document-objects-with-javascript), look at the response than mentions var doc = (new DOMParser).parseFromString(markup, mime_type), and then use vince/wheany's JQuery stuff to populate the array, rather than looking at the HTML input as a string yourself. Make the browser do the work.

Bruegels Fuckbooks fucked around with this message at 13:20 on May 11, 2015

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

v1nce posted:

The main difference is the regex method ignores HTML comments and picks up everything that even looks remotely like an element.

I am an enabler :eng99:
Looked at that quickly and was like:

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Knifegrab posted:

I just looked up es6 style imports and its not yet supported by firefox so I think I had better hold off on using that for now.

One thing you can do with typescript is compile multiple ts files into one big js file, and just serve that as a single script.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

It's important to remembert that the problems with javascript are primarily human problems. Like, you can do anything you want in client side javascript. The problem is that since literally any rear end in a top hat can write javascript, all third party libraries and all tools are poo poo. The node.js people are eventually going to win - like, Typescript and other compile-to-js stuff is a win, and eventually, someone is going to make non-retarded versions of Node.JS and angular - hell, even Microsoft has gotten tired of loving dealing with IIS and is starting to embrace Node. But until actual non-retards start getting interested in front end development, we're going to have to deal with stuff like gulp and bower and grunt and require.js.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

my effigy burns posted:

What's a good response in a technical interview for a javascript position when they tell you to do a specific kind of search and modify operation with an unsorted array and then to "convert it into a hash map." I was under the impression that since javascript arrays are objects and their indices are actually keys, a hash map is not a meaningful concept.

Is it some kind on initiative test where you're supposed to call shenanigans, or is it pretty common to get interviewers that don't know anything about javascript since whiteboarding is more about general CS skills?

If I asked this in a javascript interview, this is how I'd expect it to go:
code:
var arr = [
    { key: 'foo', val: 'bar' },
    { key: 'hello', val: 'world' }
];

var result = arr.reduce(function(map, obj) {
    map[obj.key] = obj.val;
    return map;
}, {});
Because that's a useful technique. I wouldn't be looking for an education on javascript semantics.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

German Joey posted:

Speaking of, and I'm kinda laughing at myself for even thinking about this, but is there any way to sandbox Javascript in the browser? Like, lets say I have some widget that has a bunch of methods attached to it, and I want to allow user-written scripts that can interact with this widget. As in, User A writes a script on the site, and User B loads the script and runs it.... WITHOUT needing to worry about his computer blowing up or known terrorists now knowing his credit card number and his mother's maiden name. Just from the top of my head, I'd want to ban DOM manipulations except via the widget's method calls, or modifying the widget itself, or the use the eval function, or access to cookies, or to load any external objects, or who knows what else. Is this possible natively?

The requirement for making it so the script interacts with the widget means you should probably look into having the widget render on the server with the user script executing on the server as well (like using node / Rhino) - some of the codepad utilities will run the javascript in an iframe, but since the script needs to interact with the widget, it'll be nearly impossible to lock everything down client side.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Suspicious Dish posted:

And does anybody use client-side certs yet? OK, OK, outside of that one weird corporate site you encountered once that also required a custom ActiveX plugin.
My company used to use Lotus Notes, and then the announcement went out that we were going to use gmail. It was great - we could use it on our phones, just use it on any web browser. It worked pretty well for 4 years.

Then they decided Gmail was too open.

Solution:

1. Instead of logging into gmail, you log into some external provider.
2. User needs client side certificate and activex control to log in, and can no longer go directly to gmail, but has to go through some weird website, which requires typing in the concatenation of your company id and employee id plus your password to log in.
3. You need to install a bunch of weird bullshit to get gmail on a phone to work but that's OK because you need authorization from someone director level or higher to get it on your phone.

It loving sucks. I can't figure out how to have Fiddler open and check my email at the same time, or get Gmail to work with loving google chrome.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

peepsalot posted:

Is it possible to do very RAM intensive computations in google chrome? I have a script that I fully expect to use multiple GB of ram, but it can only allocate up to about 1.5GB before chrome gives up with an "Aw Snap", even though I still have 8-10GB free and on 64bit system. The aw snap page is supremely unhelpful and only suggests that i close other tabs to free up RAM.

Are you on windows? 32-bit processes will crash when they hit the virtual size limit on windows. You should try using 64-bit chrome.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Kuule hain nussivan posted:

Nope, still can't get it to work :(

IE or Chrome?

If .checked = true doesn't work in Chrome, then you might be running into this: http://stackoverflow.com/questions/16950751/checked-checked-not-working-in-chrome.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Lord Windy posted:

I've never been good at Web development. I don't understand it at all. I went to live in the world of low level C instead. For shits and giggles I went with a group of friends to a Hackathon and we've walked away with something that both might win and we think might be a good startup idea to pursue over the summer break.

I really need to get good at javascript to be much help. I stress the part of really good, because some of the libraries we have used are cryptic as gently caress. We are using Riot.js, Ventus.js and heaps of other things in some mashup. I want to be able to detangle this mess before it becomes a headache.

So do you guys have any resources to help bring people up to speed on all this?

As a general rule, the "let's pull random javascript libraries that do cool things and smash them together" style of JS development is just a pain to work with. I would say:

a) Minimize the library use in your project. If you don't really need the whole library, or can do it yourself, just cut it. Vanilla JS is almost always easier to deal with than library slop.
b) Consider converting to a compile-to-JS language like typescript. Raw JS is more difficult to maintain than compile to JS languages.
c) Minimize the amount of stuff done in the browser - web apis are easier to test and maintain, and it'll be easier to refactor when someone decides to get rid of your flavor of the month UI library.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Skandranon posted:

For...of works differently. It is an iterator of each object in a container, where for...in is iterating over the objects properties.

I like to use forEach for iterating over an array. It's like for...in but actually does the correct thing - only downside is you can't break forEach, but it wouldn't be javascript without having five ways of doing the same thing that are broken in subtly different ways.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

geeves posted:

yeah. Just don't. when I had to do money-like numbers, I just sent it to the server instead. Much safer and not much longer.

I was thinking about replying like this but then I remembered that node.js is a thing, so it's conceivable that node.js could be used by like banking sites or some poo poo.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Professor of Cats posted:

I think what people are trying to say is it isn't that JS is bad at math, it is that doing any sort of math poo poo on the front end is dumb, unsafe and untrustworthy.

Estimates, quotes, etc are fine. But the actual data that will result in a transaction should come from the server because any data exposed to the front end can be manipulated.

In JS, there is no integer type - all numbers are IEEE 754 doubles, and it is impossible to represent .1 accurately using such a number- for instance, .1 + .2 !== .3 in javascript. This can cause issues with interest rate calculations and the display of numbers, especially over time (e.g. all the problems http://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency are valid.)

If you're just using dollars, you can avoid this by storing in cents (e.g. instead of $5.24, use 524.) The two problems with this approach are
a) You need to decide whether you care about fractions of a cent
b) This doesn't work for all kinds of currency. Bitcoin in particular has lots of weird fractions.

The separate problem is that doing the math on the front end is a bad idea because it's client side, but I was sarcastically pointing out that
a) node.js exists so you can't necessarily make the assumption that JS is client side
b) there are actually problems with doing this regardless of whether the JS is running client/server side for the above reason
c) man, since node.js is so popular, i bet people really have this problem

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Jabor posted:

for all 2.7 people in the world who care about using bitcoins, javascript is just fine because bitcoin is built on doubles anyway

I googled around to try to figure out why that came to mind and I found this: https://en.bitcoin.it/wiki/Proper_Money_Handling_%28JSON-RPC%29.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

fankey posted:

In my code I'm not storing any references to either the ws or socket - they appear to go out of scope when add() returns. At this point are they eligible for gc and could be yanked out from under me? If so, should I just store them in a collection manually? If they somehow aren't eligible for gc then I have the opposite quesiton - what do I need to do once I'm done with both connections to ensure the gc will clean up memory for me? Or do things just magically work and I don't need to worry about such things - which is hard for someone with years of C++ and C# development to come to terms with.

The javascript GC actually garbage collecting something that you don't want it to garbage collect is polar opposite of the problem I usually have with it (it not loving garbage collecting something that ought to be garbage collected).

Note that there are like, tools for figuring this poo poo out - like, if you follow along with this guide using node inspector https://www.toptal.com/nodejs/debugging-memory-leaks-node-js-applications and using the heap snapshot tool in Chrome, you should be able to test whether or not you actually have a problem.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Thermopyle posted:

Thanks for the replies. Why the gently caress is node so popular on the backend if there aren't any good full-feature frameworks for it yet?

(and by popular I mean lots of results on job sites)

It's actually a total mystery what the core value of node.js is - like all the alleged benefits it lists on its website are either completely transparent lies (scalability/concurrency yet still has to be put behind nginix in production !) or prima facie idiotic (run javascript on both the server and the client, so you can just take your front end js wizards and make them back end devs with no training!).

but I think a lot of web devs who are sick of Ruby on Rails are switching to it, and Microsoft is encouraging its use for whatever reason.

Adbot
ADBOT LOVES YOU

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

ROFLburger posted:

Just curious, why is this?

I'm just going to post this without comment:
https://thefullsnack.com/don-t-serve-static-files-with-nodejs-31666462f79c#.ynw7kcwer

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