I hereby claim:
- I am chrisfinne on github.
- I am chrisfinne (https://keybase.io/chrisfinne) on keybase.
- I have a public key ASCMyEvQ2uNEGLxSgPppGzfESWEIPG9DW1LvcNuyowZ-jQo
To claim this, I am signing this object:
yum install autoconf automake bzip2 bzip2-devel cmake freetype-devel gcc gcc-c++ git libtool make mercurial pkgconfig zlib-devel -y | |
cd /usr/src/ | |
mkdir ffmpeg_sources | |
# nasm | |
cd /usr/src/ffmpeg_sources | |
curl -O -L https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2 | |
tar xjvf nasm-2.14.02.tar.bz2 | |
cd nasm-2.14.02 | |
./autogen.sh |
I hereby claim:
To claim this, I am signing this object:
# AR .persisted? throws SystemStackError for an unsaved model with a | |
# custom primary_key that didn't save due to validation error | |
gem 'activerecord', '4.1.0.rc1' # in HEAD too | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
# Ensure backward compatibility with Minitest 4 | |
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) |
class String | |
def is_us_phone? | |
!!(self.gsub(/\D/,'') =~/\A1?\d{10}\z/) | |
end | |
def to_us_phone | |
return nil unless is_us_phone? | |
s = self.gsub /\D/,'' | |
s[0,1]=='1' ? s[0,11] : '1'+s[0,10] |
>> class Foo | |
>> | |
?> def self.bar | |
>> "i'm a class method" | |
>> end | |
>> | |
?> def bar | |
>> "i'm an instance method" | |
>> end | |
>> |
class TMail::Mail | |
def bad_html? | |
if multipart? | |
return true if parts.detect{|p| p.content_type.include?('text/plain') && p.to_s =~ /<(html|head)/im } | |
return true if parts.detect{|p| p.to_s =~ /<\/(p|a|span|div|style|head|html)>/im } | |
else | |
return true if body =~ /<\/(p|a|span|div|style|head|html)>/im | |
return true if content_type.include?('text/plain') && body =~ /<(html|head)/im | |
end | |
false |
class String | |
# http://en.wikipedia.org/wiki/North_American_Numbering_Plan | |
@@bad_phones = 0.upto(9).collect{|t| t.to_s*10} + ['231231234'] | |
def is_smsable? | |
return false unless self.is_phone? | |
return false if self.gsub(/[0123456789\-\.\+\(\) ]/,'').present? # non-phone number chars are present | |
return false if self =~ /\A\s*\+\s*[^1\s]/ # International number | |
us_ten = self.gsub(/\D/,'').gsub(/\A1/,'') | |
return false if us_ten.size != 10 |
class BigDecimal | |
class << self | |
def new_with_commas(*args) | |
if args.first.is_a?(String) && args.first=~/,/ | |
args.first.gsub!(',','') | |
end | |
new_without_commas(*args) | |
end | |
alias_method_chain :new, :commas | |
end |
class Foo < SimpleRecord::Base | |
has_dates :started_at | |
end | |
f1=Foo.create :started_at=>Time.now | |
sleep(1) | |
Foo.connection.get_attributes(Foo.table_name, f1.id)[:attributes]['started_at'][0] | |
=> "2010-04-14T22:24:56" | |
f2=Foo.create :started_at=>DateTime.now | |
sleep(1) |
def test_ascii_http_post | |
first_name = "joe" + ("X" * 1000) # pad the field to help get the URL over the 2000 length limit so AWS uses a POST | |
last_name = "blow" + ("X" * 1000) # pad the field to help get the URL over the 2000 length limit so AWS uses a POST | |
mm = MyModel.create :first_name=>first_name, :last_name=>last_name | |
mm.save | |
sleep 1 | |
assert mm.first_name == first_name | |
assert mm.last_name == last_name | |
mm2 = MyModel.find(mm.id) | |
assert mm2.first_name == first_name |