Skip to content

Instantly share code, notes, and snippets.

var testConfig = {
timeout: 3000,
freq: 250
};
function doTryCatch(f){try {return f();} catch(e){error(e);}}
function error(msg){console.error("phantomjs-joounit> "+ msg);phantom.exit(1);}
doTryCatch(
function (){
for(var i = 0; i < phantom.args.length ; i++){
var arg = phantom.args[i];
@wjordan
wjordan / install-blockly.sh
Last active July 10, 2021 15:10
installs blockly onto ubuntu server
cat <<END_ROOT_SCRIPT | sudo /bin/bash -s
set -e # exit if any command exits with nonzero
export DEBIAN_FRONTEND=noninteractive
# run as root
apt-get update
apt-get install -y software-properties-common
apt-add-repository -y ppa:chris-lea/node.js
apt-get update
apt-get install -y git nodejs libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
@wjordan
wjordan / ruby2.0.sh
Created May 15, 2014 22:20
ruby2.0 in 14.04
#!/bin/sh
# Run as root
rm /usr/bin/ruby /usr/bin/gem /usr/bin/irb /usr/bin/rdoc /usr/bin/erb
ln -s /usr/bin/ruby2.0 /usr/bin/ruby
ln -s /usr/bin/gem2.0 /usr/bin/gem
ln -s /usr/bin/irb2.0 /usr/bin/irb
ln -s /usr/bin/rdoc2.0 /usr/bin/rdoc
ln -s /usr/bin/erb2.0 /usr/bin/erb
gem update --system
gem pristine --all
@wjordan
wjordan / map_responses.rb
Created May 20, 2014 22:34
ORA response extraction
#!/usr/bin/env ruby
# This script is being used to parse the JSON data dump from a self-hosted edX server,
# transforming the relevant data into a spreadsheet listing all open-ended responses
# submitted through the system.
require 'set'
require 'json'
require 'nokogiri'
require 'csv'
@wjordan
wjordan / Vagrantfile
Created October 15, 2014 16:58
code-dot-org vagrant setup
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.60.10"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
@wjordan
wjordan / gist:3850033938fab8986fae
Last active August 29, 2015 14:07
Queries on age and has_teacher
# count average number of puzzles completed
def trophies(age, has_teacher, start_date = "2012-01-01", end_date = "2015-01-01")
age = "TIMESTAMPDIFF(YEAR, users.birthday, CURRENT_DATE) = #{age}"
has_teacher = "#{has_teacher ? 'IN' : 'NOT IN'} (SELECT DISTINCT(student_user_id) FROM followers)"
UserLevel.joins(:user).where("user_levels.best_result >= 20 AND users.id #{has_teacher} AND #{age} AND users.created_at > '#{start_date}' AND users.created_at < '#{end_date}'").count.to_f / User.where("id #{has_teacher} AND #{age} AND created_at > '#{start_date}' AND created_at < '#{end_date}'").count
end
[true, false].map{|has_teacher| (4..21).map{|age| trophies(age, has_teacher)}}
[true, false].map{|has_teacher| (4..21).map{|age| trophies(age, has_teacher, "2014-09-01")}}
@wjordan
wjordan / sample.md
Last active August 29, 2015 14:16
sample .md

TL;DR!

Announcing the Hour of Code and new partners

On Monday, October 14, 2013, Code.org announced the "Hour of Code," a campaign to introduce 10 million students to one hour of Computer Science.

Live stream of the announcement

<iframe width="560" height="315" src="//www.youtube.com/embed/ruJeDKDbr9k" frameborder="0" allowfullscreen></iframe>
@wjordan
wjordan / gist:d77c47f2a272d7c9dbf6
Last active June 25, 2019 14:50
cdo-install.sh
#!/bin/bash
# Docker-ubuntu-trusty compatible CDO install script
export DEBIAN_FRONTEND=noninteractive
apt() {
apt-get -qq install $1 &>/dev/null
}
apt-get update &>/dev/null && apt-get -y upgrade &>/dev/null
@wjordan
wjordan / pound.cfg
Created June 8, 2015 23:34
Pound HTTPS proxy configuration file
## pound configuration for proxying HTTPS to local HTTP development server
# Place in /etc/pound/pound.cfg
# Remember to set startup=1 in /etc/default/pound
User "www-data"
Group "www-data"
LogLevel 1
Daemon 1
@wjordan
wjordan / dockerize.sh
Last active June 22, 2020 15:47
Dockerize: A tiny replacement for Dockerfiles
#!/bin/sh
####
# Dockerize: A tiny replacement for Dockerfiles
# This script leverages `docker run` and `docker commit` to provide a usable workaround for
# restrictions of `docker build` and Dockerfile syntax to strictly host-independent builds.
#
# See these discussions:
# https://github.com/docker/docker/pull/1124
# https://github.com/docker/docker/issues/3156
# https://github.com/docker/docker/issues/3949