Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
@deepak
deepak / parsing_and_validating_dates.rb
Created November 14, 2013 13:06
parsing and validating dates in ruby. Have an icky feeling
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)
@deepak
deepak / gist:7366809
Created November 8, 2013 05:54
rubocop config
AllCops:
RunRailsCops: true
Excludes:
- 'db/schema.rb'
- 'vendor'
StringLiterals:
Enabled: false
LineLength:
Max: 100
module Boolean
end
class TrueClass
include Boolean
end
class FalseClass
include Boolean
end
@deepak
deepak / define_method_with_body_as_block.rb
Created July 25, 2013 07:13
define method with a block
def new_method name, &block
define_method(name) { block.call }
end
new_method :ping do
puts "pong"
end
ping
@deepak
deepak / gist:5933685
Created July 5, 2013 10:40
Set ENV in Dockerfile with string interpolation
# DOCKER-VERSION 0.4.8
FROM ubuntu:12.04
# install essentials
RUN apt-get install -y -q git
# Install rbenv
RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
RUN echo '# rbenv setup' > /etc/profile.d/rbenv.sh
@deepak
deepak / Dockerfile.badpath
Created July 5, 2013 10:11
PATH cannot be interpolated in ENV
# DOCKER-VERSION 0.4.8
FROM ubuntu:12.04
# install essentials
RUN apt-get install -y -q git
# Install rbenv
RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
RUN echo '# rbenv setup' > /etc/profile.d/rbenv.sh
@deepak
deepak / Dockerfile
Created July 5, 2013 06:59
Dockerfile to install ruby using brightbox deb
# DOCKER-VERSION 0.4.8
FROM ubuntu:12.04
MAINTAINER Deepak Kannan "[email protected]"
RUN apt-get -y install python-software-properties
RUN apt-add-repository -y ppa:brightbox/ruby-ng-experimental
RUN apt-get -y update
@deepak
deepak / Dockerfile
Last active December 8, 2024 08:48
Dockerfile for installing ruby using rbenv
# DOCKER-VERSION 0.4.8
# am facing issue
# https://github.com/dotcloud/docker/issues/1123
FROM ubuntu:12.04
MAINTAINER Deepak Kannan "[email protected]"
RUN apt-get -y install python-software-properties
@deepak
deepak / spawn_with_a_new_rbenv_version.rb
Created June 13, 2013 12:31
spawning a ruby process with a new RBENV_VERSION does not change ruby version
puts "default"
spawn({}, 'ruby --version')
sleep 2
puts "ruby2"
spawn({"RBENV_VERSION" => "2.0.0-p195"}, 'rbenv rehash; ruby --version') #~> still shown as 1.9 not 2.0
@deepak
deepak / trying out Apple Diction.txt
Created May 29, 2013 18:23
trying out Apple Diction
trying out Apple Diction. the first one was supposed to be a ruby function
none of them are even close. lolwutz all around :-)
- Hey I am making the record no he's done
- Their food and IE easy-going okay
- My name is Leslie
- This diction basics pleasing to let the Buddha
- By all of the sauce again