Skip to content

Instantly share code, notes, and snippets.

@creeefs
creeefs / rxutil.scala
Last active April 19, 2017 22:02
Testing toFutureOpt method in RxUtil
package mlbam.betljus.core.util
import mlbam.betljus.core.util.RxUtil._
import org.scalatest.FlatSpec
import org.scalatest.concurrent.ScalaFutures._
import rx.Observable
class RxUtilTest extends FlatSpec {
"toFutureOpt" should "return an error if the observable fails" in {
val f = Observable
2016-01-05 19:04:23,356 [http-bio-8080-exec-1] INFO core.FeedProxyService:291 () - http://www.nhl.com/feed/nhl/league/expandedclubroster.json?teamId=53&auth=MLBAM_Core|1452038663353|cd66f2918378da06146afd70fec272831c95d467
2016-01-05 19:04:23,484 [http-bio-8080-exec-2] INFO log.CommonsJdbcEventLogger:169 () - Opening connection: jdbc:mysql://bdata-nhl-mysql-stats-prod.cgekh9dh1peg.us-east-1.rds.amazonaws.com/nhldb
Login: ***
Password: ***
2016-01-05 19:04:23,540 [http-bio-8080-exec-1] INFO core.FeedProxyService:306 () - http://www.nhl.com/feed/nhl/league/expandedclubroster.json?teamId=53&auth=MLBAM_Core|1452038663353|cd66f2918378da06146afd70fec272831c95d467 : 187
2016-01-05 19:04:24,057 [http-bio-8080-exec-2] INFO log.CommonsJdbcEventLogger:205 () - +++ Connecting: SUCCESS.
2016-01-05 19:04:24,106 [http-bio-8080-exec-2] INFO log.CommonsJdbcEventLogger:148 () - Detected and installed adapter: org.apache.cayenne.dba.mysql.MySQLAdapter
2016-01-05 19:04:24,107 [http-bio-8080-exec-2] INFO log
@creeefs
creeefs / ar_sql.rb
Last active August 29, 2015 14:15
Does ActiveRecord have an API to typecast AR attributes? To provide some background, I'm prepping for a zero downtime deploy, so I need to migrate existing production data to the new domain model without having the create_association method available.
ActiveRecord::Base.connection_pool.with_connection do |conn|
conn.execute("INSERT INTO `comments` (`post_id`, `created_at`, \
`id`, `updated_at`) VALUES (x'535cc052b670416c8a8f90a6a2deb611', '2015-02-19 23:02:50', \
x'67b5c8191e4146708437d6c69cdb08d0', '2015-02-19 23:02:50')")
end

Hamming

Write a program that can calculate the Hamming difference between two DNA strands.

A mutation is simply a mistake that occurs during the creation or copying of a nucleic acid, in particular DNA. Because nucleic acids are vital to cellular functions, mutations tend to cause a ripple effect throughout the cell. Although mutations are technically mistakes, a very rare mutation may equip the cell with a beneficial attribute. In fact, the macro effects of evolution are attributable by the accumulated

require 'minitest/autorun'
require_relative 'hamming'
class HammingTest < MiniTest::Unit::TestCase
def test_no_difference_between_identical_strands
assert_equal 0, Hamming.compute('A', 'A')
end
def test_complete_hamming_distance_of_for_single_nucleotide_strand
skip