Skip to content

Instantly share code, notes, and snippets.

View sixfeetover's full-sized avatar

Jeff Fraser sixfeetover

View GitHub Profile
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@sixfeetover
sixfeetover / table_type.sql
Last active December 21, 2015 03:39
Pass table variable as a procedure variable in SQL Server
create type GKCTable as table (
id int,
description varchar(255)
)
go
create procedure dbo.PrintGKC(@gkc_table GKCTable readonly)
as
select *
require 'redis'
require 'hiredis'
require "redis/connection/hiredis"
total = 0
conn = Redis.new(db: 1, driver: :hiredis, path: '/tmp/redis.sock')
(1000...1100).each do |section|
key = "section:#{section}"
@sixfeetover
sixfeetover / install.sh
Created February 3, 2013 00:54
Install older ruby with modern command line tools on OS X Lion/Mountain Lion
# Sources:
# http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion
# https://github.com/sstephenson/ruby-build#special-environment-variables
# Install command line tools from https://developer.apple.com/downloads/index.action. Then:
sudo chown -R `whoami` /usr/local
brew update
brew upgrade rbenv
@sixfeetover
sixfeetover / sqlserver_options.rb
Created April 5, 2012 19:47
Set SQL Server options in rails for tiny_tds
module ActiveRecord
module ConnectionAdapters
class SQLServerAdapter < AbstractAdapter
def configure_connection
raw_connection_do "set concat_null_yields_null on; set nocount on;"
end
end
end
end
@sixfeetover
sixfeetover / benchmark.rb
Created March 15, 2012 15:55
Comparing [].join to string interpolation, different ruby versions
require 'benchmark'
n = 1_000_000
def key_arr(prefix, id, *suffixes)
[prefix, id, suffixes].flatten.compact.join ":"
end
def key_str1(prefix, id, *suffixes)
"#{prefix}:#{id}:#{suffixes.flatten.compact.join(':')}"
@sixfeetover
sixfeetover / benchmark.rb
Created March 8, 2012 21:20
Compare [].join to string interpolation
# Ruby 1.9.3-p125
require 'benchmark'
variable = 'string'
integer = 5
n = 1_000_000
Benchmark.bm do |x|
x.report("array:") do
# put this in lib
module Merb
module PartsMixin
# Dispatches a PartController.
# ==== Parameters
# opts<Hash>:: A Hash of Options. (see below)
#
# ==== Options
# An option hash has two parts.
@sixfeetover
sixfeetover / syntax_highlighting.py
Created November 4, 2011 16:04 — forked from JeanMertz/syntax_highlighting.py
Ruby on Rails syntax highlight switcher for Sublime Text 2
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid