« first day (426 days earlier)      last day (4747 days later) » 

01:14
-1
Q: What are the most useful JS snippets?

TuxedoKnight ChessHere is the list of the JavaScript Snippets so far: toggleBoolean UppercaseFirst Trim isNumber [**]...[...] I am trying to make this post communality-wiki, please try to NOT to upvote until this post is not mine

please try to NOT to upvote until this post is not mine
epic lols
RT @dstorey: New interactive CSS playground app from @LeaVerou launched today. Introducing dabblet http://lea.verou.me/2011/12/introducing-dabblet-an-interactive-css-playground/
RT @w3c: Sounding Out the Audio APIs http://ow.ly/1gcmX8
hahah yeah
that was pretty funny
this one's also pretty good: stackoverflow.com/questions/8528735/…
all of the js snippets would have taken longer to find in some list than rewritten yourself =D
what you mean putting an exclamation point in front of your boolean value
unthinkable
01:24
that question is confusing as hell
I mean
by Number, does he mean number primitives
or just the constructor function
i think the answer to that question is just "no"
can anyone help me with a stupid question? I'm trying to get node.js up and running
SO has different letter spacing on your score on the main page and inner pages
and on the tabs
@Nick ask
thanks -- I'm a complete novice, but I'm not really sure how node works. I'm developing an interactive web application with a client-server architecture
its a board game
ive got the client side working, now I want to make it so multiple people can look at the same board
but I don't know how to "install" node.js -- I have server space my school provides but I don't have administrator privileges
01:32
what os are you running
on your own machine
at home I have windows
school is ubuntu
is your home machine decent
eh...its ok
you mean my home comp would be the server?
01:33
yeah
i was thinking thats how I could do it
you could run ubuntu server inside of virtualbox
but im surprised -- theres no cheap/free online server space with node installed?
i dunno it's still fairly new, free webhosting is pretty much a php game
well if Im using my home comp regardless, would I get better performance out of ubuntu?
01:34
what version of windows?
@Nick download the node msi
huh yeah that makes sense
from the webiste
I have xp
theres plenty of cheap/free online server space
01:35
I just did actually -- its installed on my home comp
heroku, nodejitsu, joyent, etc, etc
yeah you'd probably get better performance dual booting into ubuntu
Ok if you have node installed then write code and run it
i'd probably do that if you have enough disk space to partition some off
or yeah you could just run it on windows i guess
hm ok
01:36
@Nick I'm working on a tutorial : docs.google.com/document/d/…
@Nick nodetuts.com is a fantastic series
@Nick as for installing node on your school server you need sudo access
ha yeah I figured that out the hard way
so what would you recommend? use my home computer as a server? or sign up with nodejitsu or the like?
Nick check out amazon EC2
yeah? ive heard of that too
you can set up a micro ubuntu server instance and run it pretty much for free
i guess theres still a disconnect for me somewhere...again Im sorry its my inexperience showing
01:40
yeah it's pretty decent, i have a few virtual servers on it
but the server has to be running in order for it to work right
well how do you want it to work
ppl can just go to a site and play the game right
I want to be able to access a web page, maybe specify a port number or room name or something, and if there is no one in the game make a new one
otherwise it would show the game currently in progress
yeah you'd def need to serve it up from somewhere
well if I get this space online
01:42
so you could serve it up from home computer and use somethig like no-ip
yeah or get space online
if you just need a little space to mess with and a ubuntu server amazon ec2 is perfect
ok, that sounds good
@Nick you need both
you need it running locally so you can develop, debug and test it
both what?
yeah i agree
well
And you need somewhere to host it.
testing doesn't have to be local though
01:43
yeah
Heroku, nodejitsu, azure, joyent, etc
can be remote test site, or virtualboxed, or whatever
@user886931 it's a waste to test non-locally
@Nick sshvm.com $2/mo
Raynos agreed but some people like to use their windows text editor or whatever but the source files are on another server. seen it tons of times
Mind you, if you leak any memory at all then you will go over their 128mb limit ;)
01:45
ha well I have no idea...can you even have memory leaks in JS?
yes
for sure
my server is currently at 140mb
I've only worked with C/C++ in that regard...I dont know the stack from the heap in JS
but usually it happens because of crappy dom implementations ;p
memory leaks are not really a problem the programmer is "supposed" to have to worry about in js
sorry guys I am really new at this
i really appreciate the help
01:48
@user886931 you would think that but my server went from 40mb -> 140mb over a few days
been programming for a year at school and still feel like I can't do the simplest things -- its frustrating
@Nick it gets better
a year is not a long time :)
ha yeah
Raynos, damn... well i do see a lot of activity on v8's issue tracker concerning memory leaks so i assume it's being worked on
what kind of stuff do you have to do to avoid leaks in node?
01:50
RT @jgw: How do Javascript, Java, and Native code compare on real-world code? (http://goo.gl/2Xevv)
x = null;
aggressively nulling everything
Yeah memory leaks are not fun. It's mainly because of closures
it's too easy to gangho code together without knowing the problems
yeah, it's hanging around in case someone calls that function that it's referenced inside of
but you'd think that stuff should all be freed up once the response has been served
0
Q: Feedback of working javascript code

HakanI am quite new to javascript and I wonder if you experts can see any obvious mistakes (bad javascript coding) below? Or if there are any good improvements? The code is working... // add iframes to page var normal_sortables = document.getElementById('normal-sortables'); normal_sortables.innerHTM...

01:58
@user886931 I dont know why it doesnt just work
it might be redis hogging memory
it might be my inline caching hogging memory
my previous memory session store leaked badly :D
500mb of ram leaked within a week
ouch!
yeah node.js is still pretty new
v8, for that matter
wtf is it with people having to say "it's .on in jQuery 1.7 not .delegate" pisses me off. :( It doesn't look like they will remove the "old" methods anyway and I'd rather use them than some mega overloaded one :(
what's with these silly tags on the side
are these real things
cowbell?
jawesome?
please tell me these are not real things
(js things)
cowbelljs is serious business
i do not get this kind of humor
i guess it is just too advanced for me
what do you mean :P
i mean it's just not funny to me even tough i know it's supposed to be :(
though
we need some humor in the js room to balance all the rage
is there rage?
it seems peaceful
02:18
yeah today has been surprisingly rageless day :P
they probably have nothing to rage about
that's easily fixed though
ugh i need mixins or multiple inheritance or something
maybe decorator will work
@user886931 it's my sense of humour
@user886931 cowbell is basically mocking "HURR DURR JQUERY IS GOLDEN HAMMER EVERYTHING IS NAIL NOW"
mixins are easy to do
var o = make(proto, mixin1, mixin2, mixin3, mixin4, ...);
make <3
what the heck is make
i get a ReferenceError
it's a cool naming convention in functions that make
02:31
what
i don't det it
well if you had syntax like
Element.make( ... )
an element would be made
isnt that what ctors are for
gist: The heart of pd, 2011-12-07 02:07:28Z
function beget(proto, ...args) {
  var o = Object.create(proto);
  o.constructor(...args);
  return o;
}

function make(proto, ...props) {
  var o = Object.create(proto);
  extend(o, ...props);
  return o;
}

function extend(o, ...other) {
  [...other].forEach(copyProperties);
  return o;

  function copyProperties (source) {
    Object.getOwnPropertyNames(source).forEach(copyProperty);

    function copyProperty(name) {
      o[name] = source[name];
    }
  }
}
I should fix that to not use ES6 :D
ah yeah probably so
yeah so just have some common stuff and add it to two different prototypes
i think i may be on to something with these iterators
gist: The heart of pd, 2011-12-07 02:07:28Z
var slice = Array.prototype.slice;

function beget(proto) {
    var o = Object.create(proto),
        args = slice.call(arguments, 1);
    o.constructor(args);
    return o;
}

function make(proto) {
    var o = Object.create(proto),
        props = slice.call(arguments, 1);
    extend(o, props);
    return o;
}

function extend(o) {
    var other = slice.call(arguments, 1);
    other.forEach(copyProperties);
    return o;

    function copyProperties (source) {
        Object.getOwnPropertyNames(source).forEach(copyProperty);

        function copyProperty(name) {
            o[name] = source[name];
        }
    }
}
ES5 compliant :D
02:35
@Ranoys Y U NO toArray
Anyway the point is mixins are easy
@Esailija because I need to slice the first argument of the array :\
i feel like this makes them look less easy
but yeah
mixins are a simple matter of extend(obj, mixin)
02:35
well without all of this
As mentioned : OO series : raynos.org/blog/17
I see, I just instantly assumed from the var slice that you use it to convert xD
they would just be objects that i'd iterate over and dump everything in a prototype
or prototypes
Well in my head you dont use new and you dont use constructors
you just have objects
and you inherit from them using Object.create
hmm
what benefits does that give
over costructors
02:38
var Animal = {
  constructor: function (hasLegs) {
    this.hasLegs = hasLegs;
  }
};

var FlyingAnimal = extend({}, Animal, Flying);

var Penguin = extend(Object.create(FlyingAnimal), {
  fly: function () {
    console.log("PENGUINS Y U NO CAN FLY");
  }
});
@user886931 constructors are fugly
I mean new is ugly. x.prototype is ugly
why use constructors when you can use objects
var Penguin = make(FlyingAnimal, {
  fly: function () {
    console.log("PENGUINS Y U NO CAN FLY");
  }
});
i have a pattern i like for that
Note that make is just sugar.
but jslint tells me it's weird
02:39
You ignore jslint
i do
but still
i dont want to confuse other people
new is faster and you can't make initialization code any easier, it's built in. And since you need to use a library anyway, you could just as easily use a library so you don't need to do the ugly x.prototype stuff.
but we have been over this many times .P
its a code style :D
Raynos I use something like this:
the main point was mixins are easy
02:44
var Animal = decl(function(){

this.constructor = function(hasLegs) {
this.hasLegs = hasLegs;
}

this.bark = function() {
alert('woof');
}

});
yeah except thats uglier :P
Especially if the return type is a function
eye of the beholder i suppose. I prefer it.
the function passed to decl is instantiated with new and assigned as your constructor's prototype
so it's still constructors
var Animal = klass({
  constructor: ...
  bark: ...
});
I don't see why you use a function
because you can have utility functions and stuff in there... "private statics"
instead of using another closure
,_,
anti pattern al3rt
02:48
keeps everything together
privates?
js has no privates
well 'private' as in they're only accessible within the anonymous function passed to decl
Raynos, how do you prevent all of those functions from cluttering up the global scope
I dont see the need for that
because I use module loaders
module loaders wrap my entire file in a closure for me
ah ok
gotcha
02:51
Thats the beauty of module local scope
btw if you are making a global you can do this out of the box
it's all you need
(Animal = function(hasLegs){
this.hasLegs = hasLegs;

}, Animal.prototype = {

	bark: function(){

	}

})
if you need more, your modules are too big
Esailija what is the point of putting all that in one expression?
02:53
no u
@Raynos Animal will be undefined I think
yeahie messes that up
ie
whats the point of making a library that does the same thing in more verbose ways :P
it even has built in statics
...
but yeah for globals only :(
02:54
pd is awshum ¬_¬
@Raynos I meant decl
there are a few reasons i like it
do tell ^_^
yeah i could just as easily pass it an object but i pass an anonymous constructor because i prefer the syntax, even though it's more verbose
i personally fuck things up with big objects with lots of functions inside. I'll for get commas, or put dangling ones, or whatever
02:57
...
problem: "big objects"
also, you can't access one property of the object from another as you can with the constructor
solution: "multiple small objects"
not even big, necessarily, just objects with functions in them
i find it awkward

« first day (426 days earlier)      last day (4747 days later) »