Skip to content

Instantly share code, notes, and snippets.

View alangpierce's full-sized avatar

Alan Pierce alangpierce

  • Benchling
  • San Francisco, CA
View GitHub Profile
let cids = $el.find('.alignment-row').map((row) => $(row).attr('data-id'));
cids = ($(row).attr('data-id') for row in $el.find('.alignment-row'))
const colors = getMarkers().map((marker) => marker.color);
var colors, marker;
colors = (function() {
var i, len, ref, results;
ref = getMarkers();
results = [];
for (i = 0, len = ref.length; i < len; i++) {
marker = ref[i];
results.push(marker.color);
}
return results;
colors = (marker.color for marker in getMarkers())
class Giraffe {
if (ENABLE_LOUD_GIRAFFES) {
roar() { // <- Unexpected token, expected ; (3:11)
return 'ROAR!!!';
}
} else {
roar() {
return 'roar...';
}
}
class Giraffe
if ENABLE_LOUD_GIRAFFES
roar: ->
return 'ROAR!!!'
else
roar: ->
return 'roar...'
@alangpierce
alangpierce / assign-soak-examples.txt
Created July 24, 2017 05:13
Examples of soaked assignments in CoffeeScript
Example from repos/atom/atom/src/main-process/spawner.coffee:
29 | spawnedProcess.on 'close', (code, signal) ->
30 | error ?= new Error("Command failed: #{signal ? code}") if code isnt 0
> 31 | error?.code ?= code
| ^^^^^^^^^^^
32 | error?.stdout ?= stdout
33 | callback?(error, stdout)
Example from repos/atom/atom/src/main-process/spawner.coffee:
@alangpierce
alangpierce / all-soak-examples.txt
Created July 23, 2017 23:40
Instances of soak operations in the Atom codebase
Example from repos/atom/atom/spec/atom-environment-spec.coffee:
637 |
638 | afterEach ->
> 639 | subscription?.dispose()
| ^^^^^^^^^^^^^^^^^^^^^
640 |
641 | it "invokes onUpdateAvailable listeners", ->
Example from repos/atom/atom/spec/atom-reporter.coffee:
@alangpierce
alangpierce / rd-to-create-element.js
Created August 31, 2016 16:23
Benchling jscodeshift script to convert code to use React.createElement
/**
* jscodeshift script to convert our way of creating React elements in CoffeeScript to
* React.createElement. The create-element-to-jsx script then converts the result to JSX.
*
* For example, this code:
* rd.div(myProps, child1, child2)
*
* becomes:
* React.createElement('div', myProps, child1, child2)
*