Skip to content

Instantly share code, notes, and snippets.

@wtnabe
wtnabe / jshint4r.rake
Last active September 27, 2015 02:07
sample rake task for invoking jshint4r
if system( 'which jshint4r > /dev/null' )
desc "jshint"
task :jshint do
exit system( 'jshint4r -c config/jshint.yml -r compilation' )
end
end
@wtnabe
wtnabe / jshint4r.yml
Created September 6, 2011 06:16
sample config file for jshint4r
src:
- 'public/javascripts/**/*.js'
excludes:
- 'public/javascripts/**/*.min.js'
- 'public/javascripts/**/*.pack.js'
options:
asi: true
@wtnabe
wtnabe / start-jquery-for-dual-platform.js
Created September 8, 2011 10:12
invoke JavaScript function with jQuery when window.onload-like event fired
if ( typeof $.mobile == 'undefined' ) {
// PC
$(document).ready(function() {
//
});
} else {
// Mobile
$('[data-role=page]').live('pagecreate', function() {
//
});
@wtnabe
wtnabe / gist:1221548
Created September 16, 2011 08:25
make default format html for Rails 3
before_filter :default_format_to_html
def default_format_to_html
accept = request.headers['HTTP_ACCEPT']
if params[:format].nil? and
(accept.nil? or !accept.include?('text/html'))
request.format = 'html'
end
end
@wtnabe
wtnabe / svn-untracked.rake
Created September 21, 2011 05:38
list svn-untracked files with .gitignore ( without svn:ignore )
desc 'list svn untracked files'
task 'svn-untracked' do
excludes = File.read( File.dirname(__FILE__) + '/.gitignore' ).lines.map(&:chomp)
list = Rake::FileList[`svn stat --ignore-externals | awk '$1 == "?" {print $NF}'`.lines.map(&:chomp)]
excludes.each { |ex|
list.exclude( ex )
}
puts list.select { |e|
File.file?( e )
@wtnabe
wtnabe / gist:1344386
Created November 7, 2011 07:13
A option for shut xargs trailed command up when no data from stdin on Linux
#! /bin/sh
XARGS_NO_RUN=''
if [ `uname` = 'Linux' ]; then XARGS_NO_RUN='--no-run-if-empty'; fi
find PATH CONDITIONS | xargs $XARGS_NO_RUN COMMAND
@wtnabe
wtnabe / Gemfile
Created November 9, 2011 06:45
reST-writing environment with realtime HTML-preview
# -*- mode: ruby -*-
source :rubygems
gem 'guard-shell'
gem 'guard-livereload'
@wtnabe
wtnabe / Guardfile
Created November 12, 2011 03:28
rake tasks for jasmine with guard-livereload
# -*- mode: ruby -*-
guard :livereload do
watch( /\.js$/ ) { '/' }
end
@wtnabe
wtnabe / README
Created December 4, 2011 06:04
rspec task file for each spec directories
put .rake file as lib/tasks/spec.rake