Skip to content

Instantly share code, notes, and snippets.

View ariabuckles's full-sized avatar
🍵
(boba) => <code />

Aria Buckles ariabuckles

🍵
(boba) => <code />
View GitHub Profile
componentDidMount: function() {
socket.on('update', function (comment) {
this.setState({data: this.state.data.push(comment)});
}.bind(this));
},
componentDidMount: function() {
var _this = this;
socket.on('update', function (comment) {
_this.setState({data: _this.state.data.push(comment)});
});
},
@ariabuckles
ariabuckles / perseus-3.js
Created March 24, 2015 18:41
perseus-3.js
This file has been truncated, but you can view the full file.
/*! Perseus | http://github.com/Khan/perseus */
// commit 11a9556a7a7c4a80df6e6cc00de274442fba7753
// branch master
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define(factory);
else if(typeof exports === 'object')
exports["Perseus"] = factory();
@ariabuckles
ariabuckles / perseus-3.css
Created March 24, 2015 18:42
perseus-3.css
.framework-perseus.perseus-article {
width: 640px;
}
.framework-perseus.perseus-article div.paragraph.perseus-paragraph-centered,
.framework-perseus.perseus-article div.paragraph > .perseus-widget-container:only-child {
text-align: center;
}
.framework-perseus.perseus-article div.paragraph.perseus-paragraph-centered > *,
.framework-perseus.perseus-article div.paragraph > .perseus-widget-container:only-child > * {
display: inline-block;
@ariabuckles
ariabuckles / perseus-editor.less
Created March 24, 2015 18:43
perseus-editor.less
// Use this file only for editor styles
// (changes to the renderer will not work in production)
//
// Variables
// Should be consistent with webapp's variables.less
// Colors
@grayDarker: #333;
@gray: #999;
@ariabuckles
ariabuckles / smd-raw-urls.js
Last active October 11, 2016 20:01
Parse `google.com` and `www.example.com` as links with simple-markdown
//var SimpleMarkdown = require("simple-markdown");
var SimpleMarkdown = require("./index.js");
var modifiedTextRule = Object.assign({}, SimpleMarkdown.defaultRules.text, {
match: function(source) {
// This just changes ':' to '[:\.]' in the text regex, so seeing www.g ahead ends the current text match
return /^[\s\S]+?(?=[^0-9A-Za-z\s\u00c0-\uffff]|\n\n| {2,}\n|\w+[:\.]\S|$)/.exec(source);
}
});
@ariabuckles
ariabuckles / smd-test.js
Created January 5, 2018 23:56
example testing for simple-markdown with a custom matcher
expect.extend({
toBeTheSameReactOutput: function(received, argument) {
received = cleanUpReact(received)
argument = cleanUpReact(argument)
var pass = this.equals(received, argument)
if (pass) {
return {
pass: true,
// called when expect(actual).not.toBeTheSameReactOutput fails:
@ariabuckles
ariabuckles / strip-flow-types.sh
Created May 25, 2018 18:55
Strip all flow types with babel (moves files from src/ to src2/ )
npm install --no-save babel-cli babel-transform-flow-strip-types babel-syntax-jsx babel-syntax-class-properties babel-syntax-object-rest-spread
babel src -d src2 --plugins=transform-flow-strip-types,syntax-jsx,syntax-class-properties,syntax-object-rest-spread --copy-files --no-babelrc
@ariabuckles
ariabuckles / join-smd.js
Last active January 7, 2019 19:36
A mostly-generic outputter for joining simple-markdown's adjacent text nodes
var SimpleMarkdown = require('simple-markdown');
var joinTextRules = {
// Here's where the magic happens
Array: {
join: (arr, output) => {
var result = [];
for (var i = 0; i < arr.length; i++) {
var node = arr[i];
if (node.type === 'text') {
@ariabuckles
ariabuckles / methods-to-class-properties.js
Last active April 19, 2019 20:30 — forked from satya164/class-properties-to-methods.js
Codemod to convert class methods to properties, and remove `.bind(this)` in JSX props
// Codemod to convert class methods to properties, and remove `.bind(this)` in JSX props.
// Doesn't support Flow annotations yet
export default function(file, api) {
const j = api.jscodeshift;
const isReactClass = p => {
const extended = p.node.superClass;
return (
extended && (
extended.type === 'MemberExpression' &&