« first day (1088 days earlier)      last day (3876 days later) » 

8:04 AM
I'm forced to look into some PHP script. shudders
urgh omg urgh ...
Instead of using json_encode they echo out a JSON response using actual echo calls.
 
@BenjaminGruenbaum for tipranks?
 
sigh Let's fix this crap.
 
@Esailija No, for the public knowledge workshop. It's an open source project team in Israel that takes government information and explains it to the public. Taking unorganized and badly shaped data and showing it to people in an understandable way.
 
@BenjaminGruenbaum, Why is it a bad idea to use antiforgerytokens with ajax calls, though? Is it because they should originate from the same domain anyway?
 
ok.:)
 
8:09 AM
@SunilBN Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
@Kippie It's not that it's bad as much as it's redundent. AJAX requests are usually sent with an additional header, normal GET requests (like a common CSRF vector) can't do that.
 
I have installed nodejs and I am using MySQL.
Can someone help to render the data from database to my front end?
I'm stuck and haven't found much on internet.
Can someone confirm me if I can do all the DB operations just using nodejs. JavaScript ?
 
But the redundancy being for the reason I gave?
 
You can just validate that header and you're all good.
@SunilBN You use SQL, it returns JSON objects, you work with those... at which stage are you stuck?
 
I have installed NodeJS
and I have no clue how to render the data to the frontend
I have executed on cmd, and nodejs os working
 
8:11 AM
Did you get the mysql driver? Did you read the docs on it?
 
yeah i installed the driver
Its working fine
 
@SunilBN So, let me just sum this up. You've installed Node.js and a SQL driver and now you're stuck?
 
Yeah
 
So what is the question?
 
what exactly to do get the data on html page?
 
8:12 AM
But you can query the data you need?
 
You're asking "how do I build a backend" ?
 
using JS
 
@SunilBN look into an expressjs tutorial, or even a sailsjs one.
 
yeah
Can't I do without any of those?
 
Take note that NodeJS requires a much better understanding of things like the HTTP protocol and how network traffic works to be very potent. It's geared towards experts.
@SunilBN Yes, you have an http module which you can use with require("http") and even a net module which you can use to write your own HTTP server on top of TCP if you'd like. It gives you as fine grain of control as you need.
 
8:14 AM
@SunilBN of course you can, you would just recreate them on the go, but a more sloppy and bugged version that does less.
 
However, in the npm world, you don't have to reinvent the wheel every time. You can do anything you want but rolling your own server means your own routing, your own handlers and your own anything. The http module gives you hooks to the request and response objects and that's it :)
 
Doing less isn't necessarily bad though.
 
Doing less is usually better
 
More sloppy and bugged is however.
:D
 
can you tell me step by step to do this?
I am new to this nodeJS
 
8:16 AM
@SunilBN the NodeJS philosophy is very different form the Python one for example, you have a tiny base library and then a robust and powerful package manager to load whichever suits you best.
@SunilBN Read nodebeginner.org
 
ok..
Thank you
if u have solution documented or something, please post the link
Thanks in advance
 
It (nodebeginner.org) is the best 'getting started' book. It goes through creating a basic actual server based on the http module.
If I may ask, do you have any previous backend experience? Why did you choose Node over other technologies?
 
I have experience in PHP, JSP in backend
 
Why are you using node for this project?
Or are you just looking to learn it?
 
as per my project requirements, I have been instructed to do it using nodeJs
I would have never chosen this otherwise
 
8:20 AM
why did you accept the project then?
 
hmmm I'm not in situation to tell more about it. Sorry
 
If this is for project requirements definitely use Sails (or at least express), if you come from a PHP or JSP background chances are you have no idea how backend actually works. You'll have to learn a lot in order to be effective in node without those tools.
 
Meh. Just spend a day with nodebeginner.org at least then
and spend an hour learning how HTTP works
 
ok. Thanks :)
I will see to it
 
Most PHP programmers I know don't know what HTTP status codes are, what headers actually mean or how sessions work. I'm not even talking about how to structure an app well :)
Good luck, if you run into any trouble feel free to ask.
 
8:23 AM
Sure!
 
@ManjunathBavihal Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
0
Q: why javascript is widely used scripting language in web applications?

Prem AnandI cant find plugins written in other languages other than javascript. There is browser support only for Javascript. Why didn't they use other scripting languages other than Javascript when people started using scripts on their web pages? Why javascript was given priority?

 
This is the kind of stuff I'm dealing with. paste.ubuntu.com/6208403
 
any idea if there are plans for including a signature of console.group taking a function as a second argument? It should act as its one-arg equivalent, then call the function, then end the group.
usage: console.group("calc", do_something_loud)
 
I hate your function name.
 
8:30 AM
do_something_loud is not the function name I'd use in practice, though.
or are you talking about snake_case?
what's pg_, PostgreSQL?
 
Yea to both.
 
custom-built JSON encoder WTF
 
I know ...
 
apologies for snake case
I've learned that from ruby :-/
 
It's common in Python too but I refuse to use it.
 
8:33 AM
Java uses CamelCase, but f* Java
 
I know but it just looks better.
 
I guess it's a matter of taste
I don't mind either
for ( $i=0 ; $i<count($aColumns) ; $i++ ) is a WTF. Why not use foreach?
not to mention count is called on every iteration
 
is it really?
 
0
Q: How can I fix Firefox JavaScript copy/paste? Xubuntu

tripleeeSome sites put helpful text in JavaScript text boxes, but I find that Firefox refuses to copy these things to the system clipboard. Is this a feature of Firefox, or XUbuntu, or just a local problem? For example, if I visit http://lmgtfy.com/ and type in a Google query, there is a JavaScript box...

 
In java, for instance, it's called just once.. in fact you can't use for loops for growing collections
you have to use while
 
8:37 AM
@Neil not if you write it like this
 
@Neil No, it's called at each iteration
 
foreach caches the length
 
I'm completely rewriting that code now.
 
@OctavianDamiean maybe it was written before json_encode existed. I've already seen this kind of code in such codebases.
 
@FlorianMargaine I'm afraid they can't use that as an excuse, it was created in 2010.
 
8:38 AM
ha :)
 
Why did I imagine "I'm completely rewriting code" in the melody at the end of Total Eclipse of the Heart?
 
@Esailija is the github version updated?
 
@Dave-88 ok... I've found the cause after finally looking at the right place
 
8:53 AM
Anyway, the PHP code I posted earlier can be replaced with three lines.
while ( $data = pg_fetch_object( $rResult ) ) {
    echo json_encode($data);
}
Well, not quite, but almost.
I just need to pack them into an array, then that array into another object.
 
@Dave-88 when you show/hide the left panel, you animate the content left position. When you show/hide the right panel, you animate its right position. You also set its width from CSS. What happens when all three are set?
 
@NitinJadhav Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
9:09 AM
@BenjaminGruenbaum yes it has commits as I make them
then occasionally I bump version and npm gets latest too then
 
@copy You're a Pink Floyd fan, right? cheezburger.com/7836867584
Wish You Were Here should have been between Dark Side and The Wall, but maybe they didn't have a redhead.
 
9:29 AM
@BenjaminGruenbaum I am doing non-error wrapping for promisify, is there something I could be missing that would make this a bad idea
basically if you call either of these
var throwsStrings  = Promise.promisify(function(cb){
    throw "Where is your stack now?";
});

var rejectsStrings = Promise.promisify(function(cb){
    cb( "Where is your stack now?" );
});
they promise will be rejected as an actual new Error with the primitive as a message rather than that message
 
@Esailija I think it's a good idea. The resulting error object still gives me access to the original error though, right?
 
hmm no :D
it turns it into a string
 
and uses it as a .message on error
 
We're talking about the case where I throw a non-error from a function that I promisify?
 
9:32 AM
for instance fs.exists throws the boolean true as an error
 
fs.exists is broken and nobody uses it anyway.
 
in 99% cases it would be some string anyway
because the API maker didn't know better
so they have cb("failed to read file") in their code instead of cb(new Error("failed to read file"))
 
Hmmm. so you want to turn strings to error objects of strings?
Is throwing strings in any way shape or form faster?
 
strings don't have the stack
when you do new Error - it collects the stack trace and places it on .stack
 
Yeah, that I know - that doesn't mean it's always faster though.
I wonder if it is.
 
9:35 AM
you are comparing if creating new Error, which collects stack trace, is faster than referencing constant string from intern pool?
but it doesn't even matter because the exceptional situation doesn't need perf :D
but the problem is that if some API we promisified doesn't throw errors like fs.exists
then you don't get any stack, short or long
 
Yeah, throwing a string is 500 times faster.
(while you're at it - fix my benchmark :P)
 
looks about right to me
 
Some people use exceptions for flow control :P Have you ever seen Python?
 
creating an error is only slow if you collect the stack trace
 
Ruby has two different sets of throwing
 
9:40 AM
@Esailija so the problem is fs.exists throws a string and you don't reject based on it? Or just the stack trace?
 
basically if you use IterationException to flow control, that's fine if you don't collect trace
but here is no flow control but exceptional situation that we better get a good stack for
 
github.com/joyent/node/issues/6311 went to look for anything on fs.exists and found this :)
 
ruby has throw/catch for ordinary flow control (no stack trace), raise/rescue for exceptions (complete with stack trace)
 
@Esailija that's not fine for a bunch of other reasons though. I totally agree with you on having better stack trace being more important.
 
I mean fine from perf standpoint
 
9:42 AM
Yeah
 
maybe I will just wrap primitives.. that catches the 99% problem
 
I'm not sure I'd wrap anything, returning a different error because of the promise library should either be done always (even if an error was thrown) or never , otherwise it sounds very inconsistent to me
 
even if an error was thrown ? wtf
you cannot wrap error
there is .message
that must be string
 
You can't add a .internalError to error objects?
 
I can but then I actually have your problem
 
9:46 AM
what problem?
(This is pretty much what C# does, if a Task (or multiple tasks) fails you get an AggregateException about the task, with an InnerException property containing the exception actually thrown)
 
@SrikanthRayabhagi Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
I don't need that since js is dynamic
what I need is an object so I can attach extra trace
you cannot attach to primitives
 
ok, I'm making a "you can't js under pressure" clone, and I'm a bit stomped on passing the test cases to eval. It's possible to generate an assertion of sorts, as we have the function name, parameters, and expected result, so something like: eval(userCode + "\n;assert(" + funcName + "(" + parameter + ") === " + result + ");")
However...that's just horrible
 
what might be the reason for not able to listen for dispatched simulated event?
 
But horrible may be my only alternative...since evaling it is already horrible.
 
9:48 AM
@Esailija So this is entirely for stack traces?
@Zirak Y no function constructor?
 
@Zirak the user code can throw an exception
 
@JanDvorak It's wrapped in a try catch
@BenjaminGruenbaum Since it's only executed once, is there any difference I'm not aware of?
 
@Zirak let's play a game: You want to make a tight sandbox, I want to break out of it
 
The bot's eval is a sandbox, but since this runs on the client machine, I don't care if he does stupid things
 
9:50 AM
userCode = "("
let this run on the client machine, too
 
@Zirak scoping.
 
don't keep anything sensitive in the global scope
 
What's sensitive? It's the client, he can fuck it up any way he wants
I don't care if they act stupid
 
s//or /
 
What?
 
9:52 AM
I mean ,you don't have to do both
 
@Zirak That's right! You never care, you bastard!
 
oh, missed the first one. Since this'll run on a dedicated worker, it'll always run on the client
And I think you're gonna like the questions I cooked up...the last one is a bit mean
 
yeah.. just let him do stupid things
lots of strict test cases?
including weird edge-cases?
 
I'll try and be fair on that part, I've really loosened the last couple of questions so you won't have to worry about edge cases, and focus on the logic. But the last question itself seems a bit bombastic (or at least it seemed that way to be)
 
like 90% of the final score?
 
9:56 AM
Wait...actually...if I eval the user code, which defines the function we test against, then I can just run the assertions as regular code.
...why didn't I think of that
 
@Zirak rlemon and me harvested shitloads of ectoplasms and other crap for you and you don't even care.
 
Correct
 
Oh humanity!
 
well if people want to cheat, they will
 
'course, I don't intend on trying to stop cheating.
 
9:58 AM
at the very least, they can send a fake XHR to your leader board
 
Do you think it's cheating if I enforce the user to put his function on a predefined object?
 
why would it?
 
Instead of function something () {}, obj.something = function something () {}
Cheating on my part, that is
 
that's close to how jswarrior works
 
Because I don't want to write more eval, and since I know the function name, it's a simple property access
 
10:00 AM
you still have to use Function
 
Anyway @FlorianMargaine and @JanDvorak the PHP snippet from earlier rewritten the way I need it.
    $aReturn = array();
    $aItems = array();

    while ( $data = pg_fetch_object( $rResult ) ) {
        $aItems[] = $data;
    }

    $aReturn["items"] = $aItems;
    echo json_encode( $aReturn );
Looks a lot cleaner me thinks.
 
Why the Hungarian
 
@OctavianDamiean yeah
 
@Zirak Coding convention conformity, I had to edit a script someone else wrote some time ago.
 
@Zirak for consistency I assume
 
10:03 AM
Sucks to be you
 
It does.
2 hours ago, by Octavian Damiean
This is the kind of stuff I'm dealing with. http://paste.ubuntu.com/6208403/
 
I don't really hate hungarian that much
 
For your reference, this is what I started with.
 
I don't hate Hungarian notation either. But I don't use it myself
 
I use hungarian for jQuery objects
 
10:06 AM
@Elegiac Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
hello
 
When I sent them a request that they change the structure of their JSON response a little they were like "Aw crap, that's such a big pain ... don't you wanna do that yourself if we give you the code?"
 
hello
 
anyone here good in regex? :)
 
I didn't understand why it was such a pain until I saw their code. :D
 
10:06 AM
@Elegiac depends. Are you a help vampire?
 
lol
 
1 min ago, by Caprica Six
@Elegiac Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
Ask away
 
im from the other room
 
I'm from the other planet.
 
the one we've created as a trap?
 
10:08 AM
nope
the one you can see sharp
 
;)
 
ho vampire feeders there? :->
 
@JanDvorak OH MY GOD! Best idea ever! We create another room called JavaScript with the description "Free JavaScript help and code" and name this one IT'S A TRAP!
 
We should create a room named "this world". "Do you really want to leave this world?"
 
10:10 AM
The other chat room would consist of two or three bots that just answer peoples messages with random gibberish, basically just like here and we stay in there and enjoy the show.
 
hi
Who know the program (free) that I analyze game flash on-line?
There is a FlashFirebug the plugin of a browser but this is not a free...
 
how can i get
Person in function Person(firstname, lastname)

using Regex ;)
anyhelp would appreciate a lot
 
@Elegiac hell why?
 
im doing a code-editor for javascript using c# @JanDvorak
 
Then you should use a proper js parser
 
10:11 AM
thats a honest approach :D
 
How's that a JavaScript question then?
 
but im still a noob programmer @Zirak
 
esprima.org and marijnhaverbeke.nl/acorn are two possible ones
 
cant do a good parser / lexer
 
"Use", not "build".
I've used acorn several times, it's quite nice, and several editors/checkers use Esprima
 
10:12 AM
cant use 3pp either :( thats the saddest part
 
Then don't write it
 
aw y
3 mins ago, by Elegiac
how can i get
Person in function Person(firstname, lastname)

using Regex ;)
 
Is it a homework or something like that?
 
0:)
 
Extracting language chunks is a difficult task. If you can't do it right, don't do it at all.
 
10:13 AM
for work purpose @OctavianDamiean
 
Because you're going to be in a world of pain.
 
better change your employer, I'm afraid
 
i need to do it for my job @Zirak
 
Why wouldn't you be able to use a 3rd party tool?
 
were doing a product
 
10:14 AM
@Elegiac Then you better change your requirements to include 3rd party scripts, or write one yourself.
 
@Elegiac So?
 
but not much ide
 
acorn is licensed under MIT and Esprima under BSD, shouldn't be a problem.
 
Yea, they're very permissive licenses.
 
@Elegiac I know it's tempting to resort to regular expressions, but they're not the right tool for this job. Languages like js are state-sensitive, the same text may have completely different meaning if it appears in one place and not the other.
Now, you want to do a good job, right? Then use the right tool for the job
 
10:22 AM
but im doing it on c# is there a way i can convert a js parser into c#?
 
In your example, how will you tell these apart:
function Person()
var Person = function () {};
var msg = "function Person";
var lookup = /function Person/
Doesn't Windows have a ScriptEngine to parse execute JScript?
 
@Elegiac I haven't used it, but a quick google search got me this. github.com/fholm/IronJS
 
@OctavianDamiean is it written on c#?
i need a c# parser for js language
sorry for interrupt
 
4
Q: Parse JavaScript code in C#

Igal TabachnikI have the following JavaScript code as a string literal: var $Page = new function() { var _url= 'http://www.some.url.com'; this.Download = function() { window.location = _url; } } Is there a way I could get the value of the _url variable from my C# code? An open sourc...

Can we please all go down-vote this answer?
 
18
A: parse and execute JS by C#

Simon MourierTo answer the question title "How to parse and execute JS in C#", here is piece of code that wraps the Windows Script Engines. It supports 32-bit and 64-bit environments. In your specific case, it means depending on the .JS code, you may have to emulate/implement some HTML DOM element such as 'd...

 
10:26 AM
@Zirak yeah probably windows have jscript ... but im not sure if msjscript was the same as javascript
@OctavianDamiean done >:D
 
well, that descalated quickly
 
@OctavianDamiean Are all just downvoting an answer from 2009 ? The guy will wonder :)
 
yep
the other answers mostly suck, too
 
@dystroy That's good, hopefully he'll learn something from that.
 
let me coin the term "parallel downvoting"
 
10:29 AM
He probably already learnt, if he's still around. But I have no problem with dowvoting, that was a bad answer.
 
@Anibel Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
@JanDvorak You probably should look for "mob" or "fork"
 
Parallel forking?
 
I don't think we should fork the answer
unless you mean "fork" as in "torches and pitchforks"
 
this is for temporary only ... though i know im wasting my energy for such an alternative
:/
 
10:31 AM
@OctavianDamiean this looks like a kind of pleonasm...
 
one japanese b-word came into my mind, too
 
How is it that we all know only one Japanese word starting with a b (a word that probably at least half Japanese ignore) ?
 
What do bonsai have to do with it?
 
Well, did you even look at a bonsai ? This ridiculously small and insufficient thing ? It's an obvious parabol for this answer.
 
10:34 AM
well, what should the forks be made of? :-)
oh, wait, regular trees should fare better
or even sheet metal
 
@dystroy Probably because we're not Japanese (at least most of us) and because Japanese is not exactly the lingua franca in our domain?
 
uuhhh...I might know another one...
 
@user1821727 Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
@Zirak I know only one word in total methinks. Gaijin
 
> Possible duplicate of ... itself. Damn.
 
10:37 AM
No, probably not. But one of my favourite words right now is "Sabishi", loneliness. It has such an incredible flow to it, gives it a sad and powerful tone. At least when Megumi Hayashibara (en.wikipedia.org/wiki/Rei_Ayanami) says it.
 
@Dievardump u there ?
 
do we have any japanese in this room?
 
@Zirak Is that "Sabishi" word safe for googling ? You promise ?
 
Yeah, it means "loneliness"
Or "lonely". Something of the sorts
 
Oh god, I totally abhor anime. :/
 
10:38 AM
@dystroy text search is always safe
 
!!/google Sabishi
 
@OctavianDamiean So do I, it's one of these fields which follow Sturgeon's Law so brilliantly. But having watched less than a handful of good shows, the good 10% is amazing.
Evangelion, Gunbuster and FLCL are amazing shows.
 
I only now hajimemashite, teme, yakubyougami, shinigami, bi, ai etc ^^
 
@Zirak And I also hate you because you always make me look up fancy laws.
 
10:48 AM
anybody in montreal around ?
 
@Esailija So the problem is just the stack trace?
You're trying to fix the default behavior of functions that don't do proper stack traces?
 
If someone throws a string that's their problem imo. I think fixing it for just strings should solve 99% of all cases
 
yea it just does it for primitives
well there are 3 parties.. promise, some random lib that throws strings and the promise user
 
@TommyCoffee Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
10:55 AM
Why primitives? When did you see anyone throw undefined, bool null or Number?
Why not just strings?
 
strings are primitives
 
And at least give the option to opt out, maybe only do it if longStackTraces is enabled?
@JanDvorak right, as well as undefined bool null or Number - which I don't see why he's handling there.
 
you cannot attach properties to strings
it's cleaner to handle all primitives right away than later on check the other primitives
 
I know that, they autobox and then unwrap and the property goes bye bye
What if I want to throw a string and I don't care about the stack trace?
 
who are you in the 3 parties
are you bluebird, mongo, or mongo& bluebird user
for example
 
10:57 AM
user, for example.
 
this concerns when something like mongo db throws strings
not you
 
I don't get why not let people opt out of it if they want.
 
If you throw a string then you throw a string
and it works
 
Why? Doesn't it get wrapped?
 
no
that would be wtfey
 

« first day (1088 days earlier)      last day (3876 days later) »