Skip to content

Instantly share code, notes, and snippets.

View alexfaber2011's full-sized avatar

Alex Faber alexfaber2011

View GitHub Profile
@alexfaber2011
alexfaber2011 / sequence-inverter.clj
Created September 9, 2015 03:05
Inverts DNA sequences in the form of strings
(ns sequence-inverter.core
(:gen-class))
(defn invert-char
[char]
(let [char-map {"A" "C"
"C" "A"
"G" "T"
"T" "G"}]
(get char-map char)))
@alexfaber2011
alexfaber2011 / gist:248d733ab9bebc92a7f3
Last active October 16, 2015 16:51
-- : negative infinity
C G A T A C G T T
M: 0 Ix: 0 Iy: -2 ______ | M: -- Ix: -- Iy: -3 ______ | M: -- Ix: -- Iy: -4 ______ | M: -- Ix: -- Iy: -5 ______ | M: -- Ix: -- Iy: -6 ______ | M: -- Ix: -- Iy: -7 ______ | M: -- Ix: -- Iy: -8 ______ | M: -- Ix: -- Iy: -9 ______ | M: -- Ix: -- Iy: -10 ______ | M: -- Ix: -- Iy: -11 ______ |
A ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
M: -- Ix: 0 Iy: -- ______ | M: -1 Ix: -- Iy: -- :M____ | M: -4 Ix
M: 0 Ix: 0 Iy: -2 ______ | M: -- Ix: -- Iy: -3 ______ | M: -- Ix: -- Iy: -4 ______ | M: -- Ix: -- Iy: -5 ______ | M: -- Ix: -- Iy: -6 ______ | M: -- Ix: -- Iy: -7 ______ | M: -- Ix: -- Iy: -8 ______ | M: -- Ix: -- Iy: -9 ______ | M: -- Ix: -- Iy: -10 ______ | M: -- Ix: -- Iy: -11 ______ |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
M: -- Ix: 0 Iy: -- ______ | M: -1 Ix: -- Iy: -- :M____ | M: -2 Ix: -- Iy: -4 :y__:M | M: -5 Ix: -- Iy: -5 :y__:y | M: -4 Ix: -- Iy: -6 :y__:y | M: -7 Ix: -- Iy: -7 :y__:y | M: -8 Ix: -- Iy: -8 :y__:y | M: -9 Ix: -- Iy: -9 :y__:y | M: -8 Ix: -- Iy: -10 :y__:y | M: -9 Ix: -- Iy: -11 :y__:y |
---------------------------------------------------
C G A T A C G T T
M: 0 Ix: 0 Iy: -2 ______ | M: -- Ix: -- Iy: -3 ______ | M: -- Ix: -- Iy: -4 ______ | M: -- Ix: -- Iy: -5 ______ | M: -- Ix: -- Iy: -6 ______ | M: -- Ix: -- Iy: -7 ______ | M: -- Ix: -- Iy: -8 ______ | M: -- Ix: -- Iy: -9 ______ | M: -- Ix: -- Iy: -10 ______ | M: -- Ix: -- Iy: -11 ______ |
A ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
M: -- Ix: 0 Iy: -- ______ | M: -- Ix: -- Iy: -- ______ | M: -- Ix
@alexfaber2011
alexfaber2011 / complete
Created October 16, 2015 19:27
final_matrix
C G A T A C G T T
M: 0 Ix: 0 Iy: -2 ______ | M: -- Ix: -- Iy: -3 ______ | M: -- Ix: -- Iy: -4 ______ | M: -- Ix: -- Iy: -5 ______ | M: -- Ix: -- Iy: -6 ______ | M: -- Ix: -- Iy: -7 ______ | M: -- Ix: -- Iy: -8 ______ | M: -- Ix: -- Iy: -9 ______ | M: -- Ix: -- Iy: -10 ______ | M: -- Ix: -- Iy: -11 ______ |
A ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
M: -- Ix: 0 Iy: -- ______ | M: -1 Ix: -- Iy: -- :M____ | M: -4 Ix
@alexfaber2011
alexfaber2011 / handler.cljs
Created January 13, 2016 13:46
Testing Re-Frame Handlers that Dispatch Other Handlers
; I have a question about how to test handlers that dispatch other handlers (say when fetching from a server).
; Here's what the wiki says about fetching from servers
(ns my.app.handlers
(:require [ajax.core :refer [GET POST]]
[re-frame.core :refer [register-handler]))
(register-handler
:request-it
(fn
@alexfaber2011
alexfaber2011 / with-redefs-and-go.cljs
Created January 13, 2016 20:17
Using `with-redefs` to redef a function that's called inside a go block
; ---------------------------------------------------------------------------------
; handler code
; ---------------------------------------------------------------------------------
; My handler code fetches messages in parrallel and then picks them off of the channel
; vector within the go block. I've succesfully redef'ed `http/get` by bringing it out
; of the `go` block, but redef'ing 're-frame/dispatch` doesn't seem to be working.
(defn fetch-full-messages [db [scenario-name]]
(if-let [scenario (get-in db [:admin-configuration :scenarios scenario-name])]
FROM node:4.4.2
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Set its environment to development
ENV NODE_ENV development
EXPOSE 3000
const mapStateToProps = (state: State, ownProps: Object) => {
const scenario = _.find(state.scenarios.value, (scenario: Scenario) => scenario.id === ownProps.params.scenarioId)
// state looks something like this
/**
* {
* results: {
* value: {
* 'fooScenarioId': {
* 'fooActionId: {
* foo: 'bar',
//@flow
import { TOGGLE_RESULT_ERROR_DISPLAY, } from '../actions/actionTypes'
const _ = require('lodash')
export const toggleResultErrorDisplay = (results: ScenarioActionResults = {}, action: ToggleResultErrorDisplayType): ScenarioActionResults => {
const result = _.get(results, [action.scenarioId, action.actionId])
if(!result){
return results
}
const scenarioResults = _.get(results, action.scenarioId)