Skip to content

Instantly share code, notes, and snippets.

View realityforge's full-sized avatar

Peter Donald realityforge

View GitHub Profile
@realityforge
realityforge / maven_clone.rb
Created August 9, 2016 03:31
Copy artifacts from one Maven repository to another
#!/usr/bin/env ruby
require 'fileutils'
# Run this form the directory that is being uploaded.
# It will delete the file as it goes
USER='user'
PASSWORD='password'
REPO='repo.example.com/repository/thirdparty'
@realityforge
realityforge / AllLocksInDatabase.sql
Last active April 29, 2021 02:00
SQL Server Performance Queries
SELECT
SessionID = s.Session_id,
resource_type,
DatabaseName = DB_NAME(resource_database_id),
request_mode,
request_type,
login_time,
host_name,
program_name,
client_interface_name,
@realityforge
realityforge / gitlg.sh
Created January 9, 2015 11:16
git lg alias
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit"
@realityforge
realityforge / .gitignore_global
Last active August 29, 2015 14:10
Global .gitignore
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
*~

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@realityforge
realityforge / xfer.rb
Last active August 29, 2015 14:02
A simple script I use to perform repetitive mechanical tasks across multiple source code repositories
require 'fileutils'
def mysystem(command)
puts "system (#{Dir.pwd}): #{command}" if @verbose
system(command) || (raise "Error executing #{command} in #{Dir.pwd}")
end
def in_dir(dir, &block)
begin
Dir.chdir(dir)
@realityforge
realityforge / convert_rails_db_to_domgen.rb
Created September 30, 2013 06:28
Simple bit of code to convert an old rails style schema dump to a domgen architecture.rb
# Output of:
# ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, File.new("Output.rb","wb") )
output_filename = "architecture.rb"
output = File.new(output_filename, "wb")
def pascal_case(camel_cased_word)
word_parts = split_into_words(camel_cased_word).collect { |part| part[0...1].upcase + part[1..-1] }.collect { |v| v.upcase == 'ID' ? 'ID' : v }
return word_parts[0] if (word_parts.size == 1 && word_parts[0] == word_parts[0].upcase)
word_parts.join('')
@realityforge
realityforge / all2dos.sh
Created March 25, 2012 22:56
Convert a repository to Unix EOL
#!/bin/bash
# If fromdos is not present on your system you can try the slower: "perl -pi -e 's/\r\n/\n/;'"
find . \( ! -name '.git' -type f -and -name '*.sql' -or -name '*.textile' -or -name '*.css' -or -name '*.html' -or -name '*.java' -or -name '*.js' -or -name '*.jsp' -or -name '*.properties' -or -name '*.txt' -or -name '*.xml' -or -name '*.xsd' -or -name '*.xsl' -or -name '*.rb' -or -name '*.haml' -or -name '*.rake' -or -name '*.sass' -or -name '*.rhtml' -or -name '*.yml' -or -name '*.yaml' -or -name 'LICENSE' -or -name 'CHANGELOG' -or -name 'Rakefile' -or -name 'rakefile' -or -name 'Buildfile' -or -name 'buildfile' -or -name '*.gemspec' -or -name '.gitignore' -or -name '.gitattributes' \) -exec fromdos {} \;