Skip to content

Instantly share code, notes, and snippets.

View baobaofzhang's full-sized avatar

Baobao Zhang baobaofzhang

  • Cornell University
  • Ithaca, NY
View GitHub Profile
@baobaofzhang
baobaofzhang / javascript_set_up.js
Created April 30, 2020 00:24
Accordion Feature in Qualtrics
Qualtrics.SurveyEngine.addOnload(function()
{
jQuery( function() {
jQuery( "#accordion" ).accordion({
active:false,
collapsible: true
});
} );
});
@baobaofzhang
baobaofzhang / hide_slider_qualtrics.js
Created May 22, 2020 04:59
JaveScript to hide slider for Qualtrics surveys
// Put this on the addOnload function of the Javascript for the question with the slider.
// From user @DRRTGCC https://www.qualtrics.com/community/discussion/932/no-default-on-graphic-sliders-sliders-in-general
var s = jQuery("#"+this.questionId);
var firstclick=0;
s.find(".handle").hide();
s.find(".track").on("mouseover", function() {
s.find(".handle").show();
if (firstclick==0) {
@baobaofzhang
baobaofzhang / r_artprint_city_map.R
Created November 3, 2020 06:09
A function to make city map art prints
# Function to build your own city art print map
# Original code by Josh McCrain http://joshuamccrain.com/tutorials/maps/streets_tutorial.html
# Updates by Baobao Zhang
# 3 November 2020
# Load packages
library(sf)
library(tidyverse)
library(osmdata)
library(showtext)
@baobaofzhang
baobaofzhang / power_analysis_randomize_items.R
Last active February 17, 2021 04:36
Power analysis for survey instruments where the respondents get n out of N items
# Power analysis: global public opinion survey
library(fabricatr)
library(estimatr)
library(dplyr)
library(pbapply)
library(parallel)
library(pbmcapply)
# Set seed
set.seed(3492)