Skip to content

Instantly share code, notes, and snippets.

View roblingle's full-sized avatar

Rob Lingle roblingle

View GitHub Profile
@roblingle
roblingle / setup.js
Created October 21, 2018 21:43
Jest: avoid topology-destroyed error by waiting for index creation in `afterAll`
import mongoose from 'mongoose';
import MongodbMemoryServer from 'mongodb-memory-server';
let mongoServer;
beforeAll(async () => {
mongoServer = new MongodbMemoryServer();
const mongoUri = await mongoServer.getConnectionString();
await mongoose.connect(
mongoUri,
{useNewUrlParser: true},
@roblingle
roblingle / MuiThemeWrapper.js
Last active August 4, 2016 18:09
MuiThemeWrapper
/*
* MuiThemeWrapper.js
*
* Simplifies Material-UI React components when you don't have a single top-level component,
* which is common in Rails and Meteor where you're including components in pages as needed.
*
*/
import React, { Component } from 'react';
import {deepOrange500} from 'material-ui/styles/colors';
@roblingle
roblingle / bootstrap-editable-rails.js.coffee
Created June 4, 2014 21:06
Ran into problems with bootstrap-editable-rails in a turbolinks app. Could also happen in x-editable-rails. After a page change, attempting to use the editable fields would result in Uncaught RangeError: Maximum call stack size exceeded. This fixes it by only doing the setup for EditableForm once instead of every page change.
# Be sure to remove bootstrap-editable-rails from application.js
unless EditableForm
EditableForm = undefined
EditableForm = $.fn.editableform.Constructor
EditableForm::saveWithUrlHook = (value) ->
originalUrl = undefined
resource = undefined
originalUrl = @options.url
resource = @options.resource
@options.url = ((_this) ->
@roblingle
roblingle / roo_xlsm.rb
Created November 2, 2011 15:22
Tweaks to make the roo gem work for macro-enables spreadsheets
# Easy access to xlsm files through the roo gem, version 1.10.0.
# The error that led me to write this is in the file below for google fodder. Not exactly sure what was causing
# the problem, so I'm not sure that this change won't break everything on your computer or summon zombies.
#
# Be sure to tell roo that you don't care about the extension mismatch:
# xl = Excelx.new("C:/path/to/spreadsheet_with_macro.xlsm", :zip, :warning)
#
class Excelx
alias :old_initialize :initialize
(*
Folder action to queue downloaded torrents in your uTorrent web gui. With a dyndns account you can initiate downloads on your file server from wherever you happen to be.
Gotta have uTorrent with web gui (Windows, Mac, or Linux with Wine).
Gotta have growl, too.
- Paste into Script Editor
- Edit the user, password, and server url below.
- Add as a folder action on your download directory
@roblingle
roblingle / intune.rb
Created October 17, 2009 15:43
Use iTunes on Windows to control what's playing in XBMC
# Assumes that your Music library is shared out
# and XBMC accesses it via Windows filesharing.
#
# Install the xbmc gem: gem install xbmc (may also need to run 'gem sources -a http://gemcutter.org')
# Edit the variables below and save as intune.rb
# Run 'ruby intune.rb'.
require 'win32ole'
require 'xbmc'
Dir.glob(File.join(File.dirname(__FILE__), 'recipes/*.rb')).each {|f| require f }
@roblingle
roblingle / gist:54710
Created January 29, 2009 20:02 — forked from halbtuerke/gist:31934
star is for stash. +works in subdirectories.
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"