This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rest_client' | |
require 'fileutils' | |
require 'logger' | |
require 'childprocess' | |
require 'yaml' | |
module Conductor | |
module Verifier | |
class Runner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveRecord::Base.connection.select_all(%(show table status where collation like '%latin1%')).each do |options| | |
table_name = options['Name'] | |
puts "Started Processing\t#{table_name}" | |
FileUtils.mkdir_p(Rails.root.join('tmp/db-conversion')) | |
filename_pre_transform = Rails.root.join("tmp/db-conversion/conductor.#{table_name}.pre.sql").to_s | |
filename_post_transform = Rails.root.join("tmp/db-conversion/conductor.#{table_name}.post.sql").to_s | |
commands = [] | |
commands << %(mysqldump -uroot --opt --skip-set-charset --default-character-set=latin1 --skip-extended-insert conductor_dev --tables #{table_name} > #{filename_pre_transform}) | |
commands << %(perl -i -pe 's/DEFAULT CHARSET=latin1/DEFAULT CHARSET=utf8/' #{filename_pre_transform}) | |
commands << %(iconv -f LATIN1 -t UTF8 #{filename_pre_transform} > #{filename_post_transform}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Before you use this: | |
# git clone git://github.com/some-other-user/their-repo | |
# This assumes that origin is the repo that you are merging into! | |
require 'rubygems' | |
gem 'rest-client' | |
gem 'crack' | |
require 'rest-client' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file demonstrates a quick and dirty means of testing a file. | |
# Above the ```if __FILE__ == $0``` line is where the "production" code | |
# is written. Inside the IF block, the "test" code is written. | |
class Inline | |
def to_s | |
'Hello' | |
end | |
end | |
# From Terminal, you can type `ruby class-inline.rb` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# By making use of Ruby's natural coercion methods (i.e. #to_s, #to_i) | |
# we can save some headaches with potential nil objects. | |
# By overwriting the #to_s method on a class, we can get a lot of benefits | |
# in our presentation logic. We don't have to remember are we using #title | |
# or #pretty_title. | |
# I would caution that we not put markup in the #to_s method, as that violates | |
# the intent of #to_s. In fact, markup should probably not be in the model, | |
# as the markup makes an assumption about how the content is presented. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2012 Jeremy Friesen | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "[⚡]" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty) /" | |
} | |
function __my_rvm_ruby_version { | |
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# A git hook script to find and fix trailing whitespace | |
# in your commits. Bypass it with the --no-verify option | |
# to git-commit | |
# | |
if git-rev-parse --verify HEAD >/dev/null 2>&1 ; then | |
against=HEAD | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# project completion for Sublime projects by Jeremy Friesen <jeremy.n.friesen@gmail.com> | |
function _project { | |
local cur | |
COMPREPLY=() | |
_get_comp_words_by_ref cur | |
COMPREPLY=( $(find $HOME/Repositories -type d -maxdepth 1 -mindepth 1 -exec basename {} \; | egrep "^$cur")) | |
} | |
complete -F _project -o default project |