Skip to content

Instantly share code, notes, and snippets.

View rattrayalex's full-sized avatar

Alex Rattray rattrayalex

View GitHub Profile
@rattrayalex
rattrayalex / shellshower.py
Created June 11, 2014 20:02
show commands that are being run
from clint.textui import puts, indent, colored
def red(msg):
return puts(colored.red(msg))
def shell(cmd, fail_silently=False, *args, **kwargs):
# tell the user what's about to go out
puts(colored.blue("-> {}".format(cmd)))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
const getIndex = (th) => Array.from(th.parentElement.children).indexOf(th)
const getChildren = (i) => Array.from(document.querySelectorAll(`td:nth-child(${i + 1})`))
const setHiddenStyle = (node) => {
node.style.width = '1px'
node.style.overflow = 'hidden'
node.style.overflowWrap = 'normal'
}
const toggleHidden = (node) => {
if (node.style.length) {
node.style = {}
diff --git a/src/grammar.coffee b/src/grammar.coffee
index 4ff9a1c..7229664 100644
--- a/src/grammar.coffee
+++ b/src/grammar.coffee
@@ -365,7 +365,7 @@ grammar =
Export: [
o 'EXPORT Class', -> new Export $2
- o 'EXPORT Identifier = Expression', -> new Export new Assign($2, $4)
+ o 'EXPORT Identifier = Expression', -> new Export new Assign($2, $4, 'export')
diff --git a/tests/prettier/__snapshots__/jsfmt.spec.js.snap b/tests/prettier/__snapshots__/jsfmt.spec.js.snap
index 826b40c..5d5ca84 100644
--- a/tests/prettier/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/prettier/__snapshots__/jsfmt.spec.js.snap
@@ -49,19 +49,19 @@ const comp5 = <div>Keep it on one line.</div>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const comp1 = (
<div style={styles} key=\"something\">
- Keep the wrapping parens.
+ Keep the wrapping parens.
@rattrayalex
rattrayalex / match_polyfill.js
Created September 6, 2017 07:12
Example Match Polyfill with "tests"
if (!Symbol.matches) {
const DEFINE_PROPERTY = "defineProperty";
// define Symbol.matches
Object[DEFINE_PROPERTY](Symbol, "matches", {
configurable: false,
writable: false,
value: Symbol("matches"),
});

Use a keyword (not necessarily private) as a "private this", such that private. is identical to the currently proposed #, but is used similarly to this.

class Point {
  
    private.x;
    private.y;

 constructor(x = 0, y = 0) {
@rattrayalex
rattrayalex / hacked_prettier_snippet.js
Created December 18, 2017 03:57
Hacking "check ast" into node_modules/prettier/bin/prettier.js at the bottom of `function format(argv, input, opt) {`
//
// at the bottom of `function format(argv, input, opt) {`, near line 20367
const pp = prettier$3.format(input, opt);
const ast = cleanAST(prettier$3.__debug.parse(input, opt));
const past = cleanAST(prettier$3.__debug.parse(pp, opt));
if (ast !== past) {
const MAX_AST_SIZE = 2097152; // 2MB
const astDiff =
@rattrayalex
rattrayalex / app.coffee
Last active September 11, 2018 23:46
Demo
Bacon = require('baconjs')
Imm = require('immutable')
React = require('react')
window.Actions =
changeFirstName: new Bacon.Bus()
changeLastName: new Bacon.Bus()
changeCountry: new Bacon.Bus()
addCountryBird: new Bacon.Bus()
addFriend: new Bacon.Bus()
@rattrayalex
rattrayalex / MessageStore_FluxBone.js
Last active June 19, 2020 09:40
Flux and Backbone
var ChatAppDispatcher = require('../dispatcher/ChatAppDispatcher');
var ChatConstants = require('../constants/ChatConstants');
var ChatMessageUtils = require('../utils/ChatMessageUtils');
var EventEmitter = require('events').EventEmitter;
var ThreadStore = require('../stores/ThreadStore');
var merge = require('react/lib/merge');
var ActionTypes = ChatConstants.ActionTypes;
var CHANGE_EVENT = 'change';