Deepak Kannan deepak

View rails engine Rakefile.rb
1 2 3 4 5 6 7 8 9 10
# Rakefile generated with
# rails plugin new foo --mountable
 
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
 
require 'rdoc/task'
View dependency_analysis.rb
1 2 3 4 5 6 7 8 9 10
require 'parser/current'
require 'pp'
require 'pry'
require 'graph'
 
module SexpLisper
def self.parse(path)
code = File.read(path)
 
source_buffer = Parser::Source::Buffer.new(path, 1)
View dumb_metric_treemap.rb
1 2 3 4 5 6 7 8 9 10
require 'parser/current'
require 'pp'
require 'rake'
require 'pry'
require 'treemap'
require 'treemap/image_output'
 
module SexpLisper
def self.parse(path)
code = File.read(path)
View dump_metric.rb
1 2 3 4 5 6 7 8 9 10
require 'parser/current'
require 'pp'
require 'rake'
require 'pry'
 
module SexpLisper
def self.parse(path)
code = File.read(path)
 
source_buffer = Parser::Source::Buffer.new(path, 1)
View dumb_metric_using_ruby_lint.rb
1 2 3 4 5 6 7 8 9 10
require 'pp'
require 'pry'
require 'parser/current'
require 'ruby-lint'
require 'rake'
 
# @!attribute [r] vm
# @return [RubyLint::VirtualMachine]
class Analysis < RubyLint::Iterator
attr_reader :vm
View pyg
1 2 3 4 5 6 7 8 9 10
#!/bin/bash
# /usr/local/bin/pygmentize -f rtf -O "style=friendly,fontface=Courier Bold" "$1" | pbcopy
# /usr/local/bin/pygmentize -l ruby -f rtf -P style=presentation -P fontface="Source Code Pro" "$1" | pbcopy
 
/usr/local/bin/pygmentize -l ruby -f rtf -O "style=friendly,fontface=Source Code Pro" "$1" |
# Set the font size to 36pt (that's the \fs72 - RTF font sizes work in doubles)
sed "s/\\\\f0/\\\\f0\\\\fs72/g" |
# And copy. Enjoy!
View find_parent_module.rb
1 2 3 4 5 6 7 8 9 10
# find the parent module of a class
# https://twitter.com/postmodern_mod3/status/410270060721082368
# using http://ruby-doc.org/core-2.0.0/Module.html#method-c-nesting
# or else by parsing the string representation of the class name
 
module Foo
module Bar
class MyClass
def self.nesting
Module.nesting
View time_range.rb
1 2 3 4 5
now = Time.now # => 2013-12-04 18:24:36 +0530
future = Time.now + 2.hours # => 2013-12-04 20:24:57 +0530
(now..future).member? now
# TypeError: can't iterate from Time
# from /usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/core_ext/range/each.rb:21:in `ensure_iteration_allowed'
View overcommit.yml
1 2 3 4 5 6 7 8 9 10
---
excludes:
commit_msg:
- change_id
- release_note
pre_commit:
- causes_email
- image_optimization
- restricted_paths
- test_history
View parsing_and_validating_dates.rb
1 2 3 4 5 6 7 8 9 10
def parse_date(date)
if date.is_a?(Integer)
parse_date_from_timestamp(date)
elsif date.is_a?(String)
if date.to_i.to_s == date
parse_date_from_timestamp(date.to_i)
else
parse_date_from_string(date)
end
elsif date.acts_like?(:date) || date.acts_like?(:time)
Something went wrong with that request. Please try again.