Skip to content

Instantly share code, notes, and snippets.

@leeper
leeper / read.qualtrics.csv.R
Created April 13, 2015 10:54
Function read data from a Qualtrics-generated CSV file
read.qualtrics.csv <- function(filename, stringsAsFactors = FALSE, ...) {
n <- read.csv(filename, nrows = 1, stringsAsFactors = FALSE)
dat <- read.csv(filename, header = FALSE, skip = 2, stringsAsFactors = stringsAsFactors, ...)
names(dat) <- names(n)
names(dat)[1:10] <- n[1,1:10]
for(i in seq_along(dat)) {
attr(dat[,i], "question") <- n[1,i]
}
dat
}
@longwave
longwave / optimize-pngs.sh
Created March 11, 2014 10:14
Optimize PNG files in place, with pngcrush and optipng
#!/bin/sh
for i in `find . -name "*.png"`; do
pngcrush -e .png2 -rem allb -brute -reduce $i
mv ${i}2 $i
optipng -o7 $i
done
@mkropat
mkropat / knownpaths.py
Last active April 19, 2024 00:07
Python wrapper around the SHGetKnownFolderPath Windows Shell function
import ctypes, sys
from ctypes import windll, wintypes
from uuid import UUID
class GUID(ctypes.Structure): # [1]
_fields_ = [
("Data1", wintypes.DWORD),
("Data2", wintypes.WORD),
("Data3", wintypes.WORD),
("Data4", wintypes.BYTE * 8)