Skip to content

Instantly share code, notes, and snippets.

View martin-brennan's full-sized avatar

Martin Brennan martin-brennan

View GitHub Profile

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@martin-brennan
martin-brennan / _form_errors.html.erb
Last active May 12, 2019 04:46
Rails form example using Virtus and ActiveModel
<% if form.errors.full_messages.length.positive? %>
<ul>
<% form.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
<% end %>
angular.module('app', []);
angular.module('app').controller('HomeController', HomeController);
angular.module('app').controller('SubController', SubController);
HomeController.$inject = ['$scope', '$rootScope'];
SubController.$inject = ['$scope'];
function HomeController($scope, $rootScope) {
$scope.$on('globalEvent', runGlobalLog);
@martin-brennan
martin-brennan / thisst2.xml
Created February 1, 2015 09:21
highlight js this in sublime text 2
<dict>
<key>name</key>
<string>Super this (JavaScript)</string>
<key>scope</key>
<string>source.js variable.language.js</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold italic</string>
<key>foreground</key>
@martin-brennan
martin-brennan / gulplr.js
Created January 27, 2015 01:56
Gulp Livereload
gulp.task('startServer', function () {
// restart the server
gulp.src('.')
.pipe(webserver({
livereload: true,
directoryListing: false,
open: true
}));
});
@martin-brennan
martin-brennan / iisgzip
Created January 11, 2015 10:33
iis gzip compression
cd %PROGRAMFILES%IIS Express
appcmd set config -section:urlCompression /doDynamicCompression:true
appcmd set config /section:staticContent /+[fileExtension='.json',mimeType='application/json']
appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json',enabled='True']" /commit:apphost
@martin-brennan
martin-brennan / gem specification and dir in ruby
Created December 24, 2014 07:25
gem specification and dir in ruby
spec = Gem::Specification.find_by_name("rain-doc")
FileUtils.cp_r spec.gem_dir + '/templates/css/.', './rain_out/css'
@martin-brennan
martin-brennan / thor method options
Created December 24, 2014 07:19
thor method options
method_option :log_parse, aliases: "--lp", desc: "Show the output of each line parse."
method_option :parse_signatures, aliases: "--s", desc: "Parse method and class documentation too. Defaults to false."
@martin-brennan
martin-brennan / gem bin include lib
Last active August 29, 2015 14:12
gem bin include lib
path = __FILE__
while File.symlink?(path)
path = File.expand_path(File.readlink(path), File.dirname(path))
end
$:.unshift(File.join(File.dirname(File.expand_path(path)), '..', 'lib'))
@martin-brennan
martin-brennan / hasherb.rb
Created December 13, 2014 08:55
hasherb.rb
require 'erb'
require 'ostruct'
opts = OpenStruct.new({
first_name: "Martin",
last_name: "Brennan"
})
# load the erb template. 'Hello <%= first_name %> <%= last_name %>.'
template = File.read('template.erb')