Skip to content

Instantly share code, notes, and snippets.

View jimmed's full-sized avatar
:octocat:
#purrprogramming

Jim O'Brien jimmed

:octocat:
#purrprogramming
View GitHub Profile
@jimmed
jimmed / machine.js
Last active August 10, 2020 14:40
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
import React from "react";
class LifecycleDemo extends React.Component {
constructor() {
super()
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
this.props.onClose();
}
let lastRequestId = 0
const searchRequest = (query) => {
const requestId = ++lastRequestId
// fetch results somehow, and then...
return fetchSearchResults(query)
.then(results => {
if (requestId === lastRequestId) {
performStateUpdate(results) // do your state updates here
@jimmed
jimmed / README.md
Last active January 23, 2018 13:34

MathJax for Slack in Rambox

Instructions

  1. Fire up Rambox
  2. Switch to the Configuration tab (the first tab on the topbar in Rambox)
  3. In the Enabled Services section, find the Slack instance you want to add MathJax to, and click its settings cog.
  4. Expand the Advanced section at the bottom of the settings panel that pops up.
  5. Copy the contents of the script above, and paste it into the Custom Code text area.
  6. Save the settings and enjoy MathJaxiness

Keybase proof

I hereby claim:

  • I am jimmed on github.
  • I am jimmed (https://keybase.io/jimmed) on keybase.
  • I have a public key ASDa85XFQBUnn-Tw4tps-FhtabjyVnGSCHYZt-M1R9phRwo

To claim this, I am signing this object:

@jimmed
jimmed / suitcx.js
Created August 8, 2016 10:27
It's `suitcx`. Like `cx`, but wearing a suit.
import cx from 'classnames'
import capitalize from './capitalize'
/**
* It's `suitcx`. Like `cx`, but for suitCSS
*
* @param {string} parent - The main suitCSS class, i.e. `ChatItem` or `ChatItem-message`.
* @param {Object} [modifiers] - The suitCSS modifiers to apply, where each key is the name of the modifier applied. For each key/value pair of the object; if a value is a string, the modifier name will be the value appended to the key (in camel-case); otherwise, the modifier will only be added if the value is truthy.
* @param {Object} [state] - The suitCSS state to apply, where each key is the name of the state to be applied, and the value used to determine whether to apply the state.
*
var toString = Function.prototype.toString
var hasOwnProperty = Object.prototype.hasOwnProperty
var regexpCharacters = /[\\^$.*+?()[\]{}|]/g
var regexpIsNativeFn = toString.call(hasOwnProperty)
.replace(regexpCharacters, '\\$&')
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?')
var regexpIsNative = RegExp('^' + regexpIsNativeFn + '$')
function toSource (func) {
if (!func) return ''
try {
@jimmed
jimmed / bootstrap.js
Last active August 29, 2015 14:26 — forked from Unitech/bootstrap
PM2 / Keymetrics for Heroku/Rackspace/Joyent/Amazon Elasticbeanstalk/Azure...
// Make sure you added pm2 as a dependency in your package.json
// Then in your Procfile, do a simple `node bootstrap.js`
var pm2 = require('pm2');
var MACHINE_NAME = 'hk1';
var PRIVATE_KEY = 'z1ormi9vomgq66';
var PUBLIC_KEY = 'oa0m7nuhdfibi16';
var instances = process.env.WEB_CONCURRENCY || 1; // Set by Heroku
@jimmed
jimmed / README.md
Last active August 29, 2015 14:06
Duplicate finder for google play music

Instructions

  1. Copy the code above (I recommend clicking the 'Raw' button to get at it more easily)
  2. Open all your music
  3. Zoom out as far as you can.
  4. Open up the Menu > Tools > Developer > JavaScript Console
  5. Paste in the code, and hit Enter.
@jimmed
jimmed / config.fish
Last active August 29, 2015 14:04
My config.fish
# Aliases to common git methods
function gs; git status --short $argv; end;
function gd; git diff --color $argv; end;
function gf; git fetch -p; end;
function gpl; git pull $argv; end;
function gps; git push $argv; end;
function gch; git checkout $argv; end;
function gb; git branch $argv; end;
function ga; git add $argv; end;
function gco; git commit -m $argv; end;