This file contains 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 backfill-spike.core | |
(:require [byte-streams :as bs] | |
[clojure.java.jdbc :as jdbc] | |
[clojure.string :as string] | |
[clojure.java.io :as io] | |
[environ.core :refer [env]]) | |
(import org.postgresql.copy.CopyManager) | |
(import org.postgresql.copy.PGCopyInputStream) | |
(import org.postgresql.util.PSQLException) | |
(import java.io.IOException) |
This file contains 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
def delete(value, node = @root) | |
return if node.nil? | |
if x < node.value | |
node.left = delete(x, node.left) | |
elsif x > node.value | |
node.right = delete(x, node.right) | |
else | |
if node.left.nil? | |
return node.right |
This file contains 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
bonus: Stealthed | |
ability_score: | |
primary: dexterity | |
secondary: | |
- strength | |
- charisma | |
powers: | |
cloud_of_steel: | |
name: Cloud Of Steel | |
type: at_will |
This file contains 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 credential-fn [guid] | |
(if-let [user (persistence/find-user-by-guid guid)] | |
(assoc user :roles #{:fashion.server/user}))) | |
(defn guid [request] | |
(if (empty? (:session request)) | |
(let [user (persistence/create-user {:guid (java.util.UUID/randomUUID) :password (str (java.util.UUID/randomUUID))})] | |
(workflows/make-auth (assoc user :roles #{:fashion.server/user} :identity (:guid user)) {:cemerick.friend/workflow :guid})) | |
(let [user (persistence/find-user-by-guid (get-in request [:session :cemerick.friend/identity :current]))] | |
(when user |
This file contains 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 find-user | |
[id] | |
{:id id}) |
This file contains 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
(time (map #(score %) (take 10000 (range 144115222435594240 149551225103187968)))) | |
; "Elapsed time: 0.107 msecs" | |
(time (sort (map #(score %) (take 10000 (range 144115222435594240 149551225103187968))))) | |
; "Elapsed time: 672.586 msecs" |
This file contains 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 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
doc = Nokogiri::HTML(open(ARGV[0])) | |
title = doc.css('title').first.content.scan(/\r\n\t(.*) -/).first | |
puts title | |
image = doc.css('img#imgPhoto').first.attributes['src'].value |
This file contains 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
(define minimize-interval-list | |
(lambda (ls) | |
(if (null? ls) | |
'() | |
(if (equal? (length ls) 1) | |
ls | |
(if (interval-intersects? (car ls) (cadr ls)) | |
(minimize-interval-list (append (interval-union (car ls) (cadr ls)) (cddr ls))) | |
(cons (car ls) (minimize-interval-list (cdr ls)))))))) |
This file contains 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
board = ["m", "w", "e", "t", "p", "e", "q", "i", "x", "a", "h", "v", "f", "f", "y", "j", "n", "l", "j", "h", "w", "c", "e", "s", "r"] | |
all_words = File.open('/usr/share/dict/words').readlines.map! { |line| line.strip.chomp } | |
valid_words = all_words.reject { |w| w =~ /[^#{board.join}]/ } | |
valid_words = valid_words.select do |w| | |
bool = true | |
bool = false if w.size <= 2 | |
split_word = w.downcase.split('') |
This file contains 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
6 (defn everyo | |
7 "A pseudo-relation that takes a coll and ensures that the goal g | |
8 succeeds on every element of the collection." | |
9 [g coll] | |
10 (if (seq coll) | |
11 (all | |
12 (g (first coll)) | |
13 (everyo g (next coll))) | |
14 s#)) | |
15 |
NewerOlder