Skip to content

Instantly share code, notes, and snippets.

View dsbw's full-sized avatar

Blake Watson dsbw

View GitHub Profile
@dsbw
dsbw / gist:90ac0018f388088e1cdee0ba3743c88a
Created September 13, 2016 21:12
How to recurse in logic...?
(defn allowed-values [constraints]
(cond
(nil? constraints) (run* [q])
(coll? constraints) (run* [q] (membero q constraints)) ;;<--works but not recursively
;;(coll? constraints) (run* [q] (first constraints))
(keyword? constraints) (allowed-values (translate-symbol constraints))
:else (run* [q] (== constraints q)))
(ns temp
(:refer-clojure :exclude [==])
(:use [clojure.core.logic])
(:use [clojure.core.logic.pldb]))
(db-rel parent x y)
(db-rel male x)
(db-rel female x)
(defn child [x y]
@dsbw
dsbw / designer.html
Last active August 29, 2015 14:09
designer
<link rel="import" href="../paper-toast/paper-toast.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@dsbw
dsbw / gist:6678596
Created September 23, 2013 23:53
How to set up test for loaded config.
@config = YAML.load_file('config/config.yml')[ENV['environment'] ||= 'test']
describe "let" do
let(:count) { @x = 0 }
let(:count_plus_1) { @x += 1}
it "memoizes the value" do
count.should == 0
count_plus_1.should == 1
end
it "is not cached across examples" do
class Pusher
#initialization stuff
@config = information_about_queue_I_wish_to_monitor
Mqhelper::subscribe_to_queue(@config) do |delivery_info, properties, payload |
process payload
end
end
#Moving helps in the sense that my RSpec can directly call process, but my class is still listening to @config info
require 'rspec'
Given(/^a HubSpot monitor$/) do
@h = HubspotMonitor::HubMon.new
end
And(/^new contact info arriving$/) do
@h.stub(:dummy) {"New contact info"}
end