Skip to content

Instantly share code, notes, and snippets.

View certainty's full-sized avatar
🏠
Working from home

David Krentzlin certainty

🏠
Working from home
View GitHub Profile
(ns net-protocols.examples.console_server.client
(:use [net-protocols.streams.base :as stream]
[net-protocols.streams.tcp :as tcp]
[net-protocols.control.core :as ctrl]
[clojure.string :as str]))
(defn authenticate [stream username password]
(ctrl/challenge-response stream #"Username" (str username "\n"))
(ctrl/challenge-response stream #"Password" (str password "\n")))
(ns net_protocols.examples.console_server.client
(:use [net_protocols.streams.base :as stream]
[net_protocols.streams.tcp :as tcp]
[net_protocols.control.core :as ctrl]))
(defn authenticate [stream username password]
(ctrl/challenge-response stream #"Username" (str username "\n"))
(ctrl/challenge-response stream #"Password" (str password "\n")))
(defn get-version []
(defn with-connection [host port fn]
(with-open [sock (Socket. host port)
writer (io/writer sock)
reader (io/reader sock)]
;; handle errors
(fn reader writer)))
(defn- read-with-timeout
"Reads a single byte from reader or returns false if it
cons = ->(x,y){ ->(a){ a.(x,y) } }
car = ->(c){ c.(->(x,_){ x }) }
cdr = ->(c){ c.(->(_,y){ y }) }
pair = cons.(1,2)
puts car.(pair)
puts cdr.(pair)
(define (Alter x)
(print "Wenn ich " x " Jahre alt bin, dann ist Lucie " (- x 2) " Jahre alt"))
(Alter 10)
(Alter 20)
class Foo
def self.set_finalizer(obj)
ObjectSpace.define_finalizer(obj,method(:finalize))
end
def self.set_finalizer2(obj)
ObjectSpace.define_finalizer(obj,finalize2)
end
def self.finalize
@certainty
certainty / gist:8931150
Last active August 29, 2015 13:56
Simplified example
module Reader
def load_hotels
[Hotel.new]
end
end
class Hotel
extend Reader
end
WITH RECURSIVE dates as
( SELECT NOW() AS day
UNION ALL
SELECT day + interval '1 day'
FROM dates
WHERE day + interval '1 day' <= '2012-12-24'
)
SELECT day FROM dates
LEFT OUTER JOIN DailyData ON dates.day = DailyData.date
WHERE DailyData.id IS NULL
require "spec_helper"
module Capybara
module Node
module Matchers
def has_text?(content)
normalized_content = normalize_whitespace(content)
wait_until do
normalize_whitespace(text).include?(normalized_content) or
@certainty
certainty / test.html.erb
Created December 1, 2012 09:15
capybara
require "spec_helper"
feature 'capybara' do
scenario "ignores hidden elements", js: true do
visit root_path
expect(page).to_not have_content("i'm hidden")
end
end