Skip to content

Instantly share code, notes, and snippets.

View ymek's full-sized avatar

Myke Stubbs ymek

  • cyberspace
View GitHub Profile
#!/usr/bin/env ruby
require 'benchmark'
def graphite_test(host)
system("echo 'ap.test.foo 1 #{Time.now.to_i}' | nc #{host} 2003")
# send(metric_path value unix_timestamp)
# example: send("foo.bar.baz my_value 12345678")
end
@ymek
ymek / users_test.rb
Created August 22, 2013 19:04
Example subdomain integration test
require 'test_helper'
class Api::UsersTest < ActionDispatch::IntegrationTest
def setup
host! 'api.host.com'
end
test 'get /v1/users/1.json' do
user = users(:one)
get "/v1/users/#{user.id}.json"
/* global module:false */
var lrSnippet = require('connect-livereload')();
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
var rewriteRulesSnippet = require('grunt-connect-rewrite/lib/utils').rewriteRequest;
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
module.exports = function(grunt) {
uglify: {
options: {
mangle: false,
banner: '<%= banner %>'
},
/*
* Example alternative to usemin automagicalness
*
dist: {
@ymek
ymek / gist:6179635
Last active December 20, 2015 18:59
copy: {
dist: {
files: [
{
expand: true,
cwd: 'sinatra',
src: ['**', '!public/js/**'],
dest: '<%= dist_dir %>',
filter: 'isFile'
}
autoload -U colors && colors
# between the local and remote branches
function git_remote_status() {
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
if [[ -n ${remote} ]] ; then
ahead=$(git rev-list $remote..HEAD 2>/dev/null | wc -l)
behind=$(git rev-list HEAD..$remote 2>/dev/null | wc -l)
if [ $ahead -eq 0 ] && [ $behind -eq 0 ]
DEBUG = true
def debug(message)
puts "[#{Time.now}] #{caller[0][/`.*'/][1..-2]}::#{message}" if DEBUG
end
@ymek
ymek / capitalize_dirs.rb
Created November 29, 2012 07:14
Capitalize all directory names within a given path
#! /usr/bin/env ruby
##
# Capitalize all directory names within a given path
#
# defaults to the current working directory if no supplied path
base_dir = ARGV[0] || Dir.pwd
Dir.chdir base_dir do
dirs = Dir.glob('*').reject { |f| !File.directory?(f) }
@ymek
ymek / file_sort.rb
Created November 29, 2012 06:57
Quickly sort related files in a given directory into subdirectories
#! /usr/bin/env ruby
##
# Quickly sort related files in a given directory into
# subdirectories of that same directory
#
# defaults to the current working directory if no supplied path
require 'fileutils'
base_dir = ARGV[0] || Dir.pwd
# This works well enough for debugging
# hax for irbrc
class Object
def imethods
(self.methods - Object.instance_methods)
end
end