Skip to content

Instantly share code, notes, and snippets.

@danielgtaylor
danielgtaylor / gist:0b60c2ed1f069f118562
Last active April 2, 2024 20:18
Moving to ES6 from CoffeeScript

Moving to ES6 from CoffeeScript

I fell in love with CoffeeScript a couple of years ago. Javascript has always seemed something of an interesting curiosity to me and I was happy to see the meteoric rise of Node.js, but coming from a background of Python I really preferred a cleaner syntax.

In any fast moving community it is inevitable that things will change, and so today we see a big shift toward ES6, the new version of Javascript. It incorporates a handful of the nicer features from CoffeeScript and is usable today through tools like Babel. Here are some of my thoughts and issues on moving away from CoffeeScript in favor of ES6.

While reading I suggest keeping open a tab to Babel's learning ES6 page. The examples there are great.

Punctuation

Holy punctuation, Batman! Say goodbye to your whitespace and hello to parenthesis, curly braces, and semicolons again. Even with the advanced ES6 syntax you'll find yourself writing a lot more punctuatio

@Ianfeather
Ianfeather / gist:fefaee82c2ac0e66fddd
Created March 17, 2015 14:30
List files using node and generators
'use strict';
var co = require('co'),
fs = require('co-fs'),
each = require('co-each');
var dive = function* (path) {
var items = yield fs.readdir(path);
@cletusw
cletusw / .eslintrc
Last active February 29, 2024 20:24
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
@tomfuertes
tomfuertes / social.haml
Created December 19, 2013 16:32
Social Sharing w/ no external requests (Bootstrap3 + FontAwesome)
%li
-# https://developers.facebook.com/docs/reference/dialogs/feed/#redirect
%a{:href => "https://www.facebook.com/sharer/sharer.php?u=#{u request.original_url}", :target=>"blank", :rel=>"external nofollow"}
%span.fa.fa-facebook.fa-2x
%span.text-hide Facebook
%li
-# http://stackoverflow.com/a/11212220/94668
%a{:href => "//pinterest.com/pin/create/button/?url=#{u request.original_url}", :target=>"blank", :rel=>"external nofollow"}
%span.fa.fa-pinterest.fa-2x
%span.text-hide Pinterest
MyExceptions = [RangeError, RegexpError, IOError].freeze
begin
raise IOError, "should be rescued"
rescue *MyExceptions => e
puts e
end
upstream myapp {
server unix:///myapp/tmp/puma.sock;
}
server {
listen 80;
server_name myapp.com;
# ~2 seconds is often enough for most folks to parse HTML/CSS and
# retrieve needed images/icons/frames, connections are cheap in
@tapi
tapi / KVO.js
Created February 24, 2012 01:36
Quick and dirty Javascript KVO
/* Extends the Class Object Written by Resig. http://ejohn.org/blog/simple-javascript-inheritance/ */
Class.prototype.addObserver = function(/** String */ key, /** Object */ observer, /** Function */ method)
{
if (key !== null && key !== undefined &&
observer !== null && observer !== undefined &&
method !== null && method !== undefined)
{
eval("this._" + key + " = this." + key);
this.__defineGetter__(key, function()
@millermedeiros
millermedeiros / gist:891886
Created March 29, 2011 06:21
iPad HTML5 video quirks and hacks
/*
* Example how to preload HTML5 video on the iPad (iOS 3.2+)
* @author Miller Medeiros
* Released under WTFPL
*/
var vid = document.createElement('video');
vid.src = 'lol_catz.mp4';
document.getElementById('video-holder').appendChild(vid);
@mikhailov
mikhailov / installation.sh
Created November 23, 2010 15:18
nginx+passenger (real production config)
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz