Skip to content

Instantly share code, notes, and snippets.

View hoandang's full-sized avatar
👟
Roaming

Hoàn Đặng hoandang

👟
Roaming
  • Sydney, Australia
View GitHub Profile

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

@hoandang
hoandang / introrx.md
Last active August 29, 2015 14:26 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@hoandang
hoandang / preprocessor_fun.h
Last active August 29, 2015 14:27 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
#!/bin/bash
cat > ~/.bash_profile <<EOL
export VISUAL=vim
export EDITOR="$VISUAL"
alias install="sudo apt-get -y install"
alias update="sudo apt-get -y update"
alias upgrade="sudo apt-get -y upgrade"
alias v="vim"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial,Helvetica Neue,Helvetica,sans-serif;background: #CCC;padding: 0;margin: 0;">
<head style="font-family: Arial,Helvetica Neue,Helvetica,sans-serif;">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>eBay Innovation Lab</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body style="font-family: Arial,Helvetica Neue,Helvetica,sans-serif;background: #CCC;padding: 0;margin: 0;">
<!-- <table style="font-family: Arial,&quot;Helvetica Neue&quot;,Helvetica,sans-serif;border-spacing: 0;background: #FFF;max-width: 900px;margin: 0 auto;"> -->
@hoandang
hoandang / uninstall_homebrew.sh
Created August 17, 2012 07:49 — forked from mxcl/uninstall_homebrew.sh
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@hoandang
hoandang / email_regex
Created January 20, 2013 06:34
Validate email address
/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
@hoandang
hoandang / mysql: next_auto_increment_id.sql
Created February 1, 2013 11:06
Return the next auto increment id in Mysql
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='table_name'
@hoandang
hoandang / java: HasMap-Iterator.java
Last active December 13, 2015 19:09
Three ways to iterate a HashMap in Java
Map<String, Object> map = ...;
//If only interested in the keys, you can iterate through the keySet() of the map:
for (String key : map.keySet()) {
// ...
}
//If only need the values, use values():
for (Object value : map.values()) {
// ...
@hoandang
hoandang / javascript:custom_dialog.js
Created February 16, 2013 04:20
Create a custom dialog (there are two buttons OK and Cancel leverage twitter bootstrap)
document.addEventListener('DOMContentLoaded', function() {
document.getElementById("click").addEventListener("click", function(e){
var msg = 'Are you sure you want to delete action?';
customConfirm(msg);
//customConfirm(msg, function(){alert('id deleted')},function(){alert('user pressed Cancel button')});
e.preventDefault();
});
});
function customConfirm(message, true_func, false_func){