https://github.com/calebphillips/luhny/blob/master/src/luhny/core.clj
This file contains hidden or 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
(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))) |
This file contains hidden or 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 '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 |
This file contains hidden or 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
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' |
This file contains hidden or 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
;; 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) |
This file contains hidden or 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
(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) |
This file contains hidden or 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
(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])) |
This file contains hidden or 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
(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)))) |
This file contains hidden or 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 '[clojure.string :as str]) | |
(def turns | |
{:L {:N :W | |
:W :S | |
:S :E | |
:E :N} | |
:R {:N :E | |
:E :S | |
:S :W |
This file contains hidden or 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
#!/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 |
OlderNewer