Pass the filename or pipe the contents of the file into the script.
#> ./camel-to-hyphen-case.rb path/to/file.scss > converted_file.scss
Pass the filename or pipe the contents of the file into the script.
#> ./camel-to-hyphen-case.rb path/to/file.scss > converted_file.scss
Rails uses a concept called details to find a template using an Action View Resolver (actionpack-3.2.14/lib/action_view/template/resolver.rb). Version Cake registers an additional detail (called versions) to add more granularity when locating a template. The resolver builds a query from the details which is used to search the directory for the templates.
resolver = ActionView::OptimizedFileSystemResolver.new(Rails.root.join("app/views"))
template_name = "tester/index"
details = {:locale => [:en], :formats => [:html], :handlers => [:erb, :builder, :coffee, :jbuilder], :versions => [:v1]}
# without RABL
query = resolver.build_query(template_name, details)
=> ".../app/views/tester/index{.en,}{.v1,}{.html,}{.erb,.builder,.coffee,.jbuilder,}"| # Git commands | |
| # ggh - git url: get the url to the current github repo (assumes it's the remote push server) | |
| # ggbn - git branch name: get the name of the current branch | |
| # ggwip - git wip: commit the current staged and unstaged files with a commit message of WIP | |
| # ggundo - git undo: pull the last commit off as staged changes | |
| # ggbh - git branch history: list the 6 recent branches by commit date | |
| # ggbs - git branch smart history: list the 6 recent branches by commit date without master, staging or production | |
| # ggbl - git branch last: get the last branch that is not master, staging or production | |
| alias ggh="git remote -v 2> /dev/null | grep push | awk '{print \$2}' | sed 's/:/\//' | sed 's/git@\(.*\)\.git/https:\/\/\1/'" |
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'nokogiri' | |
| require 'open-uri' | |
| class GithubStargazers | |
| def initialize(repo) | |
| @repo = repo |
| class ActiveRecord::Base | |
| DATE_FIELDS = [:created_at, :updated_at] | |
| after_save :make_dates_less_precise | |
| def make_dates_less_precise | |
| DATE_FIELDS.each do |date_field| | |
| if respond_to? date_field | |
| time = self.send(date_field) |