Skip to content

Instantly share code, notes, and snippets.

Jeffrey Wear wearhere

Block or report user

Report or block wearhere

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@wearhere
wearhere / client.js
Last active Jun 8, 2018
Making SSE easy
View client.js
import _ from 'underscore';
import $ from 'jquery';
import Backbone from 'backbone';
const DataCollection = Backbone.Collection.extend({
url() {
return '/api/data';
},
fetch() {
@wearhere
wearhere / main.js
Created Dec 3, 2017
Minimal Babel setup for use with React "hello world". External dependencies purposefully not handled—see https://mixmax.com/blog/rollup-externals for solutions.
View main.js
import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render(
<h1>Hello, world!</h1>,
document.getElementById('root')
);
@wearhere
wearhere / actual.js
Last active Jul 28, 2017
Draft of module for adding custom helpers as well as a bind operator that caches. Solution for https://github.com/tc39/proposal-bind-operator/issues/46.
View actual.js
var f = ctx::ns.obj.func;
var g = ::ns.obj.func;
var h = new X::y;
@wearhere
wearhere / promisify.js
Created Mar 21, 2017
Simple promisify.
View promisify.js
function promisify(fn) {
return function(...args) {
return new Promise((resolve, reject) => {
fn.call(this, ...args, (err, res) => {
if (err) reject(err);
else resolve(res);
});
});
};
};
@wearhere
wearhere / test.js
Last active Jun 19, 2018
Using async/await with Bluebird in Node 7.6.0.
View test.js
/* eslint no-console: false */
const bluebird = require('bluebird');
function isBluebirdPromise(promise) {
return promise.constructor === bluebird;
}
function respond() {
return new bluebird((resolve) => {
setTimeout(() => resolve('hi'), 2000);
@wearhere
wearhere / link.css
Created Mar 1, 2017
Mostly put's GitHub's link color to back to how it was before 03.01.2017, i.e. not stabbing your eyes. Credit to https://userstyles.org/styles/139584/github-return-link-color. Load using a Chrome extension like Stylebot.
View link.css
@wearhere
wearhere / unstick.fish
Last active Feb 10, 2017
Shell functions for killing rogue servers. Assumes that touching `src/server/router.js` will restart the server.
View unstick.fish
# Put this in ~/.config/fish/functions/.
function unstick
kill -9 (lsof -ti :$argv[1]); and touch src/server/router.js
end
@wearhere
wearhere / HelloWorld.ract
Last active Feb 9, 2017
Backbone + Ractive + Rollup
View HelloWorld.ract
<h1>Hello, {{ titlecase(name) }}</h1>
@wearhere
wearhere / HandlebarsHelpers.js
Last active Feb 9, 2017
Backbone + Handlebars + Rollup
View HandlebarsHelpers.js
export default function(Handlebars) {
Handlebars.registerHelper('titlecase', (string) => {
if (!string) return string;
return string[0].toUpperCase() + string.slice(1);
});
}
View index.js
var rollup = require('rollup');
var handlebars = require('rollup-plugin-handlebars-plus');
var nodeResolve = require('rollup-plugin-node-resolve');
// This can be whatever as long as it's consistent below.
var jqueryModuleId = 'jquery';
rollup({
entry: 'main.js',
external: [jqueryModuleId],
You can’t perform that action at this time.