Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter Donald realityforge

View GitHub Profile
@realityforge
realityforge / all2dos.sh
Created Mar 25, 2012
Convert a repository to Unix EOL
View all2dos.sh
#!/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 {} \;
@realityforge
realityforge / convert_rails_db_to_domgen.rb
Created Sep 30, 2013
Simple bit of code to convert an old rails style schema dump to a domgen architecture.rb
View convert_rails_db_to_domgen.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 / _font-awesome.scss
Created May 25, 2014
Rework of font-awesome to use placeholder classes
View _font-awesome.scss
/*
This is the initial import and rework of font-awesome to use placeholders.
*/
// Variables
// --------------------------
$fa-border-color: #eee !default;
$fa-inverse: #fff !default;
$fa-li-width: (30em / 14) !default;
View _brightness.scss
// Brightness math based on:
// http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx
$red-magic-number: 241;
$green-magic-number: 691;
$blue-magic-number: 68;
$brightness-divisor: $red-magic-number + $green-magic-number + $blue-magic-number;
@function brightness($color) {
// Extract color components
@realityforge
realityforge / xfer.rb
Last active Aug 29, 2015
A simple script I use to perform repetitive mechanical tasks across multiple source code repositories
View xfer.rb
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)
View pr.md

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:

View .gitignore_global
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
*~
View gitlg.sh
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 / snowden-ietf93.md
Last active Aug 29, 2015 — forked from mnot/snowden-ietf93.md
Transcript of Edward Snowden's comments at IETF93.
View snowden-ietf93.md
@realityforge
realityforge / AllLocksInDatabase.sql
Last active Nov 20, 2020
SQL Server Performance Queries
View AllLocksInDatabase.sql
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,