Skip to content

Instantly share code, notes, and snippets.

View realityforge's full-sized avatar

Peter Donald realityforge

View GitHub Profile
@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)

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 / .gitignore_global
Last active August 29, 2015 14:10
Global .gitignore
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
*~
@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 / 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 {} \;
@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 / 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 / diff.sh
Created June 27, 2017 03:06
Git diff excluding vendor dir
git diff . ':(exclude)vendor/*'
@realityforge
realityforge / externalize.rb
Last active February 5, 2019 23:48
Setup a git repository master that points at actual repository
PROJECT_NAME='jsinterop-generator'
PROJECT_SLUG='jsinterop-generator'
UPSTREAM_OWNER='google'
LOCAL_OWNER='realityforge'
LOCAL_BRANCHES_TO_KEEP=%w(TravisCiIntegration)
#WARNING this will delete local branches which may contain your changes
DELETE_LOCAL_BRANCHES=true
def mysystem(command, fail_on_error = true)
@realityforge
realityforge / Notes.md
Created November 4, 2019 01:37
Making react4j-todomvc j2cl compatible

How to build

First you need to install updated build tools that does not copy the */public/ assets into the directory used by j2cl compile. To install build tools locally do:

> git clone https://github.com/realityforge/j2cl.git
> cd j2cl
> git checkout NoCopyPublicAssets
> mvn clean install