Skip to content

Instantly share code, notes, and snippets.

View etosch's full-sized avatar

Emma "Frank" Tosch etosch

View GitHub Profile
Require Import List.
Require Import EqNat.
Definition alist := list (nat * bool).
Fixpoint in_assignment n (a : alist) : Prop :=
match a with
| nil => False
| (h,_)::t => if beq_nat n h
then True
@etosch
etosch / paths.clj
Last active August 29, 2015 14:01
Find paths through the survey
(defn get-dag
[blockList]
"Takes in a list of Blocks; returns a list of lists of Blocks."
(if (empty? blockList)
'(())
(let [^Block this-block (first blockList)]
(if-let [branchMap (and (.branchQ this-block) (.branchMap (.branchQ this-block)))]
(let [dests (set (vals branchMap))
blists (map (fn [^Block b] (drop-while #(not= % b) blockList)) (seq dests))]
(map #(flatten (cons this-block %)) (map get-dag blists))
function depth
input : A survey block
output : integer indicating depth
begin
idArray <- block id as an array
return length(idArray)
end
@etosch
etosch / turn_off_breakoff_notice.js
Created February 28, 2014 01:26
The `showBreakoffNotice` function displays a notice to the respondent stating that they are allowed to submit results early and will be compensated more for more work and better results. If the user wishes to remove this feature, the following can be added to `custom.js.` Changes to the breakoff notice can be added directly to this function.
sm.showBreakoffNotice = function () {
sm.showFirstQuestion();
};
sm.showBreakoffNotice();
@etosch
etosch / move_early_submit.css
Created February 27, 2014 18:38
The default setting is to display the "Submit Early" button in the same location as the final "Submit" button. This position is very close to the "Next" button and could lead to accidental submission.
.breakoff {
white-space : nowrap;
display : block;
position : relative;
top : 10px;
left : 20px;
}
@etosch
etosch / time_per_question.js
Last active August 29, 2015 13:56
To find the time spent per question, we need to track the time between firings of showQuestion and registerAndShowNextQuestion.
var oldShowQuestion = sm.showQuestion;
var oldRegisterAndShowNextQuestion = sm.registerAndShowNextQuestion;
var addTimingInfo = function(q, tag) {
var start = document.createElement('input');
start.type='text';
start.id=tag+'_'+q.id;
start.name=tag+'_'+q.id;
start.form='mturk_form';
start.hidden=true;
start.defaultValue=new Date().getTime();
.answer {
white-space : nowrap;
display : block;
}
label {
display : block;
padding : 2px 1em 0 0;
white-space : nowrap;
}
@etosch
etosch / gist:6076049
Created July 25, 2013 01:05
binary number stuff
(* Exercise: 4 stars, recommended (binary)
Consider a different, more efficient representation of natural numbers using a binary
rather than unary system. That is, instead of saying that each natural number is either
zero or the successor of a natural number, we can say that each binary number is either
zero,
twice
@etosch
etosch / app_ass4
Created July 12, 2013 21:20
From the list chapter in the Coq book.
(* There is a short solution to the next exercise.
If you find yourself getting tangled up, step back and try to look for a simpler way. *)
Theorem app_ass4 : forall l1 l2 l3 l4 : natlist,
l1 ++ (l2 ++ (l3 ++ l4)) = ((l1 ++ l2) ++ l3) ++ l4.
Proof.
intros l1 l2 l3 l4.
Theorem app_right : forall l1 l2 l3 : natlist,
l1 ++ (l2 ++ l3) = (l1 ++ l2) ++ l3.
Proof.