This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import pygame | |
from pygame.locals import * | |
class GameGrid: | |
def __init__(self, grid_size=(100, 100), window_size=(400, 400)): | |
self.grid_size = grid_size | |
self.square_x_size = window_size[0] / grid_size[0] | |
self.square_y_size = window_size[1] / grid_size[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((* extends 'article.tplx' *)) | |
((* block docclass *)) | |
\documentclass[a4paper,11pt]{article} | |
((* endblock docclass *)) | |
((* block commands *)) | |
% Prevent overflowing lines due to hard-to-break entities | |
\sloppy | |
% Setup hyperref package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
import random | |
import pprint | |
def assign_blocks(total_n, block_sizes): | |
block_size_list = [] | |
current_n = 0 | |
while current_n < total_n: | |
max_size = total_n - current_n | |
possible_sizes = [s for s in block_sizes if s <= max_size] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program assign_blocks | |
version 13.1 | |
syntax [varlist], totaln(integer) blocksize(integer) | |
drop _all | |
set obs `totaln' | |
generate treatment_assigned = 1 | |
generate dice_roll = runiform() | |
generate block = 1 | |
local half_block = `blocksize' / 2 | |
local n_blocks = `totaln' / `blocksize' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
ambiguous_letters = ['I', 'O'] | |
letter_targets = [letter for letter in string.ascii_uppercase | |
if letter not in ambiguous_letters] | |
ambiguous_numbers = ['0', '1'] | |
number_targets = [digit for digit in string.digits | |
if digit not in ambiguous_numbers] | |
print(number_targets) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# Convert all markdown files in the current folder to PDF using pandoc | |
import os | |
import subprocess | |
import time | |
MARKDOWN_EXTS = ('.markdown', '.md') | |
# Using abspath means I don't have to manually specify the folder name | |
ROOT_FOLDER = os.path.split(os.path.abspath(__file__))[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(lattice) | |
hrt <- function(x, y) { | |
x^2 + (y-(x^2)^(1/3))^2 | |
} | |
hrt_mat <- matrix(10000, nrow=100, ncol=100) | |
x_vals <- seq(-1, 1, length.out=100) | |
y_vals <- seq(-1, 1.5, length.out=100) | |
for (x in seq(1:nrow(hrt_mat))) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
from pygame.locals import * | |
import random | |
KEYS_1 = {K_w:'up', K_s: 'down'} | |
KEYS_2 = {'up arrow': 'up', 'down arrow': 'down'} | |
KEY_DICT = {1: KEYS_1, 2: KEYS_2} | |
WHITE = (255, 255, 255) | |
class Player: |