Skip to content

Instantly share code, notes, and snippets.

import csv
filename = '/full/path/tofile/'
with open(filename, 'rb') as csvfile:
reader = csv.reader(csvfile, delimiter=' ', quotechar='|')
result = [row for row in reader if 'N/A' in reader]
print result
import itertools as it
import random
def cards(n, t):
nt = n*t
images = range(nt)
return [[j for j in images[i:i + t]] for i in range(0, n*t, t)]
def edges(cards, link_count):
ct = min(len(cards), link_count) # we can't have more edges than cards for prop4
(ns interactive)
(defn my-fancy-function
[x y z]
(* x y z))
(comment
(= 1 (my-fancy-function 1 1 1)) ; eval here, move to a test ns when you're done and want a regression suite
)
@munk
munk / client.clj
Created February 14, 2016 22:45
Understanding Protocols
; HTTP Client for OpenHDS-REST
(ns ohds.client
(:require [clojure.edn :as edn]
[clojure.tools.logging :as log]
[org.httpkit.client :as http]
[clojure.data.json :as json]
[schema.core :as s])
(:import (java.time LocalDateTime)))
@munk
munk / framework.cljs
Created December 6, 2015 00:13
Testing with core.async and reagent
(ns framework
(:require [reagent.core :as reagent]))
(def isClient (not (nil? (try (.-document js/window)
(catch js/Object e nil)))))
(def rflush reagent/flush)
(defn add-test-div [name]
(let [doc js/document
body (.-body js/document)
#!/bin/bash
function hacstest {
name=$1
result=$2
expected=$3
if [ $result = $expected ]
then
echo -n "."
else
#!/bin/bash
set -eu
shopt -s nullglob
readonly base_dir=/var/lib/docker/registry
readonly output_dir=$(mktemp -d -t trace-images-XXXX)
readonly jq=/usr/bin/jq
readonly repository_dir=$base_dir/repositories
# Python 3.4
import requests
import bs4
def get_stock_price(name):
url = "https://www.google.com/finance"
data = requests.get(url, params={'q': name})
bs = bs4.BeautifulSoup(data.text)
div_price = bs.find(attrs={"id": "price-panel"})
import json
import httplib
import pymongo
from time import sleep
url = 'http://citibikenyc.com/stations/json'
connection = pymongo.Connection()
db = connection['citibike']
collection = db['station_status']
  1. General Background and Overview