« first day (1186 days earlier)      last day (3761 days later) » 

4:06 AM
'scuse me
I'm having an issue with XMLHttpRequest
I'm making a mini-site to run on my Nintendo DS server, only html and javacript
It basically gets the xkcd comic of choice from the ds server
However, the filenames have spaces in them
localhost/xkcd_downloader/%209%20-%20Serenity%20is%20coming%20out%20tomorrow.txt
It requests that, when I need
localhost/xkcd_downloader/9 - Serenity is coming out tomorrow.txt
Any suggestions? I don't want to half to spend forever scripting mass renaming, and editing all the definitions in my code (for each comic)
...I'd like to finish it so I can try it out then go to bed
 
!!tell AustinBurk google How to encode a URL in JavaScript
 
@MirkoCianfarani Don't be annoying, drop the @, nobody likes a double-ping.
 
Look the first
you have to use deconding
 
4:22 AM
^^ that
 
m59
Does anyone know why SyntaxHighlighter could be rendering my code like:
 
but also cool project
 
m59
$foo
=
'bar'
 
!!tell AustinBurk xkcd
 
m59
because it really sucks :(
 
4:22 AM
@AustinBurk xkcd.com/663
 
4:51 AM
Hello
I figured out my issue (extra space in the js), and I can get the comic to load with the JS Console but now it's not working for passing the value from a textbox
I think it's passing a value in quotes instead of just the value
 
how can I force to download xml file in javascript?
 
> getComic(663)
undefined
XHR finished loading: "http://localhost/xkcd_downloader/663%20-%20Sagan-Man.txt". xkcd_update.js:6454

> document.getElementById("comicInputBox").value
"663"

> getComic(document.getElementById("comicInputBox").value);
undefined
I'm using switch case with a different filename for each comic (with the exception of 404 and a couple other weird ones which my downloader script didn't handle correctly)
It's not working though
just typing getComic(663) works
 
@AustinBurk maybe it requires a number?
rather than a numeric string
 
facepalm
 
:-)
 
5:00 AM
One moment while I replace all my case #s with case "#"s
Would there be any way to just convert it without having to edit all of those?
 
Yes, but you probably want a string input anyways
 
I can just write a macro to do it but I want to know my other option first
Yeah, sounds good
 
I found out that you can .. chain? assignment statements. x.onclick = y.onclick = z.onclick = function() { console.log(this); }; but is this a "good" practice?
 
In backbone.marionate, how do I write code for form submit? I am completely new to backbone.marionate.
 
@RUJordan this has unintended consequences when declaring variables
 
5:02 AM
Should I be writing a new module for that?
 
@JanDvorak what do you mean?
 
@RUJordan var x = y = z = 0
only x is declared, the rest are global.
 
What if they're all predefined? var x = document.getElementById("x"); var y = document.getElementById("y"); var z = document.getElementById("z");
Err, predeclared?
 
@RUJordan Not sure what you're asking; it's a well known feature of JavaScript (and every language I've ever used). It's not considered a bad practice if that's what you mean.
 
except in a var statement, where it is bad practice
 
5:06 AM
@JanDvorak Then it's not the same thing at all. It's not that it's a "bad practice" in a var statement, it's wrong. It's not doing what you think it's doing.
 
Alright, I'm going to try it!
 
Fuck it's hot outside
 
@monners where?
 
Melbourne
 
It works, yay
Hot?
 
5:07 AM
oy
 
can anybody help me with a code to force download xml file in javascript
 
43 Degrees
 
F/C?
 
@monners which scale?
 
I'm in mid-Michigan so it's pretty cold
 
5:07 AM
Celcius
 
Or at least it has been, it's warmed up a bit
 
43 C is f* hot
 
Dang, 109Ëš you right.
 
Glorious +5C here, which is awesome, as two weeks ago we were in the -40 range...
 
HOLY CRAP
109 degrees?!
Hahaha sorry
Alright, I'm going to put my code on my DS, start it up and give it a shot
Thanks guys!
 
5:10 AM
@RUJordan I don't think anybody would be saying "fuck it's hot outside" if it were 43F :p
 
Maybe antarctica <.<
 
At least it doesn't stay this hot for long
When I was in Texas, it'd stay at 110F for weeks at a time
 
Probably a silly question, but can JS include an html file (like a header/footer file)?
My initial assumption is no, but I just want to make sure.
 
Like a string with markup?
Ugh, I have to ride home in this
 
Naw, basically the equivalent of include("header.html") in PHP
 
5:14 AM
Maybe you can do that with requirejs or something. I dunno.
Why are you trying to include an html file in your js anyway? Query it on the server side or something?
 
I honestly don't want to setup PHP or a database right now
 
So use nodejs?
 
I guess that's my preferred way, but it means I gotta apply node.js for the first time and I'm nervous lo
 
Only way to really learn something...
 
0
Q: How to submit form using backbone.marionate?

Rahul DesaiI am completely new to backbone.marionette. I referred the documentation here. Here is my code so far: var MyApp = new Backbone.Marionette.Application(); MyApp.module("MyModule", function(){ $("#lookup").submit(function(event){ event.preventDefault();...

Experts, please help! I am completely new to backbone.marionette.
 
5:42 AM
Issue resolved. I had missed including backbone.marionette js file :/
 
I know :p
 
I feel so stupid. I had included everything else. :/
@meagar what do you think about my code now? Am I heading in the right direction?
 
No idea
 
6:03 AM
This question appears to be off-topic because it is about how to use a while loop. — RUJordan 26 secs ago
if a question asks about something that isn't a question tag (eg github.com/fontello/fontello), is that ok to make a tag? I'm wary of this one because it's a font thing, not a code library
 
@RUJordan is it relevant to the question and is it useful to categorize questions related to it? Then create.
If unsure, you can still create and see if it gets edited out.
 
@rlemon Hahaha, "don't send me pictures!" XD
@monners Let's go some psychoanalysis going!
 
6:20 AM
@JanDvorak thanks
 
hello
 
\o
 
o/\o
 
0
Q: New Tag Editing

RUJordanI created a tag, since it did not exist in a question, and I did a search on it; quite a few results. I was going to edit the tag in to them, but I figured I should check first. If I create a new tag, is it a bad idea to edit into every question that does not have the tag? (Maybe not every, but ...

 
6:30 AM
@JanDvorak: just set up a private chat room with Justin... soz for polluting :)
 
is anyone familiar with the jquery UI library?
 
@Jaigus heard of it; it's quite negatively popular in this room
 
@JanDvorak oh ok lol, I was just having this weird problem; I'm simply trying to call the .draggable({helper: "clone"}) method, but I keep getting the ".draggable(...) is not a function" error
apparently im getting another type of object when calling $()
 
or maybe the lib isn't included correctly?
jQueryUI is a separate entity from jQuery
 
^
 
6:36 AM
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
are what I included
 
Are those included before or after the code?
 
@RUJordan $ appears to be a function
 
the code is in a separate file
 
@Jaigus link to the page code?
 
Sounds like you need to use noConflict
 
6:39 AM
<script type="text/javascript" src="javascripts/jquery-1.10.2.min.js"></script>
would including that cause the conflict?
 
@Jaigus can we see the whole head?
 
ok i have to create a fiddle
 
but yeah.. you shouldn't use two versions of jQuery at once
 
^
 
namely, the sequence [jQuery, jQueryUI, jQuery] overwrites the version of jQuery with UI with the version without.
 
6:42 AM
they're not in the head they're at the bottom of the body
 
Use one version of jQuery, and make sure the DOM is loaded before the JS runs
 
then it could be that the library hasn't loaded yet?
sorry but how can I ensure that the DOM has loaded before this?
 
@Jaigus placing the script at the end of body totally suffices.
 
3 more meta post with 2 score or more and I get a silver badge <3
 
$(function(){
    //call your function, DOM is loaded inside these braces
});
 
6:50 AM
3 mins ago, by Jan Dvorak
@Jaigus placing the script at the end of body totally suffices.
 
7:11 AM
@web2students.com That alone doesn't mean the DOM is loaded
 
@monners what you mean?
 
@monners how come it doesn't?
 
My function will be called after DOM is loaded
isn't it?
 
@web2students.com If it's placed at the end of the document, then yeah. But that's not how I read it.
 
@monners explain please.
 
7:15 AM
@monners it ensures that anywhere in the document
 
@JanDvorak Since when???
 
@web2students.com That function will be called when the document is ready, not when it's loaded and loaded all assets
 
$(document).ready(function() {}); Sure.
 
@monners since the time $(function(){...}) became a valid shortcut for $(document).ready(function(){...}) (that is, since jQuery 1.0)
 
@monners mine and yours both are same i think
 
7:17 AM
!!tell monner jquery jquery
 
News to me :P
facepalm
 
what would be the use otherwise? :-)
 
@JanDvorak Hence my comment. I've never seen that done
 
Yeah, i would like to know that :)
 
7:19 AM
@web2students.com My apologies
 
OT: I love the "swipe to clear a notification" gesture in Chrome 32
 
@JanDvorak My kitchen table has the same functionality
Usually results in undesirable side effects for the floor though
 
@monners is your kitchen table as smooth as my computer screen? :-)
 
7:21 AM
@monners don't be. i feel proud when i spot mistake of someone specially at this chat room that shows i have more knowledge :P
 
@JanDvorak That depends, is your computer screen made out of saphire and unicorn tears?
@web2students.com Way to twist the knife...
 
@monners does a gorilla glass count?
 
@JanDvorak ... fuck
 
<script type="text/javascript" src="javascripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
 
@Jaigus don't include two different versions of jquery
 
7:22 AM
strange when i remove either of the first two libraries, jquery doesn't seem to be loaded; i get the "$ is not a function" error
 
@Jaigus are you using $.noconflict?
 
ah I wasn't.
 
!!beer or wine
 
@monners beer
 
Too late
 
7:23 AM
!!bear or whine?
 
@JanDvorak bear
 
I'll bear with it, then :-)
 
thanks guys, the code no longer produces errors, but the canvas isn't draggable either lol. Is there some kind of nuance regarding the canvas element and draggable function
 
@Jaigus is some event handler preventing event propagation?
 
why not showing us at jsfiddle.com ?
 
7:29 AM
Is setInterval supposed to drift like that? It appears to run about one milisecond each few seconds slower than it should run.
setInterval(function(){console.log(+new Date)},1000)
 
I've always been aware it's not accurate, that's why some people prefer to setTimeout it
 
sure, but I thouught it was not supposed to drift like that?
 
> you will see thatsetInterval and settimeout both will not execute the code at the exact specified time you tell it. with setInterval(f,1000); it will wait AT LEAST 1000MS before it executes, it will NOT wait exactly 1000MS. Other processes are also waiting for their turn to use the CPU, which causes delays. If you need an accurate timer that times at 1 second. I would use a shorter interval, like 50MS and compare it to the start time. I wouldnt go under 50MS though because browsers have a minimum interval
> "Chrome and Chromium provide an interval that averages just over 41 milliseconds, enough of a difference for the second clock to be visibly slower in well under a minute. Safari comes in at just under 41ms, performing better than Chrome, but still not great. I took these readings under Windows XP, but Chrome actually performed worse under Windows 7 where the interval averaged around 46ms." taken from
 
@web2students.com yeah sorry, theres alot of code and images I'd have to edit out; so far I've been hanging in there with general troubleshooting tips :P
@JanDvorak no, should I implement one and call preventDefault?
 
@connorspiracist sure, but shouldn't there be corrections to the accumulated drift?
 
7:37 AM
@JanDvorak There should be, if setTimeout can do it spot on then so should setInterval
 
@connorspiracist setTimeout will drift. It's only better at ensuring minimal spacing between events.
 
@JanDvorak does it?
 
@connorspiracist if a callback delays, the next one is scheduled later by that amount
(plus the execution time, if you schedule at the end)
 
i suppose :/
 
Here's a drift measurement fiddle: jsfiddle.net/8YcmA
 
7:44 AM
this is better to see
 
7:58 AM
I'm making a plugin api, what do you think?
module.exports =

	pluginName: 'Rating'

	models:
		Stars:
			rating:
				type: 'integer'
				required: yes
			id:
				type: 'string'
				required: yes

			belongsTo:
				type: 'string'
				required: yes

	routes:
		rateIt:
			type: 'POST'
			match: '/rating/create' # will be /api/:storeId/rating/create
			action: 'Rating.create'


	events:
		validate:
			event: 'stars:beforeValidation'
			action: 'Rating.validate'


	Rating:
		create: (params, next) ->
			Stars.create(params).done (error, star) ->
wow
wait
 
What's that language you're using?
 
That doesn't look like valid js
 
I'd say coffeescript
 
coffeescript
 
I liked it better when it was called coffeescropt.
 
7:59 AM
the plugin doesn't have to be written in it though
:)
So, my plan is to make it as powerful as it can be
 
That's for node.js?
 
You can create your own database table with models
@Kippie yeah
you can define you're own routes
that will be prefixed with api/:storeId/:pluginName/:route
You can listen on core events like user:create then modify the data before it get's created
I'm not letting the plugins have access to global || GLOBAL though
 
Does each plugin have to be in its own module?
 
@Kippie yeah
 
Well, I guess it's neat. Haven't really gotten around to playing with node yet, though, so can't say anything else :)
Nevermind the fact that coffeescript syntax is complete gibberish to me as well
 
8:06 AM
@Kippie it's like python for javascript :-)
 
coffeescript is good
 
actually
is it possible to prevent access to global?
If i did
all you have to do is
setTimeout ->
    # access global again
hmmmmmmm
Anyone have any suggestions for security?
 
don't put your stuff in global?
 
@FlorianMargaine Using sailjs, it is by default
 
8:16 AM
@connorspiracist Use Object.defineProperty
 
don't use a sucky framework
 
@FlorianMargaine It's not "sucky"
Plus, there are no other "good" alternatives
 
I thought sailjs was pretty much the standard?
 
looks shit
 
8:19 AM
Hello guys :)
 
@phenomnomnominal I don't get your point? Use it for what?
@phenomnomnominal to remove global?
@FlorianMargaine was a joke btw
 
@connorspiracist to define some properties like freeze, getters/setters, etc, on whatever you want to protect
 
@FlorianMargaine Basically, what i would have originally done, was prepended global = GLOBAL = undefined; at the top of the plugin file
 
what do you want to do?
 
Prevent access to global throughout the whole file, or create my own version of global
 
8:29 AM
why?
 
Because my models are global, it's default with sails, so they can do CreditCards.find(); // got all
 
not much you can do. You're running the code of your plugins anyway, so the plugin can do anything like search all files and read the code or whatever
 
@FlorianMargaine only if global's there
 
even if it's not there
it can have access to your database
it can read your config files, get all the data, etc
so you're trying to see a problem where there is none
 
8:34 AM
require('fs');
 
But, isn't that on global?
 
nope
oh wait
you want to hide the global object, or every object stored in global too?
you don't want people to create arrays or objects?
... or functions?
 
@JanDvorak thanks alot for steering me the right way
 
I suppose it'll be easier to hide my private methods/properties
 
if you want to hide that, yes. But plugins are code you run, not an external entity. You should treat it as such and give it full power.
if you want to have external entities, use a 3-tier architecture
like, your core is a webservice, and plugins attach themselves on it
 
8:38 AM
Yes, i shouldn't give them full powers though
 
Because that's dangerous
 
plugins are a bit of code that you trust
if you don't trust the code of your plugin, then run it as an external entity
 
Well, i don't trust
 
because you're never going to be satisfied
 
8:39 AM
The point is
You can have a store
and you can create a plugin for it
that's fine
but if they have all powers
 
if you run the plugin as part of your code, it can access anything your main app can
 
then they can get information about other stores too
 
then you want external entities
the code in your plugins is run code, it can do whatever the heck it want
 
so
what should i do
 
have the main app as a webservice
plugins are apps that register themselves on the main app
 
8:41 AM
You mean like an api
 
and the main app dispatches requests to the right sub-app
like a web service, yes
every app is a webservice
a main app has such methods
and every sub-app has the same methods
well... you get the idea
 
I don't see how it's possible to give the plugin the powers i have already got with a webservice though
 
send some objects with the requests?
 
I'm confused
are you saying the plugins should be on a different server?
 
res.render(JSON.stringify(someObj));
yes
in reality, they can be on the same server, but conceptually it's another server
 
8:44 AM
hmm
and how would i communicate
 
it's the only way to make sure the plugins have only the power you give them
with a REST API...
 
Yeah, it sound decent
 
no matter what you try, if you run the plugins as part of your main app, they'll have access to whatever they want. You can't fight it.
 
@FlorianMargaine ok
How do i find info on how to do this on the same server?
 
run them with different ports
 
8:47 AM
right
 
$ node app.js & # runs on 80
$ node plugin1.js & # runs on 6666
$ node plugin2.js & # runs on 7777
6 mins ago, by Florian Margaine
plugins are apps that register themselves on the main app
 
@FlorianMargaine but i would have just 1 plugin server, right?
 
the "register" gives info on IP/port of the plugin
@connorspiracist you can have as many as you want.
 
why would i have more than 1
I'm looking forward to this :)
start on it now
 
in a production environment, each plugin should have its own user so that it can't see the code of other plugins
 
8:49 AM
Is Bard going to kill Smaug in next Hobbit?
 
or require('fs') would allow them to get infos about other plugins
 
A server for each plugin sounds bad
 
@EnglishMaster I didn't read the book, was it in there?
 
@FlorianMargaine I could just replace this in all files though right
file.replace("require('", "require('./");
right?
or something along those lines
 
Yeah, and Bilbo is going to try to sell his Arkenstone to Thorin instead of handing it over to him for free. Furthermore, Thorin won't share golds in Elabor with Bard and Wood elves so they will declare a war with Thorin
 
8:52 AM
@EnglishMaster Thanks a fucking lot
 
No worries
 
Just tell everyone the story before they watch it
@FlorianMargaine Thanks for that, sounds like a plan
 
To be fair, the story is like 60 years old...
 
@connorspiracist What do you mean? The movie is based on a book.
 

« first day (1186 days earlier)      last day (3761 days later) »