Skip to content

Instantly share code, notes, and snippets.

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

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

@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
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 / 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
@creeefs
creeefs / nginx.conf
Last active March 6, 2018 04:28
/usr/local/etc/nginx/nginx.conf
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8888;
location / {
#! /bin/bash
# Initially, I was trying to have my filter function return both the flag and the flag's values.
# As you can see below, my value substring contained spaces, which led to the following two outcomes:
# 1) If the command is not quoted, the shell parses the output and splits the string into 4 words
# 2) If the command is quoted, word splitting is avoided and you get 1 word
# In both cases, the ffmpeg utility would fail since it's not passed valid options.
filter_flag_and_value() {
echo "-filter_complex first second third"
}
# Configuration checksum: 14132506172776696809
# setup custom paths that do not require root access
pid /tmp/nginx.pid;
load_module /etc/nginx/modules/ngx_http_modsecurity_module.so;
daemon off;
worker_processes 1;
$ ninja -C build/
......................
[268/3400] Compiling C object 'subprojects/gst-examples/playback/player/gtk/1bbe5de@@gtk-play@exe/gtk-play.c.o'.
FAILED: subprojects/gst-examples/playback/player/gtk/1bbe5de@@gtk-play@exe/gtk-play.c.o
cc -Isubprojects/gst-examples/playback/player/gtk/1bbe5de@@gtk-play@exe -Isubprojects/gst-examples/playback/player/gtk -I../subprojects/gst-examples/playback/player/gtk -Isubprojects/gstreamer -I../subprojects/gstreamer -Isubprojects/gst-plugins-base/gst-libs -I../subprojects/gst-plugins-base/gst-libs -Isubprojects/gstreamer/libs -I../subprojects/gstreamer/libs -Isubprojects/gst-plugins-bad/gst-libs -I../subprojects/gst-plugins-bad/gst-libs -Isubprojects/orc -I../subprojects/orc -Isubprojects/gstreamer/gst -Isubprojects/gst-plugins-base/gst-libs/gst/tag -Isubprojects/gst-plugins-base/gst-libs/gst/video -Isubprojects/gst-plugins-base/gst-libs/gst/audio -Isubprojects/gst-plugins-base/gst-libs/gst/pbutils -I/usr/local/Cellar/glib/2.
@creeefs
creeefs / Dockerfile
Created October 7, 2020 14:09
Gstreamer wpesrc Dockerfile
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
bison \
flex \
git \
libmount-dev \
pkg-config \