« first day (1382 days earlier)      last day (3551 days later) » 

12:03 AM
How many of you are buying the Humongous Entertainment Humble Bundle? :P
 
ME
4 hours ago, by SomeKittens Ux2666
also: https://www.humblebundle.com/flash
 
12:20 AM
0
Q: Node js code using promises

GrishaI'm very new o Q library. I'd like to rewrite following code using promises. The code bellow is Sync var items = getItems(); var relatedItems = processItems(items) saveRelatedItems(relatedItems) markItemsAsProcessed(items) Any ideas?

 
12:37 AM
0
Q: Should I emulate '.$promise' objects?

Christophe FondacciI am working on an admin app. The app fetches its data from the server using $resource. I end up with data objects containing '$promise' property to determine when the data has been fetched. Everything's fine. Now, this admin app can also create new objects. Those new objects are managed by the ...

 
1:22 AM
what's a good, simple templating language? No logic needed
 
@Crow JQUERY
 
@Crow What do you mean? Like Jade, or Mustache?
 
@SomeKittensUx2666 I just want files with HTML, that I inject into a div on hashchange event. That's all
 
Mustache is a nice option
depending on how complex the div is, you might not need a library at all
document.createElement('div');
 
it's a pretty annoying amount of html, and there are a lot of them
 
1:27 AM
doesn't need to be super complex, you can write your own mini utility
 
is it also possible to load styles on the fly, or is that stupid?
 
sure it is possible. and it isn't stupid depending on the need
 
basically, this phone thing. jsfiddle.net/4cX8a/5 . I want to load some examples of different pages into it, purely for presentation.
 
use an iframe
much easier for you in the end
 
would it be easy for an iframe to listen to a hashchange?
 
1:32 AM
or if you really want to stick with the html approach just load all of the css at once
@Crow if you own both domains, yea
css libraries like bootstrap are huge in comparison to most sites. loading a few extra fluff that may or may not be used shouldn't effect anything
 
yeah, it probably wouldn't be a big deal... for some reason just feels unoptimized
 
time is money
optimize your time
don't waste it on less than low issues. worry about the big stuff
 
I hafta worry about the big stuff every time I take a piss
 
1:56 AM
I killed the room. Again.
 
They're just jealous
 
@monners media.247sports.com/Uploads/Assets/170/559/559170.gif ............................ ping
 
how come if I do console.log(location.hash), I get two values back?
console.log(location.hash);
undefined
"#hash.mst"
 
If Q/A sends me another ticket about Samsung's default internet browser not working correctly I'm going to kill someone
 
console.log returns undefined
I'm guessing you're pasting that into the console
 
2:01 AM
yep. Is there anything wrong with this?
function updateScreen() {
        var templateUrl = 'examples/templates/' + location.hash + '.mst';
        $.get(templateUrl, function(template) {
            var rendered = Mustache.render(template);
            $('#screen-overlay').html(rendered);
        });
    }

    $(window).on('hashchange', function() {
        updateScreen();
    }).trigger('hashchange');
 
You can just put location.hash into the console
You don't need console.log when you're using the console
 
Ahem, nevermind
 
 
1 hour later…
3:17 AM
0
Q: How to inject a service into a factory

Eric B.I have a REST backend which provides a hashmap of API methods. This allows the front end to use a keyname to map to the API method instead of needing to know the entire REST url. Ex: { CHARGE.GET_CHARGE_INFO: /provider/charge/getChargeInfo/{{providerId}}/{{chargeId}} CHARGE.LIST_CHARGES: /...

 
4:15 AM
allo allo
how do i proceed to learn jQuery , i am being forced
 
4:27 AM
!!google learn jquery
 
that moment you go to fix a bug and realise it's just a symptom of a much larger fuckup
That moment you git blame already knowing what the response is going to be
 
4:53 AM
@monners ...because it's a solo project
 
@Zirak Yeah, which you wrote
 
@monners Yeah, with your goat as the muse.
 
@Zirak I never said it was a blame blame. Just a blame.
Also, nice to know someone's gettin' ma goat.
 
Dude, for some reason, I was certain you were copy
@BenjaminGruenbaum Is it really worthy of deletion?
 
stackoverflow.com/questions/17351494/promises-pattern-in-node-js-libraries-to-us‌​e
Yes, it's a library compare... Those become outdated and harmful very fast
 
5:40 AM
$ means jQuery , funny things i hear from people.. :(
 
How do I explain to my creative director that targeting devices rather than targeting viewports is a bad idea?
 
is .ready == DOMContentLoaded , show him a demo
everyone needs demos these days
 
@blackbee TBF, I've never seen any other use in ages
 
icy
 
Angular
 
5:48 AM
right now i am sitting in th training facility of an office, and i have been enlightened with the fact that closure can be learned in taught in less that two minutes .. "a function returning a function, volla closures!! click click clik!! "
 
6:08 AM
@blackbee what's the fucking point? Just place your JS before </body> and it will be executed when DOM is finished
I have never understood why people keep on using $.ready()
 
@tereško then it won't start loading before DOM is done loading
 
emm .. I'm not following
 
6:23 AM
if you place a script tag at the end, the browser won't know about it until it's done loading the page itself. Ideally you want to be downloading the javascript soon
 
why exactly is it that you cannot put your "libraries that should be loaded while DOM is loading" in the <head> and leave the executable part at the bottom ?
 
I want the main script to be loaded fast as well
 
that sounds like poor organization
 
why?
 
No you can have a flash if you put the scripts in your body when you have to hide some stuff or something
 
6:26 AM
@FlorianMargaine ideally you should be doing that in CSS. Otherwise you're even flashing with $.ready
 
If your "bootstrap" (do not confused with shitty framework, abusing a common term) part of the code is so large that it has to be preloaded, then it means that your bootstrap is badly written.
Everything else is just a bad excuse to keep pretending that $.ready() is somehow essential
 
I could reduce the bootstrap code to call App.run(), but sometimes I don't have an App class
actually, usually I don't.
 
I hope you are aware that having a single-like-bootstrap "just because" is as stupid as having a 1000-line one
 
what do you suggest for a bootstrap code, then?
 
wiring of various dependencies between libraries, DOM binding where necessary, configuration
 
6:34 AM
dependency injection? What I write isn't that big
 
then you have one less part to have in bootstrap, but yeah, I was talking about dependency injection for when you are using some reusable bits of code
 
@Kippie stop it please
 
... and now there is a new user in the tiny-avatar-people list
 
1 message moved to Trash can
@tereško $.ready is actually nice, $(function(){}) or $(document).ready suck :D
 
is there actually $.ready?
 
6:47 AM
@JanDvorak Yep
Morning
 
@BenjaminGruenbaum ok, well .. that's another level of terrible right there.
 
@SecondRikudo that's $().ready
 
Indeed it is
So I don't know :D
 
:D
@JanDvorak yes, it's a promise over being ready, it's not very well known. jQuery internally uses promises for .ready.
 
@BenjaminGruenbaum Alarms at 2:30AM :(
 
6:50 AM
@SecondRikudo not in Jerusalem
 
@BenjaminGruenbaum nice. Is it documented?
 
Nope, but in Tel Aviv
lol
 
I actually use $.ready when using jQuery a lot more often than $(document).ready since it lets me fetch the data as a promise.
 
10 hours ago, by Benjamin Gruenbaum
!!afk if you have any php or jQuery questions, @SecondRikudo is your guy, no matter how new you are he has patience if you bug him enough. Plugin questions are his specialty.
10 hours ago, by rlemon
!!afk driving home. @SecondRikudo told me he especially enjoys being pinged about jQuery plugin questions. Make sure not to share which plugin you are using, and be as vague about your issue as you'd like.
Where the hell did that come from ? XD
 
@tereško as if i knew what is the point .. i saw it in codeschool trracks
 
6:52 AM
Holy crap, 10 more casualties since yesterday :o
 
@SecondRikudo on which side ?
 
@SecondRikudo Ours? As in humanity's?
 
@monners Israel's, I live in Israel.
 
That must be fun...
 
6:54 AM
you probably should look into the casualties for the other side too, since having one-sided information can be really distorting for the perspective
 
@SecondRikudo do you really program in CSS?
 
@tereško I do look into the other side's casualties. I believe it passed over the 1k mark.
@JanDvorak If you can call CSS "programming", then sure.
 
@SecondRikudo well, you call it that
 
My profile readme?
It hasn't changed in... 3 years? XD
 
indeed
 
6:57 AM
$.when(jQuery.ready.promise(), $.get("apiUrl").then(function(_, data){

});
2
Pretty useful I guess.
 
@SecondRikudo =/
does anyone actually remembers how the whole mess begun?
 
@tereško Hmm... someone said Jesus wasn't the Son of God, then someone said he wasn't even a proper prophet...
 
neah, not that part
 
@tereško They kidnapped and killed 3 teenagers from our side. Group of extremists did the same to a teenager on their side. They started firing as a response, all efforts to reach simple conclusion failed.
 
@tereško we do.
@tereško it's all quite horrible, and incredibly stupid actually. Fueled by bigots and racists on both sides, unfair and unjust to both sides. People here that border the Gaza strip live in shelters and children are being traumatized and are getting nightmares - I can't even start to describe what's happening on their side because it's horrible.
 
7:00 AM
@SecondRikudo basically, bunch of shitheads from both sides wanted to make a point .. awesome. And now probably close to 1500 people are dead
 
It's a stupid unnecessary war. We couldn't have avoided it but we certainly do hate it.
 
@BenjaminGruenbaum aren't all wars like that?
 
is .on related to asynchronous something?
 
@tereško Exactly!
 
@tereško that sounds pretty accurate.
 
7:01 AM
Welcome to the Middle East!
 
@blackbee it's the jQuery way to attach event handlers
 
we can just use .on("event" ...) instead of doing .event() or is that we need to be specific.
i was just told, that if new elements are created in an existsing document , then only we use on
 
@blackbee why are you angreh?
 
@blackbee please don't shout at us
 
as bad as my country is, at least it's not middle-east ... then again, if I lived there, I probably would have been killed for being an atheist
 
7:04 AM
no, its the caps lock
 
@tereško oh, I also blame the superpowers more than I blame either side here. They're fighting for influence.
 
i am not angreh
 
@tereško most of Israelis are atheist or for the very least non religious.
 
@JanDvorak What do you mean 'stop it' ? It's not like I'm continuing anything. Besides, similar things have been posted here lots of times...
 
javascript is handy, just did .toLowerCase() :D
 
7:05 AM
Then what's with the "reclaiming the land, that is only described in a fairy tail book" crap, that has been stoking the conflict from your end?
 
@blackbee $(sel).event(func) translates to $(sel).on("event", func). When new elements appear dynamically, you want $parent.on("event", sel, func)
 
ok..
 
@Kippie now you're disagreeing with yourself
@tereško Once upon a time God gave them that land. Now they want to keep it even though God now has quite a different plan
or at least the jews with power do
 
@tereško that's a very loud minority.
 
"shitheads"
 
7:09 AM
Yup.
 
Is it still religiously based, though? Do the settlers really believe they're in the right because God gave them that land?
 
@teresko even though Jews may not be religious, they're still a distinct people imo, like kurds
 
sure ... same goes for gypsies (there was a more P.C. name for that culture, but I cannot remember)
 
Gypsies are more on the nomad side IMHO. Anyway it makes sense for Jews to have a country. The fact that they had one is related to the guilty sense after ww2 I'd guess
 
@tereško Wikipedia to the ... rescue?
 
7:13 AM
actually, I was taught that gypsies are the result of Migration Period in early Middle Ages ... or they could be result of Genghis Khan's exploits in Europe
 
@FlorianMargaine How does it make sense?
 
o/
 
Because they're a distinct people
@GNi33 \o
 
talking about the Gaza conflict?
 
7:15 AM
kinda-ish
 
@GNi33 yep
 
Hi there,
Is there anything bad about using promises for synchronous operations like validating?
 
has there anything changed during the last week?
 
@user2422960 rather, is there a point in doing so?
 
from the perspective of our members from Israel?
 
7:16 AM
@user2422960 do you think they might become asynchronous one day?
 
the news we get here in central Europe is pretty vague
 
@JanDvorak, I prefer the then/catch style over classic try-catch blocks. i find them a lot more readable and I like the easy way of throwing reasons for a failed validation
no, that's unlikely
 
@user2422960 have you considered not using expection handling for this?
 
@GNi33 not really.
 
what kind of validation are you talking about @user2422960 ?
 
7:17 AM
Israel started a one sided cease fire twice again. Was met with rockets again.
 
@JanDvorak, yes. However, after the validation process I need to fire some more operations, some of them are qorking asynchronously. If I could chain evertyhing up in one then chain, I would have a pretty neat block of code
 
these two "options" are a joke, right?
 
@GNi33, simple lookup of an object to determine wheter or not every needed field is filled out
 
@user2422960 or you could throw an if block in the middle
 
7:19 AM
and why would you do a try/catch for these?
i mean, it's okay. Just never did it this way. A simple function that handles this with a return value felt nicer
 
the try/catch wasn't meant for that specific operation. I rather wanted to know if it is a bad idea per se to use promises for synchronous operations
 
I don't see the benefit in it
 
but also no disadvantages?
 
@BenjaminGruenbaum with amount of casualties on the Palestinian side, I am not entirely surprised.
 
@GNi33 yup, people here are mostly for "finishing" the operation by collapsing Hamas.
 
7:22 AM
@user2422960 using promises for synchronous operations seems pointless. Using expection handling kinda stinks. But ultimately it's up to you.
 
that's an answer I can live with :). thank you
 
@tereško for what it's worth, Isreal has offered to end it long before the ground invasion. The majority of the casualties are since then. No one in Israel has any interest in doing anything in Gaza, we withdrew all our forces from there in 2005.
 
@user2422960 if you need every last bit of performance (I guess you don't) you really want to avoid unneccesary allocations and uninlineable functions
 
@BenjaminGruenbaum you cannot "collapse Hamas" by bombing civilians. Each bomb you drop creates 4 new Hamas members.
 
7:23 AM
@tereško you're preaching to the choir.
 
=(
obviously, it's the wrong choir
 
@tereško Isn't that exactly why the ground offensive started? So they could better focus their attacks?
 
@JanDvorak I haven't really thought about performance yet as I am still trying to figure out the tools and techniques to work with. Still good to know, though
 
@Kippie it is, they're not doing it very well though.
Hamas has gotten really good at fighting out of civilian population, they beat up and threaten people Palestinians who want to leave combat areas.
 
@BenjaminGruenbaum do they really want to? In fact, I know of someone with power that doesn't.
 
7:25 AM
@JanDvorak like @tereško said, every bomb we drop creates 4 new Hamas members. They thrive on charity and shock.
I don't blame them, the situation there is horrible, they have very low living standards. They're fighting out of desperation not out of spite.
 
whom does Murica try to help, actually?
 
The only solution is a political one, where both sides get security and dignity. I honestly feel the biggest obstacle to that is global superpowers.
 
jews
 
@JanDvorak itself, as always.
 
hmm... EU? NATO?
 
7:27 AM
Obama already released a statement last week supporting the invasion, though that was before so many casualties occured
 
@Kippie Obama gave up the middle east, he's no Clinton and also - I don't blame him.
 
as expected... the only real solution is to wait for God to "roll up the skies" and remove those with power.
 
Europe is mostly racist and shit scared of Arabs, not unlike parts of Israel.
 
That's just not true...
 
The IDF doesn't really have a choice here though... rockets are fired towards Israel. The US would have flattened Gaza a long time ago.
 
7:28 AM
@JanDvorak Murica want's to help their own electability and their contributors from military-industrial complex
 
I just got caught putting a cheeky comment in the CSS :(
 
@Kippie that has not been my experience, no one even considered banning protests here like France did.
Mosques are allowed to invite people with a speaker here, unlike Switzerland.
 
huh... and I thought vans selling milk were annoying when bursting their moos through the streets
 
Arabic is a recognized language here, we have Arab parliament members, doctors, judges, and even soldiers. I won't say there is no discrimination (there is) but I've seen much much more hate towards Arabs in my trips to Europe (towards Jews too, but less so) than I've ever seen in Israel.
 
@BenjaminGruenbaum fear, or hate?
 
7:31 AM
I have Arab friends and I've never considered it "weird" or "odd", I buy food in an Arab village and when it works out I get my hair done there.
@JanDvorak honestly I don't know... I just remember being shocked by it, especially given Europe's history.
 
the right-wing movement in Europe is scary. And shocking
 
^ it scares me.,
 
With France being right on top there
 
@BenjaminGruenbaum We... don't really have Arab soldiers...
 
The extremists scare me here too.
 
7:32 AM
@BenjaminGruenbaum well, the media here in Europe teach us that terrorists are mostly arabs
 
@SecondRikudo yes, we most certainly do. I have a friend in Magav (combat unit) from Abu Ghosh, Muslim Arab. A guy who went to school with me served in 8200 (Israeli Intelligence - Muslim Arab. I'm not even talking about Druze who are Arabs (but not Muslim).
 
or used to
 
I'll take your word for it
 
@JanDvorak religious extremists are scary, and some of those are Arabs. That's as good an argument as telling people everyone named "John" will try to kill a president because of John Wilkes Booth.
 
@BenjaminGruenbaum People in general are bad at logic
 
I don't think the new generation is afraid of arabs, though
 
@BenjaminGruenbaum The problem is when said extremists are at the top...
 
@JanDvorak you'd be surprised.
 
the development of the european right-wing parties has little to nothing to do with terrorists in my opinion
 
@SecondRikudo they're just very loud.
 
7:37 AM
@BenjaminGruenbaum "Very loud" doesn't get you 1000 civilians killed
 
and nothing with religious extremists
 
"Very loud" doesn't get you 200,000 of your own people killed.
 
@SecondRikudo you'd be surprised.
Very loud got 20 thousand Palestinians killed when they tried the same thing in Jordan in 1970
 
there was a little guy with a beard that was pretty loud
we all know how this turned out
 
pre-requisite to learn node,js apart from javascript?
 
7:40 AM
@Pradeep_Evol 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.
 
@Pradeep_Evol basic idea of server-client separation
If you want to have a database, knowing its query language (say, an SQL flavor) would be nice
most importantly, don't be afraid to research
 
@BenjaminGruenbaum that's what scares me about Europe right now. The topics of speeches, the terminology, the way that fear is created and used by those parties sometimes reminds me an awful lot of about 80 years ago
 
@JanDvorak AND specially about how to prevent injection...
 
@GNi33 scares me a lot more than Hamas to be fair
 
@AwalGarg or rather know not to interpolate at all. Use prepared statements.
 
7:48 AM
@JanDvorak yeah right. node has prepared statements too?
 
@AwalGarg Node.js isn't PHP ;-)
 
kk
 
which is better, learning all windowObject API for client javascript programming, or directly jumping to jQuery
 
if i have
 <div id = "red"></div>
<div id = "green"></div>
then should i do
$('div').event(function() { $(this). ...}):
or just use the id like querySelector
 
@Pradeep_Evol start without jQuery
@blackbee what do you mean by "use the id like querySelector"?
 
7:51 AM
@blackbee that highly depends on what you want to do
but $('div') as selector is rarely a good idea
 
@JanDvorak $("#red") .
@GNi33 ow
 
@blackbee you could use a class
 
but wouldnot that affect all the div's?
 
$(".sth").on("click",...)
 
@JanDvorak and never come to jquery... this is what you were aiming at right?
 
7:58 AM
@blackbee that's the "rarely a good idea" part
 
:D
 
@rlemon Who are you referring to?
 
Hi
 
@FlorianMargaine Haha, that's bananas.
 
8:09 AM
@SecondRikudo inorite
saying "yam you!" sounds so satisfying
 
is there event delegation in jQuery ?
 
@blackbee yes
 
there is even delegation in javascript
 
@tereško no native js method provides event delegation though
 
8:11 AM
@tereško do you mean event bubbling?
 
and the jquery's event-wrapper passes you event object
@JanDvorak same term , different people
 
@tereško nope, it's not the same
 
then how exactly is event bubbling different from event delegation ?
 
event delegation = event bubbling + automatic filtering of events by target
 
event delegation is a little bit more than event bubbling, i.e. it provides the target as the context of the callback
so, "a little bit more"
I wrote a small module to do that in js: github.com/Ralt/delegation/blob/master/lib/delegation.js
 
8:13 AM
$(document).on("click", ".button"...) => you don't get events for non-button clicks
 
function(evt) { evt.target.lot of things}
 
2 mins ago, by Florian Margaine
@tereško no native js method provides event delegation though
 
yes. I had to write my own method.
 
^ that an extremely misleading statement
 
It is not
 
8:14 AM
since event.targetElement || event.srcElement is as native as you get
 
there isn't an "addEventDelegationListener" method
but yeah, it was confusing, my bad
 
no i think
i used addEventListener
 
@tereško yet you want a parent thereof that matches a selector, not the innermost child that received the event
you don't get that part from vanilla JS
 
@JanDvorak i knew it was opposite,
if the child didnot have an eventListener attached, then it would bubble upto the parent which had the eventListener attached
 
It's even worse if you want to support "browsers" that don't support matchesSelector
@blackbee now: determine the .button that was clicked, knowing a child of it might have been clicked actually
 
8:17 AM
@JanDvorak yeah it's hard
 
@blackbee and exit the handler if it wasn't a .button
 
@Qantas94Heavy it passed in upvotes that indirect eval call question.
 
Have you test ionic Framework ?
 
why do u prefer using a class than an id ? @JanDvorak
 
Hey, I'm trying to convert milliseconds to minutes and seconds through this method I came up with here...
//[refresh = miliseconds]
var secondsTillRefresh = (refresh/1000).toFixed(0); //milisec to sec
var minutesTillRefresh = (secondsTillRefresh/60).toFixed(0); //sec to min only
var additionalSecondsTillRefresh = secondsTillRefresh - (minutesTillRefresh*60);//remaining sec with min removed


But for some reason, whenever minutes > 0, seconds are offset by -30 and go into the negatives when >30
Is there anything I'm doing wrong?
 
8:30 AM
@blackbee you can have multiple elements with the same class
!!> 1.75.toFixed(0)
 
@JanDvorak "2"
 
@Leaf ^
!!> Math.floor(1.75)
 
@JanDvorak 1
 
I don't quite follow @janDvorak
 
@Leaf if secondsTillRefresh is 45, minutesTillRefresh is 1. You want 0.
 
8:37 AM
Oh, I see. Is .toFixed(0) rounding up?
 
!!> 0.25.toFixed(0)
 
@JanDvorak "0"
 
It rounds towards nearest
 
Whoops, no wonder
!!> Math.floor(0.65)
 
@Leaf 0
 
8:40 AM
thank you!
!!> Math.floor(15000/1000)
 
@Leaf 15
 
Doesn't javascript have anything like integer division? Never really thought about it
 
css is so ugly :'( i cant do it properly
 
It's my favorite language @blackbee
 
@Kippie It doesn't have anything built in to do integer division but since numbers and floats are the same thing it's 2 lines of code to do it

var division = Math.floor(a / b);
var remainder = a % b;
 
8:49 AM
I totally forgot about the % remainder...
 
function div(a,b){return (a-a%b)/b} // don't do this
 
@JanDvorak your function will always return zero?
 
@DaveMackintosh why would it?
 
a - a = 0 no remainders so nothing to divide by.
 
!!> (function div(a,b){return (a-a%b)/b})(5,2)
 
8:52 AM
@JanDvorak 2
 
@DaveMackintosh I never compute a-a
 
think algebra
(a-(a%b)/b)
 
@JanDvorak My bad, tested enter to get your name up.
Ahh, bugger. Totally forgot bidmas. :/
 
the add and remove are float right, but i didnot mean go extreme right
 
It confused me at first as well @daveMackintosh
 
8:54 AM
@Leaf It's too early for me..
 
@blackbee Why do you need to use float?
 
well, i want to make it like this, the todo lists will be on the left half and add, remove on the right half @Leaf thats why i though float left right and clear:both
what should i have done
 
something like
position:absolute;
right: 50px;
for Add/Remove, then
position:absolute;
left: 50px;
for the todo list MIGHT work
but CSS is a bit finicky when it comes to position:absolute;
left/right: #px; being how far away you want it from the edge
 
@Leaf he will need to set the parent container of those elements to

position: relative

unless he wants them to be positioned from the upper most top left.
 
Float is typically only useful for responsiveness, in my oppinion
 
8:59 AM
well, there is one problem, the middle part ash part is already absolute, left : 0; right : 0; and margin : 0 auto; so i have a add another div to it and set it to relative and apply absolute on the menu? my structure looks like this...
<body>
<div id = "wrapper">
<div id = "main_left">
</div>
<div id="menu_right">
</div>
</div>
</body>
 

« first day (1382 days earlier)      last day (3551 days later) »