Skip to content

Instantly share code, notes, and snippets.

View jimeh's full-sized avatar

Jim Myhrberg jimeh

View GitHub Profile
/* ==UserStyle==
@name GitHub Dark Diff Color Customizer (customized)
@namespace StylishThemes
@version 2.0.4-custom
@description A diff color customization style, colorblind friendly by default
@author StylishThemes and contributors
@homepageURL https://github.com/StylishThemes/Feature-Override-Styles/
@supportURL https://github.com/StylishThemes/Feature-Override-Styles/issues/new/choose
@updateURL https://gist.githubusercontent.com/jimeh/57b7e6e6e0107036c167f10f87a55861/raw/github-dark-diff-color-customizer.css
@license MIT
@jimeh
jimeh / show-and-hide-any-app.applescript
Created June 8, 2011 00:45
AppleScript to help make any app toggle-able via a global hotkeys like the Twitter and Sparrow apps.
-----------------------------------------
-- Show and Hide <application>
-----------------------------------------
--
-- This script allows you to easily
-- toggle the visibility of a specific
-- app, similar to how Twitter and
-- Sparrow toggle with their global
-- hotkey option.
--

RSpec Hook Order

The following is a quick reference to exact order of hook execution in RSpec. The output from hook_spec.rb is:

describe: "a thing"
  -> before: all (top)
    -> around: before (top)
      -> before: each (top)
        -> example: "success" (top)
@jimeh
jimeh / mass_insert_mongo.js
Created September 20, 2009 00:44
Simple MySQL vs. MongoDB Insert benchmark.
for (var i=0; i < 100000; i++) {
db.mass_insert.save({
"first_name": "James",
"middle_name": "Richard",
"last_name": "Windsgate",
"email": "jamesrichardwindsgate@email.com"
});
};
@jimeh
jimeh / bluetooth_sleep.lua
Created January 29, 2019 01:16 — forked from ysimonson/bluetooth_sleep.lua
Hammerspoon script to disable bluetooth when the computer is put to sleep. Requires `blueutil` to be installed (`brew install blueutil`).
function bluetooth(power)
print("Setting bluetooth to " .. power)
result = hs.execute("blueutil --power " .. power)
if result.rc ~= 0 then
print("Unexpected result executing `blueutil`: rc=" .. result.rc .. " type=" .. result.type .. " output=" .. result.output)
end
end
function f(event)
@jimeh
jimeh / sudome.rb
Created November 20, 2009 23:30
sudome — A simple Ruby method which checks if the current script is running as root, and if not, re-invokes itself by using the sudo command.
# A simple Ruby method which checks if the current script
# is running as root, and if not, re-invokes itself by
# using the sudo command.
def sudome
if ENV["USER"] != "root"
exec("sudo #{ENV['_']} #{ARGV.join(' ')}")
end
end
@jimeh
jimeh / README.md
Created January 17, 2010 14:20
A simple key/value store model for Rails using the database and memcache

Rails Setting model

This is a semi-quick key/value store I put together for a quick way to store temporary data related to what's in my database, in a reliable way. For example, I'm using it to keep track of where a hourly and a daily crontask that processes statistics left off, so it can resume only processing and summarizing new data on the next run.

Code quality most likely is not great, but it works. And I will update this gist as I update my project.

How It Works

The settings table has two columns, a key and a value column. The value column is serialized, so you can technically store almost anything in there. Memcache is also used as a caching layer to minimize database calls.

@jimeh
jimeh / com.rabbitmq.rabbitmq-server.plist
Created March 24, 2011 10:47
Mac OS X launchctl plist for Homebrew-based RabbitMQ installations. Place in: ~/Library/LaunchAgents
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.rabbitmq.rabbitmq-server</string>
<key>Program</key>
<string>/usr/local/sbin/rabbitmq-server</string>
@jimeh
jimeh / p2pool
Last active January 12, 2018 13:26
Quickly hacked together init.d script for p2pool.
#!/bin/sh
### BEGIN INIT INFO
# Provides: p2pool
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: p2pool startup script
# Description: p2pool startup script
### END INIT INFO
@jimeh
jimeh / .rubocop.yml
Last active September 18, 2017 11:20
Error in Rubocop 0.50.0's Style/SafeNavigation cop
AllCops:
TargetRubyVersion: 2.4