Skip to content

Instantly share code, notes, and snippets.

View BinaryMuse's full-sized avatar
🏳️‍🌈
Just gayin' up the place the best I can

Michelle Tilley BinaryMuse

🏳️‍🌈
Just gayin' up the place the best I can
View GitHub Profile
@BinaryMuse
BinaryMuse / gist:8697520
Created January 29, 2014 21:23
OS X Command Line Fu

Text File Operations

Reverse the lines of a file

tail -r file

Join each line of a file together with a character

angular.module('app.common.directives.html-editor', [])
.directive('htmlEditor', function() {
return {
restrict: 'E',
scope: {
'html': '='
},
link: function (scope, element, attrs, ctrl) {
// this is a browserify bundle where my react components live
@BinaryMuse
BinaryMuse / gist:9592591
Last active August 29, 2015 13:57
Highlight react DOM
setInterval(function() {
Array.prototype.slice.call(document.querySelectorAll('[data-reactid]')).forEach(function(node) {
node.style.backgroundColor = 'rgba(255, 0, 0, 0.1)';
})
}, 500)
@BinaryMuse
BinaryMuse / gist:e615814ae70f0b6f5460
Last active August 29, 2015 14:01
ChangingModelPropMixin
ChangingModelPropMixin = function(propName, handlerName) {
return {
componentWillReceiveProps: function(nextProps) {
if (nextProps[propName] && nextProps[propName] !== this.props[propName]) {
this.props[propName].removeListener("change", this[handlerName]);
nextProps[propName].on("change", this[handlerName]);
}
},
componentDidMount: function () {

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@BinaryMuse
BinaryMuse / README.md
Last active August 29, 2015 14:07
keyMirror with namespaces
var data = keyMirror({
  ONE: null,
  TWO: null,
  
  OTHER: keyMirror({
    STUFF: null
  }, "OTHER")
});
@BinaryMuse
BinaryMuse / gist:1ef56674787db244343a
Last active August 29, 2015 14:10
Add .done to native ES6 Promises
/* Native HTML5 promises will swallow exceptions if you're not careful. For example:
*
* promise.then(function() {
* something.froEach(iterator);
* });
*
* This extension patches the Promise prototype with a `done` method that will log errors:
*
* promise.then(function() {
* something.froEach(iterator);
@BinaryMuse
BinaryMuse / EmbeddedGwt.java
Created March 28, 2010 07:11
DND - Serving GWT app with embedded Java - used on blog
package net.binarymuse.EmbeddedGwt;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.webapp.WebAppContext;
public class EmbeddedGwt {
public static void main(String[] args) throws Throwable {
HTML Template:
{foreach releases as release}
<h1><a href="{release.link}">{release.title}</a></h1>
<p>{release.teaser}</p>
{/foreach}
<p><small>If you believe this has been sent to you in error, please safely <a href="{optout_confirm_uri}">unsubscribe</a>.</small></p>
Feed URL:
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ (\1$(parse_git_stash))/"
}
parse_git_stash() {
git stash list 2> /dev/null | wc -l | sed -e "s/ *\([0-9]*\)/\ \+\1/g" | sed -e "s/ \+0//"
}
parse_svn_branch() {
parse_svn_url | sed -e 's#^'"$(parse_svn_repository_root)"'##g' | awk -F / '{print " ("$1 "/" $2 ")"}'
}
parse_svn_url() {