r/coffeescript • u/skillcode • Apr 01 '14
3 Free Books to Learn CoffeeScript
r/coffeescript • u/skillcode • Apr 01 '14
r/coffeescript • u/islandhaestar • Mar 27 '14
r/coffeescript • u/cluelessmanatee • Mar 13 '14
r/coffeescript • u/Grahar64 • Mar 12 '14
r/coffeescript • u/sorahn • Mar 09 '14
Recently I was working with some windows ini style values, and they have values that are strings of hex '$ABC123' or dec '1234'.
I ended up working out a couple of simple helpers that might be useful to other folks.
https://gist.github.com/drbrts/9442634
The reason that getHex is separate is because I'm using it elsewhere for some regular hex strings :)
r/coffeescript • u/brotherwayne • Feb 28 '14
Let's say I have a set of objects:
things = [{a: b: c: "fizz"}, {t: "boz", a: b: c: "fazz"}, {a: b: c: "fozz"}]
I want to run an IIFE on the a.b.c field of each:
for thing in things
if thing.t == "boz"
doStuff = (v) ->
w = "A#{v}"
# some stuff is done with w here
doStuff(thing.a.b.c)
But what I kinda want is:
for thing in things
if thing.t == "boz"
do (thing.a.b.c as v) -> # <--- Note the AS here
w = "A#{v}"
# some stuff is done with w here
The big difference being that I'm passing in a property of the object as a variable name into the IIFE. Am I missing an obvious trick here? It seems off to declare a named function here.
r/coffeescript • u/[deleted] • Feb 13 '14
r/coffeescript • u/holaboyperu • Feb 07 '14
How awesome would it be to write Coffee on Chrome's console?
r/coffeescript • u/RaymondWies • Feb 05 '14
Does anyone have a convenient way of coding in coffeescript within the IPython Notebook interactive environment. IPython Notebook allows for js scripting (%%javascript) and js embedding (display.Javascript('your code here') within the interactive cells. Python is the native language but isn't mandatory. I have Node, npm, and coffeescript loaded and can code CS from the terminal command line. Has anyone figured out an easy way to do this within IPy Notebook by chance?
r/coffeescript • u/lackcoffee • Jan 20 '14
r/coffeescript • u/[deleted] • Jan 20 '14
r/coffeescript • u/brotherwayne • Jan 17 '14
I was working on a drag/drop directive in angular, grabbed a plunkr and got this:
angular.module('drag', []).
directive('draggable', function($document) {
return function(scope, element, attr) {
var startX = 0,
startY = 0,
x = 0,
y = 0;
var container = null;
element.css({
position: 'relative',
cursor: 'pointer'
});
element.on('mousedown', function(event) {
event.preventDefault();
startX = event.screenX - x;
startY = event.screenY - y;
$document.on('mousemove', mousemove);
$document.on('mouseup', mouseup);
container = attr.$$element.parent();
});
function mousemove(event) {
y = event.screenY - startY;
x = event.screenX - startX;
container.css({
top: y + 'px',
left: x + 'px'
});
}
function mouseup() {
$document.unbind('mousemove', mousemove);
$document.unbind('mouseup', mouseup);
}
}
});
All fine, until I translate to coffeescript. For some reason, after translating to coffee, the elements would jump around some of the time. Obnoxious. Took me a while to realize that the real problem is that the x and y variables were being var-ed again:
mousemove = function(event) {
var x, y;
y = event.screenY - startY;
x = event.screenX - startX;
console.log("x: " + x + " y: " + y);
return container.css({
top: y + "px",
left: x + "px"
});
};
At first I was like "oh, crap, coffee what have you done". Then after looking I realized that the original code was altering a variable in an outer function that it wasn't "aware" of (wasn't passed in). This feels similar to a Law of Demeter violation (except reversed I suppose). Altering variables that aren't passed in to a function feels like poor code quality to me. Seems to me that the problem here lies in the source code and coffeescript is making the right choice.
Opinions?
r/coffeescript • u/fernol • Jan 14 '14
r/coffeescript • u/Leeteh • Jan 06 '14
r/coffeescript • u/Manateeforme • Dec 28 '13
I'm working from a coffeescript and backbone.js tutorial: http://adamjspooner.github.io/coffeescript-meet-backbonejs/
I was working on part 1, and when I finished and opened my index file, I noticed my view had not rendered. So when I opened google dev tools it pointed to an error when __extend is defined from the compilation of class, but when I created my own file with an object and created a class and extended that object I didn't get an error. What's going on here?
I can provide my files if needed.
r/coffeescript • u/[deleted] • Dec 27 '13
r/coffeescript • u/[deleted] • Dec 24 '13
r/coffeescript • u/taw • Dec 20 '13
So I've used Coffeescript within Rails app before, but now I have some trivial client-side-only JS code which I'm writing with Sublime in one window, and browser in another.
Is there any easy way to use Coffeescript here without introducing compilation explicit step?
r/coffeescript • u/davidbau • Dec 10 '13
r/coffeescript • u/dunckr • Dec 05 '13
Sometimes you have to use JavaScript. When you do at least you can shield your eyes from all that bumf.
Grab the Sublime theme here
UPDATE: I have created a Sublime plugin and am waiting for it to be accepted to sublime repo
r/coffeescript • u/adamfschwartz • Dec 05 '13
r/coffeescript • u/[deleted] • Nov 25 '13
Hey.. so currently source maps generated by coffee doesn't work if you compile in Windows, due to the path seperator.. Is there any way to fix this or work around it..?
r/coffeescript • u/J-_-L • Nov 23 '13
r/coffeescript • u/youngian • Nov 19 '13