Skip to content

Instantly share code, notes, and snippets.

@rgoldfinger
rgoldfinger / app.js
Created June 16, 2014 04:07
real-time markdown editor in React.js
//node/express server routes for editing
// edit a post
router.get('/a/:id/edit', function(req, res) {
Post.findById(req.params.id, function(err, post) {
if (err) {
res.send(err);
} else {
res.render('createPost', {
@rgoldfinger
rgoldfinger / trailSorter.js
Created August 23, 2014 04:08
algorithm to sort a trail, where the points are out of order
var fs = require('fs');
var path = require('path');
var simple = require('simplify-js');
var geolib = require('geolib');
fs.readFile(path.join(__dirname, 'map.geojson'), 'utf8', function(err, data) {
// var jsonPoints = data;
var LoginStore = require('../stores/LoginStore');
var LoginActions = require('../actions/LoginActions');
var Login = React.createClass({
getInitialState: function () {
return {
expanded: false,
username: '',
constants = require('../constants/constants')
AppDispatcher = require('../dispatchers/appDispatcher')
ApiHelper = require('../helpers/ApiHelper')
LoginActionsCreators = {
# user actions
loginUser: (username, password) ->
merge = require('react/lib/merge')
EventEmitter = require('events').EventEmitter
AppDispatcher = require('../dispatchers/appDispatcher')
constants = require('../constants/constants')
CHANGE_EVENT = 'change'
_currentUser = null
_authToken = null
_exp = null
/* @flow */
import idx from 'idx';
if (typeof window !== 'undefined' && window.Rollbar) {
// TODO some way to disable console output. This seems to require a PR to rollbar's lib.
const { Rollbar } = window;
const nativeConsoleError = console.error;
// $FlowFixMe
console.error = (...args) => {
// If there's an error passed to the console, we want to use thar directly to preserve the stacktrace
/* @flow */
import idx from 'idx';
const regexsToIgnore = [
/Request blocked by client, probably adblock.*Branch/gi, // Branch init
/Request timed out.*Branch/gi, // Branch init
/GoogleAPI.*popup_closed_by_user/gi, // google auth
/GoogleAPI.*access_denied/gi, // google auth
/unhandled rejection was null or undefined/gi,
/script error/gi,
/* @flow weak */
import { transform, checkIgnore } from '../setupErrorLogging';
describe('setupErrorLogging', () => {
const errorsToSend = [
{
body: {
trace: {
exception: {
message: 'Received 401 after finding a window user',
<%_ if (!__DEV__ && !__FUNCTIONAL__) { _%>
<script>
var _rollbarConfig = {
accessToken: "xyz",
captureUncaught: true,
captureUnhandledRejections: true,
reportLevel: 'error',
payload: {
environment: '<%= ROLLBAR_ENVIRONMENT %>',
release: '<%= VERSION %>',
// --------------------------------------------------
// rollbar.ejs
// --------------------------------------------------
<%_ if (!__DEV__ && !__FUNCTIONAL__) { _%>
<script>
var _rollbarConfig = {
accessToken: "37c613c5a8b34fba89cd4fcfebc76808",
captureUncaught: true,
captureUnhandledRejections: true,
reportLevel: 'error',