« first day (957 days earlier)      last day (4216 days later) » 

00:02
@BenjaminGruenbaum every single time. :(
Also, I'm happy to say Ghost Armour screen protector did manage to fill in the very shallow surface scratch on my phone! Win!
00:15
@phenomnomnominal read this: github.com/jashkenas/coffee-script/issues/712 ?
Jon Skeet, you're such a noob :P
@BenjaminGruenbaum, it's never an issue I've come across. I kinda agree with Jeremy that it's just not good style in the first place.
@phenomnomnominal python solves this nicely
I just can't think of when I would have to deal with it
Well, what about something like:
i = 5
b = (elems) ->
    i=0
    for elem in elems
        elems.idx = i+1
that's a silly example, but more generally when I have a variable named something common in an outer scope
okay, but my solution to that isn't to change the language, it's to give the variable a better name?
> Keeping all your modules separated and compiling them individually, you'll never run in the above.
Yeah I don't know what he's going on about re: writing plugins etc
00:30
If I have a 1000 lines module, I don't want to worry about which variable names I use in every function
It's just something the language should at least warn me about, it could cause some very unpredictable bugs
A warning yes, but I don't think it needs new syntax for it
It would only need to be as simple as: A variable with this name has been declared in an outer scope.
> odf: Sure, in theory. In practice, well structured JavaScript code doesn't litter the top-level scope with lots of global variables, and keeps function scope shallow. This problem literally never comes up. And in the rare cases it does -- it's the same as when you try to reuse a variable name inside of a deep if/else statement -- you think "oh, I need to use a different name for this" ... and do just that.
It would be impossible for the compiler to know when it's intended
> CoffeeScript is basically for programming for only one programmer in the project. In case you have several other programmers, they all should first find out which variable names are already borrowed.
^ That's what bothers me
The way it stands if the variable name doesnt exist it gets a var, doesn't it stand to reason that if it isn't going to not give it a var and it's defined in a do or class or function, it should just warn you?
still reading, formulating opinion
But modules should be small enough and separate (at least before deployment), that it really shouldn't be an issue.
Still looks like language smell to me
@BrianHannay 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.
@ManolisC. 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.
if you really needed it you could just do:
blah = 'outside'
do (blah = 'inside') ->
  console.log blah
console.log blah
Yeah, you can do this in normal JS to, this is what your code reads to me as:
var blah = "outside"
with({blah:"inside"})
   console.log(blah)
console.log(blah)
00:45
Yeah but it's not
you know what it is haha
It's introducing a new scope
Hello guys! I'm trying to make a simple ajax converter.. I'm new to js so i'm stuck on the begging.. If anyone could have a look at jsfiddle.net/CmFLv
Because why would you want to do shadowing like this
I know what it is, but I'm telling you what it looks like, this is exactly like with, it's a poor idea
but the correct solution is this:
outside = 'outside'
inside = 'inside'
@ManolisC. you have a function but you never call it, also you call a function that doesn't exist in it
@phenomnomnominal Only in real code that might be 1000 lines long, it might not be apparent, or so clear.
00:47
I keep getting highlighted in the Python room :(
@BenjaminGruenbaum Is it called from the button?
@ManolisC. you're calling it but it's not in the window since it's inside an onload handler
@BenjaminGruenbaum, yeah but then the issue is the modularily of the code. Even then you're going to have to know that the variable already exists in the scope so you can use local or := or anything. Or you're just going to have to declare everything local which is just gross
@phenomnomnominal What about the way prototypes work?
If you try to get the value it's there, but if you change it you create a local unless you're explicit about it
that's not very JS though hmm
Exactly, it's about the ethos of the language
00:50
@BenjaminGruenbaum should i put it in the head?
@ManolisC. in the bottom of the script area, in the fiddle window.convert=convert; . Also, use unobtrusive JavaScript
@phenomnomnominal Honestly, I don't think var is such a bad idea
@BenjaminGruenbaum maybe like this? jsfiddle.net/CmFLv/2
No, the only suggestion I would agree with is adding back var for an explicit var in the JS
@ManolisC. right, now what error is it telling you about?
@phenomnomnominal I guess it's not that big of a deal, scopes shouldn't be deep nested anyway, but it's still smell
@BenjaminGruenbaum The thing is that i don't know how to continue the coding of the converting. I found the math operation to convert Fahrenheit to Celcius but I don't know where to do what?
00:58
@ManolisC. I'm not going to write your code, you have a bug (hint, you're using getElementById but you've set name in HTML), fix it
> Adding an import or writing a new function / global variable should never, ever affect local code in a function!
anyone know any nice themes with sleek, sexy nav bars? :D
@BenjaminGruenbaum Ok! I'll try to write the math code now.. Thank for your help!!
makeCounter = (counter = 0) -> -> counter++
@BenjaminGruenbaum, ^ just don't write dumb code :P
his example seems legit
His big one, yeah
But a) it wouldn't be hard to debug, and b) using Math.log is much clearer than log because it differentiates a logarithm from console.log or any other kind of log.
01:30
@Safixk 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.
@BenjaminGruenbaum I figured out!! once again thanks for your help! (you can check it here if you want jsfiddle.net/KtUGJ )
@ManolisC. Sure, consider using toFixed to not get numbers like 3.999999999994
((number).toFixed(n) rounds to n decimal places)
@BenjaminGruenbaum great!!
can it be like newTemp = (((temp -32) / 1.8).toFixed(n); ?
yes works now
just had to remove one (
02:07
9704151: Missing Missy is an old time classic :)
02:38
let keyword (ES6) looks pretty neat.
02:57
!!/choose glee conan
@copy glee
WHY GOD WHY
I'M SUPER HAPPY
CAPITAL LETTERS INDICATE HAPPINESS
WHILE NORMAL LETTERS INDICATE IRONY
(It's not reversed)
03:09
@rahstame 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.
@rahstame WELCOME
tnx
can you help me understand the code?
That looks suspiciously like Java
Which is not equivalent to JavaScript
 
1 hour later…
04:17
1 message moved to recycle bin
hi @Zirak
Hullo
@BadgerGirl hiii
@XCritics Where's the answer you promised?
@Zirak You're the bosley to my angel
I just got home, what was the question that I had to answer
04:19
@scroll_lock 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.
7 hours ago, by XCritics
@Zirak Pop quiz, can I use @remember_token in place of self.remember_token?
Hm
I don't know what scenario to pop that bitch into
Hang on i'll go play
10 minutes start now :)
!!/nudge 10 minutes time up
@Zirak Nudge registered.
Semi-fail, but it'll do.
04:20
Just tell me what console.log is in ruby
I need to log the values to console x.x
puts or print. The former adds a newline after every argument.
or p
p does more escaping and also returns its argument
Also, learn about irb
Pretty sure I'm retarded
and it doesn't work
But I don't know what else to do, and I don't know ruby
oh derp
hang on
04:27
uh, testVariableAt and testVariableSelf don't exist
First, write a class, because that's what you're testing for...
selftest.rb:1: class/module name must be CONSTANT
what does this mean!
Class name should start with a capital letter
And why are your method calls inside of the class?
//undo
!!/undo
Cause I don't know ruby :(
04:30
Then why do you use Rails?
To learn
What's the answer @Zirak can I see your .rb file
# here's the general pattern I followed:
class Test
    def initialize
        # put the variable initialization here
    end
    def test_at
        # test accessing that variable with @
    end
    def test_self
        # test accessing the variable with self
    end
end

t = Test.new
# put the test invocations here
You know how we yell at people for learning jquery before learning javascript?
Consider yourself yelled.
But I read using Ruby is a lot different than using Rails :(
and it doesn't really matter which one you learn first in the sense of using Rails
Rails is a Ruby framework
Ruby On Rails
Even if you can learn it without really knowing ruby, you shouldn't.
I know what you're saying, and I understand that, I'm just going off Michael Hartls rails tutorial, where he said it doesn't matter if you do or not
He said you'll learn a lot of Ruby a long the way
04:35
@Zirak do you have any good tutorial on Ruby variable scoping rules?
Nope. My Ruby experience doesn't exceed the a full 2 days of coding in it.
Is that any better
Still errors, but am I going in the right place
Yes, much better, but you can eliminate the 2 variables; you really only need one, and they're shadowing the method calls
Or the method calls shadow them
@XCritics testSelf is accessed via a getter/setter pair, but there is no such getter/setter
What you mean shadow them
04:39
instead, testSelf calls itself
When you say @testAt inside the class for example, which do you mean: The method, or the property?
By having both, one shadows the other.
gacnt@gacntMint ~/Desktop $ ruby selftest.rb
test
selftest.rb:11: stack level too deep (SystemStackError)
I removed line 4, and line 8 logs, line 12 errors
@Zirak the property. @testAt is always a class variable.
So change your test variables. Give them a different name. And change "them" to "it", because you only need one
:O
They both log
So are they one in the same?
04:41
Ruby does not have public variables. Ruby has getters and setters
@XCritics Dude, you're still calling testAt...
Change the fucking name
3 messages moved to Trash can
I don't know what you're talking about
@testAt = test
...
def testAt
I must be next level retarded, cause I see nothing wrong x.x
They have the same name?
04:42
What does
I don't see anything with the same name there
@XCritics self.testAt is a method that has the same name as a local variable
@ ***testAt****
def ***testAt***
I must be full on retarded
Why can't they have 2 different names
I mean
The same name
They SHOULD!
4 mins ago, by Zirak
When you say @testAt inside the class for example, which do you mean: The method, or the property?
4 mins ago, by Zirak
By having both, one shadows the other.
normally, if a variable has the same name as a local variable, it is a getter for that variable
04:44
oh
By doing self.testAt, how do you know which you're referring to?
You don't, so your test is invalid
See I was confused at that
I gotcha now derp
  1 class Test
  2   def initialize (test)
  3     @testAt = test
  4   end
  5
  6   def testing
  7     puts @testAt
  8     puts self.testAt
  9   end
 10  end
 11
 12 t = Test.new('test')
 13 t.testing
@Zirak you do. You're referring to the function.
04:45
He doesn't know
oh :-)
@XCritics ...you're still calling t.testAt and t.testSelf
which are undefined
I seen that
Gotta gimme time ok, little bit slow bro
With the above I get
You don't say
04:46
gacnt@gacntMint ~/Desktop $ ruby selftest.rb
test
selftest.rb:8:in `testing': undefined method `testAt' for #<Test:0x0000000117cae0 @testAt="test"> (NoMethodError)
	from selftest.rb:13:in `<main>'
Look up attr_accessor
Huzzah! You found the answer!
Yay me
Now what was my question
...whether @something and self.something are the same
Soooooooo
Now I need to know, when do I want to use self, and when should I use @ :(
04:48
They are not. self.something refers to the setter.
So I can set a property with self, and call to it using @?
Use self when you want to call a function of self
Just a method?
use @ when you want to set a local variable without invoking its setter
o.O
Like
04:49
Hint: you don't want to invoke a setter from itself
The way Array.filter invokes a new Array, but does not change the one it's referring too?
in a sense? No?
'invocation' = method call
class Foo
    def foo= (arg)
        @foo = arg
    end
    def print_foo
        puts @foo
    end
end
Array#filter creates a new array.
If we did foo = arg inside of foo=, we would've gotten into infinite recursion.
@XCritics That's mutative/non-mutative.
Mutative functions change their input; non-mutative ones don't (for instance, sort in js is mutative, map isn't)
04:52
1 class Test
  2   def initialize (test)
  3     @testAt = test
  4   end
  5
  6   def testing
  7     puts @testAt
  8     @testAt = 'New Variable'
  9     puts @testAt
 10     self.testAt = 'New Infinity'
 11     puts @testAt
 12     puts self.testAt
 13   end
 14  end
 15
 16 t = Test.new('test')
 17 t.testing
my new test
There's some convention in Ruby that mutative functions have their names end with a !
and I don't know what I was trying to achieve
Yeah I learned that I could do like a.shuffle!
Then your test is bad
I was trying to see if @ would create a new local variable, as where self would change the testAt for everything
if that makes sense
@Zirak not "mutative", "dangerous". JSON.parse! is dangerous because it accepts more inputs, not because it modifies JSON.
04:53
Then splinter that into different functions
@XCritics self.xxx is always a method call
Have your functions do or test one thing
New Infinity sounds like a cool name for something btw
Make something with it
@Zirak Can we have a ruby console in our bot, please?
No
oh wait, you said please
m59
m59
05:07
I thought I understood pseudo elements, but maybe not :(
<div></div><ul></ul>
Which pseudo-elements specifically?
m59
m59
ul:before {
  content: '';
  display: inline-block
}
that doesn't work the same as the div.
Anybody know of a VIM plugin that removes the redundancy of writing HTML?
That inserts an inline block within the ul
i.e. <div></div><ul><ul:before></ul:before></ul>
It's not exactly an accurate name, but :/
m59
m59
ya know, I started thinking that too
so I tried it on the parent
they didn't go inline
above instead, whereas the div worked fine.
05:10
In that case the ul needs to be an inline block too
m59
m59
it is
I mean, it works perfectly as div before and after, not as css though
lol, display: table on parent and table-cell on ul and pseudo's works
but sucks
then I can't use left
err
nm I can
Ok I deleted my rails app, managed to include the bootstrap gem, make my routes file and generate a controller without having to look at the tutorial, so far so good x.x
@Zirak you pimp you ;)
05:25
0
Q: Can this PDF JavaScript be optimized?

AlexI have a PDF document which I'm scripting, but I'm not happy with the script I've got so far, although it works. I've only implemented three rows of functionality out of ~30 and it's already at 550+ lines. I'd appreciate it if someone can lead me to a better solution. I think a matrix would work ...

@Feeds Oh my
05:39
@Nick 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.
-1
Q: JavaScript: making a dynamic class clickable -- why not working?

user1883050The code below creates a button on screen, and when clicked, it creates new Div's dynamically. And after a certain number of clicks it deletes all the newly created Div's. The problem: I want to make the newly created Div's also clickable so they create new Div's. Why is the following function n...

@All: Can any one help me, My issue is window.event.srcelement not working in firefox?
srcElement
that is srcElement not srcelement
05:54
i hav checked with it, itz not the solution.............
any error in console?
Firefox doesn't have a global event variable (as it shouldn't); use the parameter passed to the listener.
would you like to say what that error is ?
[11:27:12.299] TypeError: window.event is undefined @ ..JS/Common.js:67
05:57
event
it should be passed to your event handler
pardon?
See my message above
means i have to pass parameters?
The parameter is already passed
Then, what i hav to do?
06:00
...use the parameter that's passed to your function
//assuming this is your function
function (e) {
    //e.srcElement is what you're after
}
I am calling the function with no parameters
onclick="SelectAllChildNodes()"
Unobtrusive JavaScript is a general approach to the use of JavaScript in web pages. Though the term is not formally defined, its basic principles are generally understood to include: * Separation of functionality (the "behavior layer") from a Web page's structure/content and presentation * Best practices to avoid the problems of traditional JavaScript programming (such as browser inconsistencies and lack of scalability) * Progressive enhancement to support user agents that may not support advanced JavaScript functionality A new paradigm JavaScript historically has had a reputation for ...
And my fn is
function SelectAllChildNodes() {
//debugger;

var obj = window.event.srcElement;
...you're already doing a mistake by doing that inline
What?
I hav tried your code and console says "e is undefined"
06:20
  1 module SessionsHelper
  2
  3   def sign_in (user)
  4     cookies.permanent[:remember_token] = user.remember_token
  5     self.current_user = user
  6   end
  7
  8   def sign_out
  9     self.current_user = nil
 10     cookies.delete[:remember_token]
 11   end
 12
 13   def signed_in?
 14     !current_user?
 15   end
 16
 17   def current_user=(user)
 18     @current_user = user
 19   end
 20
 21   def current_user
 22     @current_user ||= User.find_by_remember_token(cookies[:remember_token])
Why does it use self for half, than @ for the other half
This is where I get confused x.x
it says self is accessible in the views / controller
But I don't know what the reason for the @ symbol is anymore
@Zirak glad to see you gave up
because fuck that.
I love prolog.
| ?- x = 1.

no
I can feel the interpreter furrow its brows, saying "uh, no"
2
06:37
One day I'll understand @, and you will regret this day. For I shall destroy EVERYTHING
06:55
I wear a GoPro on my head while I program
07:20
0
Q: Distinct value from the javascript array of object

djtechieI do have this kind of object var j = [{'one':1},{'two':2},{'three':3},{'four':4},{'five':5},{'one':1}]; Now I want to skip the duplicate record. Can anyone suggest me the way?

07:36
@copy Anybody can make a game incredibly hard, it takes somebody ingenious to devise the most awry, awkward, confusing, mind-blowing, brain shattering ways for people to die unexpectedly :)
Hello someone to help me on that please

http://stackoverflow.com/questions/16817540/twitter-widget-dynamic-shown-content-by-user-selection-with-html-form
0
Q: Twitter widget dynamic shown content by user selection with html form

MhcheThe following code is for the widget and a little js for the query of the function of widget that i have took from Twitter widget methods for dynamic widget updating Here is the code: function do_twitter_widget(search_query, title, subtitle) { if (!window.widgetRef) { window.wid...

07:49
duuuuuuuuuuh
duplicate IDs in the HTML ~~
and I need to set behavior on them
weird, heh?
*#dup_id
in this case have fun using attribute selectors
@JanDvorak ha, thanks, I knew there was a trick, couldn't remember.
@FlorianMargaine anything but #id - then jQuery uses getElementById
yeah it's horribly unperformant
07:54
cache, cache, cache the critical selectors
hey how do i include only needed bootstrap js files? like only modals + popover js ?
i need to split the bootstrap.js manually? :U
@badbetonbreakbutbedbackbone you can manually create your bootstrap you want here twitter.github.io/bootstrap/customize.html
@Mhche yeah but i would like separated js files and it seems it generates a single one :(
anyway thanks for advice
@badbetonbreakbutbedbackbone yes generate separate files e.g. one for modal then another for popover
you 're welcome
please someone to help on that stackoverflow.com/q/16817540/2214753

« first day (957 days earlier)      last day (4216 days later) »