Dan Mayer danmayer

View gist:4083050
1 2 3 4 5 6 7 8 9 10
So agree with @davetron5000 that defects to users are the most important to prevent.
I also agree that a test failure doesn't mean a defect occurred as tests themselves
often just are bad tests that don't test what they should. While you do have to maintain
and think about a test suite, well written tests should be entirely isolated.
The app code you do need to reason about the changes of the code effect other pieces of
the application. So while a buggy tests might be a bit flaky, if it just passes and I am
not specifically working with that test it isn't increasing my thought load while reasoning
about the code structure.
 
I still think people should maintain and keep clean tests, and unless you are doing payments,
View ruby_number_examples
1 2 3 4 5 6 7 8 9 10
>> Integer('1001')
=> 1001
>> Integer('1001a')
ArgumentError: invalid value for Integer: "1001a"
from (irb):26:in `Integer'
from (irb):26
#note this is very odd, so is '10a100'.to_i
>> '1001a'.to_i
=> 1001
>> Float('1001.0')
View wumpus.java
1 2 3 4 5 6 7 8 9 10
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
 
public class Room {
View I18n_bad_test.rb
1 2 3 4 5 6 7 8 9 10
require File.dirname(__FILE__) + '/../test_helper'
 
class FakeTest < ActiveSupport::TestCase
 
test "first de" do
puts "about to be de: #{I18n.locale}"
assert_equal 'en', "#{I18n.locale}"
I18n.locale = 'de'
assert true
end
View remove_code.rb
1 2 3 4 5 6 7 8 9 10
Dir.glob("./mayerdan.com/**/*.php") do |local_filename|
unless local_filename.to_s.match(/ayerdan\.com\/pics/) ||
local_filename.to_s.match(/wastedbrains\.com\/art\/index\.php/) ||
local_filename.to_s.match(/simplepie\/demo/) ||
local_filename.to_s.match(/proj\/picts\/slideshow\.php/) ||
local_filename.to_s.match(/prog\/bencode\/slideshow\.php/) ||
local_filename.to_s.match(/proj\/phpquiz/) ||
local_filename.to_s.match(/picts\/linpha-1\.0beta3\/adodb/)
doc = File.read(local_filename)
View gist:1491781
1 2 3 4 5 6 7 8 9 10
rm -f mayerdan.com/.htaccess
rm -f mayerdan.com/MT/.htaccess
rm -f melonandorange.com/.htaccess
rm -f melonandorange.com/dom/.htaccess
rm -f melonandorange.com/nicole/.htaccess
rm -f MYMOVETOLA.COM/.htaccess
rm -f scoreher.com/.htaccess
rm -f wastedbrains.com/.htaccess
rm -f .htaccess
rm -rf backup/mayerdan.com/tmp_1637643485416709.php
View init_gemset.rb
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/env ruby
 
# example usage: init_gemset mygemset
# to use this setup an alias in your .bash_profile
#
# #setup new gemset
# function initgemset()
# {
# local myresult=`ruby /Users/danmayer/projects/script_helpers/init_gemset.rb $#1`
# eval "$myresult"
View AR_bug.rb
1 2 3 4 5 6 7 8 9
# this is rails 2.3.x so perhaps it has been fixed but any on a empty AR association object that has [] returns true.
# after being inspected or to_s it returns false (as it should
 
# rails console
[].any? => false
none = ar_object.association_objects (like Person.find(2).posts where there are no posts) => []
none.any? => false
none.ancestors.map(&:to_s).sort == (from Rails.development.log none.ancestors.map(&:to_s).sort ) => true
(just to make sure all the same things are loaded -> "ActiveRecord::AssociationPreload", "ActiveRecord::Associations", "ActiveRecord::AttributeMethods"... and many more)
View ruby_closure_compiler_helper.rb
1 2 3 4 5 6 7 8 9 10
require 'net/http'
require 'uri'
 
COMPRESS_LEVEL = "SIMPLE_OPTIMIZATIONS"
FILE_PATH = "assets/www/"
FILES = ['application','custom','plugin','base']
 
def compress(compilation_level,jscode)
response = Net::HTTP.post_form(URI.parse('http://closure-compiler.appspot.com/compile'), {
'js_code' => jscode,
View redis_connect_example
1 2 3 4
#connect resque web to different redis server
`resque-web ./resque-conn.rb`
#cat ./resque-conn.rb =>
Resque.redis = Redis.new(:host => “127.0.0.1”, :port => 6379, :db => 1)
Something went wrong with that request. Please try again.