Skip to content

Instantly share code, notes, and snippets.

View susanBuck's full-sized avatar

Susan Buck susanBuck

View GitHub Profile
@susanBuck
susanBuck / codechat2.R
Last active December 2, 2025 17:07
Code Chat 2 code
###############################################
## PSY 1903 – Code Chat 2
## Please complete each step by writing R code
## directly below the corresponding comment.
###############################################
## 1. Import the data ----------------------------------------------------------
## Read in the CSV file located at data/raw/participant001.csv
@susanBuck
susanBuck / stroop_trials.csv
Last active November 21, 2025 14:19
Example Stroop Task Data Set (Trials)
participant_id trial condition word color response reaction_time
1 1 congruent red red b 933.6277622971892
1 2 congruent red red y 734.4963197335094
1 3 incongruent blue red g 896.9710286450861
1 4 incongruent blue red b 779.4735569583567
1 5 congruent green green r 960.397883633962
1 6 congruent blue blue g 800.0482608940355
1 7 incongruent blue green y 926.678871244671
1 8 congruent red red b 875.5292567603713
1 9 congruent green green b 978.6542694462784
Perfect — you want to create a symbolic link inside your web directory that points to the real week10_taskset folder in the project root.
Since you’re currently in /Users/Susan/Desktop/psy1903, you can run this:
ln -s ../week10_taskset web/week10_taskset
Wait — that’s if you’re inside web/. But since you said you’re in the project root (psy1903), the correct command from there is:
ln -s ../week10_taskset web/week10_taskset
@susanBuck
susanBuck / iframe-qualtrics.md
Created October 14, 2025 19:53
Embed jsPsych experiment in Qualtrics via iframe

Embed your jsPsych experiment in a Qualtrics survey

Using a HTML iframe element, you can embed your jsPsych experiment directly in a question within your Qualtrics survey - E.g.:

<iframe 
    src='https://susanbuck.github.io/psy1903/projects/lexical-decision/?qualtricsId=${e://Field/ResponseID}' 
    id='experimentEmbed'>
</iframe>
@susanBuck
susanBuck / a.js
Created October 13, 2025 16:50
Code Chat 1
// Welcome
let welcomeTrial = {
type: jsPsychHtmlKeyboardResponse,
stimulus: `
<h1 class='welcomeHeader'>Welcome!</h1>
<p>In this experiment, you will be shown a series of words.</p>
<p>Press the letter <span class='key'>F</span> if the word is positive.</p>
<p>Press the letter <span class='key'>J</span> if the word is negative.</p>
<p>Press <span class='key'>SPACE</span> to begin.</p>
`,
@susanBuck
susanBuck / index.html
Last active October 7, 2025 21:50
PSY1903 file updates
<!doctype html>
<html lang='en'>
<head>
<title>PSY1903</title>
<link href=data:, rel=icon>
</head>
<body>
<h1>My PSY1903 Web Server</h1>
@susanBuck
susanBuck / example.js
Created September 26, 2025 15:24
variable scope example
// For the purposes of this demo, hard-code answer and response
let answer = 4;
let response = 'e';
// THE FOLLOWING WILL *NOT* WORK
for (let i = 0; i < 3; i++) {
if (answer % 2 == 0 && response == 'e') {
let correct = true;
@susanBuck
susanBuck / consent.txt
Last active October 28, 2025 20:02
Experiment Consent Screen
@susanBuck
susanBuck / app.js
Created September 16, 2025 18:10
Week 3 Task Set Tips
// Select the elements on the page we will alter
let num1Span = document.getElementById('num1');
let num2Span = document.getElementById('num2');
// Example numbers
let num1 = 5;
let num2 = 9;
// Update the elements on the page with the example numbers
num1Span.innerHTML = num1;
@susanBuck
susanBuck / example.js
Created September 9, 2025 16:38
Note on capturing responses with the prompt method and reusing variables
// Don’t redeclare the same variable:
let answer = prompt('What is 1 + 1?');
console.log('You answered: ' + answer);
let answer = prompt('What is 4 + 8?');
console.log('You answered: ' + answer);
// Instead do this: