Skip to content

Instantly share code, notes, and snippets.

View snowch's full-sized avatar

Chris Snow snowch

View GitHub Profile
@snowch
snowch / index.sh
Last active August 29, 2015 14:08
cloudant query utility script
#!/bin/bash
set -e
USERNAME=snowch
DBNAME=stackoverflow
SCRIPT=$(basename $0)
if [[ ! $1 =~ (create)|(list)|(delete)|(find) ]]; then
@snowch
snowch / dixondates.R
Last active August 29, 2015 14:11 — forked from noamross/dixondates.R
#'% Using Dates and Times in R
#'% Bonnie Dixon
#'% 14-02-10 15:09:57
#'
#' *Today at the [Davis R Users'
#' Group](http://www.noamross.net/davis-r-users-group.html), [Bonnie
#' Dixon](http://ffhi.ucdavis.edu/people/directory/bmdixon) gave a tutorial on the
#' various ways to handle dates and times in R. Bonnie provided this great script
#' which walks through essential classes, functions, and packages. Here it is piped through
#' `knitr::spin`. The original R script can be found as a gist

Objective

Test that changing the database linked to the account is thread safe.

How to test by making parallel invocations of?

  • /vechicles
  • /customers

How can you be sure that a parallel invocation of /vehicles and /customers will actually run parallel? E.g. on different cores at exactly the same time?

@snowch
snowch / load_cloudant.py
Created May 12, 2015 21:48
Baltimore City Employee Salaries FY2014
#!/usr/bin/env python
import requests, json
CL_USERNAME = CHANGE_ME
CL_PASSWORD = CHANGE_ME
AUTH=(CL_USERNAME, CL_PASSWORD)
jsondata = requests.get('https://data.baltimorecity.gov/api/views/2j28-xzd7/rows.json?accessType=DOWNLOAD')
@snowch
snowch / main.py
Last active December 26, 2016 08:39
Cloudant Python connection pooling and cookie renewal (Gunicorn)
# WARNING: THIS CODE HAS NOT BEEN TESTED!
from apscheduler.scheduler import Scheduler
from requests.adapters import HTTPAdapter
import cloudant
import logging
import json
import os
# setup connection pooling - see http://stackoverflow.com/questions/29046503/cloudant-python-https-connection-pooling
@snowch
snowch / .xbindkeysrc
Last active August 29, 2015 14:23
Ubuntu MacBook
# ~/.xbindkeysrc
# CTL + ALT + Click = Right Click Menu
"sleep .04 && xdotool click 3"
Control+Alt + Alt_L + b:1 + Release
@snowch
snowch / lisp.c
Last active August 29, 2015 14:26 — forked from sanxiyn/lisp.c
Lisp
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
enum type {
NIL,
@snowch
snowch / Vagrantfile
Created September 27, 2015 12:47
Vagrant Openstack Provider
```
require 'vagrant-openstack-provider'
Vagrant.configure('2') do |config|
config.vm.box = 'openstack'
config.ssh.username = 'ibmcloud'
config.vm.provider :openstack do |os|
os.openstack_auth_url = 'https://keystone2.open.ibmcloud.com/v2.0/tokens'
@snowch
snowch / design_doc_replication_backup.py
Last active March 15, 2016 08:42
Replicate design docs for all databases in a Cloudant account
#!/usr/bin/env python
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
@snowch
snowch / DSUR datafiles
Last active July 17, 2016 15:50
DSUR scripts
dir.create('./DSUR/')
download.file('https://studysites.uk.sagepub.com/dsur/study/DSUR%20Data%20Files/Data%20files.zip', dest='DataFiles.zip')
unzip('DataFiles.zip', exdir='./DSUR/')
baseurl = 'https://studysites.uk.sagepub.com/dsur/study/DSUR%20R%20Script%20Files/'
scripts <- c(
'Chapter%203%20The%20R%20Environment.R',
'Chapter%204%20DSUR%20Graphs.R',
'Chapter%205%20DSUS%20Exploring%20Data.R',
'Chapter%206%20DSUR%20Correlations.R'