Skip to content

Instantly share code, notes, and snippets.

; CIDER 0.6.0alpha (package: 20140316.1007) (Clojure 1.5.1, nREPL 0.2.3)
user> (.maxMemory (Runtime/getRuntime))
103284736
user> (require '[clojure.java.io :as io])
nil
user> (with-open [f (io/writer "/tmp/foo")] (doseq [x (range 50000)] (.write f (prn-str [x (range 1000)]))))
nil
user> (.length (io/file "/tmp/foo"))
194988890
user> (slurp "/tmp/foo")
(require 'compile)
(defun locate-all-dominating-files (dir filename)
"Searches for FILENAME in DIR and its parents, returning a list
of all dirs containing the file."
(let ((found-dir (locate-dominating-file (expand-file-name dir) filename)))
(if found-dir
(cons found-dir (locate-all-dominating-files
(concat found-dir "..")
filename)))))
(ns my.cache.listener
(:require [immutant.cache :as c])
(:import org.infinispan.notifications.Listener
[org.infinispan.notifications.cachelistener.annotation
CacheEntryCreated CacheEntryModified CacheEntryRemoved]))
(definterface Handler (^void handle [event]))
(deftype ^{Listener true}
Monitor []
#!/bin/bash
IN="LVDS1"
EXT="HDMI3"
if (xrandr | grep "$EXT disconnected"); then
xrandr -d :0.0 --output $IN --auto --output $EXT --off
else
xrandr -d :0.0 --output $IN --auto --output $EXT --auto --right-of $IN --primary
fi
@cemerick
cemerick / gist:6cc2a276f34177ebf52b
Created March 9, 2015 17:46
quartz scheduling job name / key leak
; CIDER 0.6.0alpha (package: 0.5.0) (Clojure 1.6.0, nREPL 0.2.3)
=> (schedule #(println "foo"))
=> (schedule #(println "foo"))
=> (schedule #(println "foo"))
...
=> (def s (immutant.scheduling.internal/scheduler {}))
#<Var@5f67764a:
#<QuartzScheduling org.projectodd.wunderboss.scheduling.QuartzScheduling@450109d4>>
; scheduled job names (and thus their JobKeys) are retained, even if they're not repeating
Spec::Runner.configure do |config|
config.before(:suite) do
configuration = org.jboss.arquillian.impl.XmlConfigurationBuilder.new.build()
Thread.current[:test_runner_adaptor] = org.jboss.arquillian.impl.DeployableTestBuilder.build(configuration)
Thread.current[:test_runner_adaptor].beforeSuite
end
config.before(:all) do
if (self.class.respond_to? :create_deployment)
Dear Mr. Benton,
It has been brought to our attention that our social studies
class, Ze Fat Cats, has been treated differently than the other
classes in the case of the ropes course. This message is written
not in an act of asking to go out, but why we don't and if we
will. Therefore, we hope you take us seriously and consider our
thoughts.
We happen to know that both the Lactopuses (Lactopi?) and the
require 'spec_helper'
require 'open-uri'
# A remote group nested within a local one
describe "end-to-end testing" do
# Deploy our apps
deploy <<-END.gsub(/^ {4}/,'')
application:
root: #{File.dirname(__FILE__)}/..
require "#{File.dirname(__FILE__)}/../../twitter/spec/spec_helper"
require 'torquebox-core'
remote_describe "tweet consumption testing" do
# Necessary for injection in examples
include TorqueBox::Injectors
# Deploy our apps
deploy <<-END.gsub(/^ {4}/,'')
require 'torquespec'
TorqueSpec.local {
require 'capybara/dsl'
require 'akephalos'
Capybara.register_driver :akephalos do |app|
Capybara::Driver::Akephalos.new(app, :browser => :firefox_3)
end