Skip to content

Instantly share code, notes, and snippets.

View calebphillips's full-sized avatar

Caleb Phillips calebphillips

View GitHub Profile
@calebphillips
calebphillips / gist:1901853
Created February 24, 2012 16:21
Project Euler Problem 35
(ns euler.level2.problem035
(:use [clojure.contrib.lazy-seqs :only [primes]]
[euler.common :only [prime? parse-int]] ))
(defn rotate [[h & t]]
(apply str (concat t [h])))
(defn rotations [s]
(take (count s) (iterate rotate s)))
@calebphillips
calebphillips / gist:2346422
Created April 9, 2012 20:35
Personal/Hobby Code Portfolio
require 'benchmark'
class ActionController::TestCase
alias __old_process__ process
def process(*args)
max_time = 0.2
time = Benchmark.realtime { __old_process__(*args) }
assert time < max_time, exceeded_run_time(time, max_time)
end
@calebphillips
calebphillips / spec_helper.rb
Created July 18, 2012 19:44 — forked from sethbro/spec_helper.rb
Rails unit, functional and integration tests in Minitest spec format.
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rubygems'
gem 'minitest'
require 'minitest/autorun'
require 'action_controller/test_case'
require 'miniskirt'
require 'capybara/rails'
;; Find a random even number less than 100
;; Standard nested lisp form
(rand-nth (filter even? (range 100)))
;; With threading macro http://clojuredocs.org/clojure_core/clojure.core/-%3E%3E
(->> (range 100)
(filter even?)
rand-nth)
(ns nouns
(:require [clojure.java.io :as io]
[clojure.data.generators :as gen]
[datomic.api :as d])
(:import [java.io PushbackReader]))
;; Knobs
(def transaction-size 1000)
(def transaction-count (atom 0))
(def document-count 200000)
(ns pallet-test.core
(:use
[clojure.contrib.command-line])
(:require
[pallet.core :as core]
[pallet.compute :as compute]
[pallet.phase :as phase]
[pallet.crate.java :as java]
[pallet.crate.automated-admin-user :as automated-admin-user]))
(defn nodes-in-group
"Build a list of nodes in a given security-group"
[security-group]
(filter #(= (% 0) security-group)
(map #(vector (pallet.compute/group-name %)
(pallet.compute/primary-ip %)
(pallet.compute/id %)
(pallet.compute.jclouds/node-locations %) )
(pallet.compute/nodes srvc))))
(require '[clojure.string :as str])
(def turns
{:L {:N :W
:W :S
:S :E
:E :N}
:R {:N :E
:E :S
:S :W
#!/bin/sh
pat='.marvel-2015.04.29'
idxs=`curl -s localhost:9200/_cat/indices/${pat}\?h=index | sort`
single=`echo $idxs | tail -1`
id=`echo $pat | sed 's/[^a-zA-Z]*//g'`-`date -u +%s`
d=/tmp/$id
if [ -d $d ]; then
echo $d exists, delete and rerun $0