Skip to content

Instantly share code, notes, and snippets.

View TrevorS's full-sized avatar

Trevor Strieber TrevorS

View GitHub Profile
" add change inside ruby block param list (|x, y|) not currently working
" call textobj#user#plugin('rubyblockparam', {
" \ 'list': {
" \ 'pattern': ['do \|', '\|'],
" \ 'select-a': 'aB',
" \ 'select-i': 'iB',
" \ }
" \ })
# Global Configuration
def load_config(file)
File.exist?(file) ? YAML.load_file(file) : {}
end
def rails_platform
if Rails.env.production?
ENV['PLATFORM'] != 'production' ? :staging : :production
else
Rails.env.to_sym
@TrevorS
TrevorS / fix.sh
Created April 28, 2015 22:49
fix permissions in a Rails application
find . -type f ! -path "./.git/*" ! -path "./bin/*" -perm 755 -exec chmod 644 {} \;
#!/usr/bin/env ruby
# encoding: utf-8
require 'benchmark'
iterations = 5_000_000
a = 'test a'
b = 'test b'
c = 'test c'
SELECT DB_NAME() AS DbName,
name AS FileName,
size/128.0 AS CurrentSizeMB,
size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT)/128.0 AS FreeSpaceMB
FROM sys.database_files;
SELECT total_worker_time/execution_count AS AvgCPU
, total_worker_time AS TotalCPU
, total_elapsed_time/execution_count AS AvgDuration
, total_elapsed_time AS TotalDuration
, (total_logical_reads+total_physical_reads)/execution_count AS AvgReads
, (total_logical_reads+total_physical_reads) AS TotalReads
, execution_count
, SUBSTRING(st.TEXT, (qs.statement_start_offset/2)+1
, ((CASE qs.statement_end_offset WHEN -1 THEN datalength(st.TEXT)
ELSE qs.statement_end_offset
#!/usr/bin/env ruby
# encoding: utf-8
require 'digest'
source = ARGV[0]
target = ARGV[1]
md5 = Digest::MD5
def parse(source, crypt)
File.open(source, 'rb').map(&:strip).each_with_object({}) do |line, lines|
#!/usr/bin/env bash
cat dsl_migrate.txt | cut -d '|' -f 4 | sort | uniq | grep -v 10183 | grep -v 10184 | grep -v 10189 | grep -v 10190 | grep -v 10191 | grep -v 10192 | grep -v 10193 | grep -v 10194 | grep -v 10195 | grep -v 10196 | grep -v 10197 | grep -v 10198 | grep -v 10199 | grep -v 10200 | grep -v 10201 | grep -v 10202 | grep -v 10203 | grep -v 10204 | grep -v 10206 | grep -v 10209 | grep -v 10238 | grep -v 10253 | grep -v 10255 | grep -v 10382 | grep -v 10383 | grep -v 10408 | grep -v 10409 | grep -v 10452 | grep -v 10514 | grep -v 10527 | grep -v 10529 | grep -v 10531 | grep -v 10533 | grep -v 10535 | grep -v 10601 | grep -v 10603 | grep -v 10604 | grep -v 10605 | grep -v 10606 | grep -v 10607 | grep -v 10608 | grep -v 10609 | grep -v 10610 | grep -v 10611 | grep -v 10612 | grep -v 10613 | grep -v 10614 | grep -v 10615 | grep -v 10616 | grep -v 10617 | grep -v 10618 | grep -v 10619 | grep -v 10620 | grep -v 10621 | grep -v 10622 | grep -v 10623
# api info
api = 'dictionaryapi.com/api/v1/references/collegiate/xml'
sounds = 'media.merriam-webster.com/soundc11'
key = process.env.PRONOUNCE_KEY
# xml parser
parser = require 'xml2json'
# define String#startsWith
String::startsWith = (string) -> @.lastIndexOf(string, 0) == 0
@TrevorS
TrevorS / whiteboard_cleaner.sh
Created January 20, 2015 19:32
whiteboard cleaner
#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2