Skip to content

Instantly share code, notes, and snippets.

View daveray's full-sized avatar

Dave Ray daveray

View GitHub Profile
@daveray
daveray / busy-cursor.clj
Created August 31, 2012 01:56
Clojure/Seesaw busy cursor example
(ns busy-cursor.core
(:use seesaw.core))
(defn long-running-task
[]
(Thread/sleep 5000)
"The result")
(defn run-task-with-busy-cursor
[c]
@daveray
daveray / gist:3444716
Created August 24, 2012 02:06
lein-tarsier errors in lein2 preview 8
[503,1] joyspring [master *]$ lein2 vimclojure
Could not find artifact lein-tarsier:lein-tarsier:pom:0.9.3 in central (http://repo1.maven.org/maven2)
Retrieving lein-tarsier/lein-tarsier/0.9.3/lein-tarsier-0.9.3.pom (3k)
from https://clojars.org/repo/
Could not find artifact lein-tarsier:lein-tarsier:jar:0.9.3 in central (http://repo1.maven.org/maven2)
Retrieving lein-tarsier/lein-tarsier/0.9.3/lein-tarsier-0.9.3.jar (8k)
from https://clojars.org/repo/
Exception in thread "main" java.lang.ClassNotFoundException: vimclojure.nailgun.NGServer, compiling:(NO_SOURCE_PATH:1)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6462)
at clojure.lang.Compiler.analyze(Compiler.java:6262)
@daveray
daveray / lein2.txt
Created May 10, 2012 12:11
lein2-preview3 repl issue
$ lein2 version
Leiningen 2.0.0-preview3 on Java 1.6.0_29 Java HotSpot(TM) 64-Bit Server VM
$ lein2 new hi
Generating a project called hi based on the 'default' template.
$ cd hi
$ lein2 deps
$ lein2 repl
Retrieving org/clojure/tools.nrepl/0.2.0-beta1/tools.nrepl-0.2.0-beta1.pom
from http://repo1.maven.org/maven2/
Could not find artifact org.thnetos:cd-client:pom:0.3.3 in central (http://repo1.maven.org/maven2)
@daveray
daveray / table-test.clj
Created April 5, 2012 12:44
Highlighting table rows with Seesaw
(ns table-test.core
(:use [seesaw core table swingx]))
; A predicate that decides whether a row should be highlighted
; adapter is an instance of JXTable.TableAdapter
; http://projects.joshy.org/projects/painterreview/swingx/org/jdesktop/swingx/JXTable.TableAdapter.html
(defn hl-predicate [renderer adapter]
; Highligh all rows where :age is over thirty
(> (.getValueAt adapter (.row adapter) 0) 30))
@daveray
daveray / gist:2231956
Created March 29, 2012 00:50
chef mysql issues
[Wed, 28 Mar 2012 10:52:02 -0700] FATAL: Chef::Exceptions::ShellCommandFailed: execute[mysql-install-privileges] (mysql::server line 136) had an error: Expected process to exit 0, but it exited with 1
---- Begin output of /usr/bin/mysql -u root -p"B0MAn1h8e3LFoV_4iDzA" < /etc/mysql/grants.sql ----
STDOUT:
STDERR: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
---- End output of /usr/bin/mysql -u root -p"B0MAn1h8e3LFoV_4iDzA" < /etc/mysql/grants.sql ----
Ran /usr/bin/mysql -u root -p"B0MAn1h8e3LFoV_4iDzA" < /etc/mysql/grants.sql returned 1
that is, maybe mysql isn't up yet when it tries to set the root password.
@daveray
daveray / gist:2231948
Created March 29, 2012 00:49
chef mysql issues
[Wed, 28 Mar 2012 10:51:58 -0700] INFO: Processing gem_package[mysql] action install (mysql::client line 50)
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/provider/package/rubygems.rb:202.
NOTE: Gem::SourceIndex#search is deprecated with no replacement. It will be removed on or after 2011-11-01.
Gem::SourceIndex#search called from /opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/provider/package/rubygems.rb:76.
and then fails with:
[Wed, 28 Mar 2012 10:52:02 -0700] FATAL: Chef::Exceptions::ShellCommandFailed: execute[mysql-install-privileges] (mysql::server line 136) had an error: Expected process to exit 0, but it exited with 1
---- Begin output of /usr/bin/mysql -u root -p"B0MAn1h8e3LFoV_4iDzA" < /etc/mysql/grants.sql ----
STDOUT:
STDERR: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock
@daveray
daveray / print-table.clj
Created March 27, 2012 02:08
clojure.pprint/print-table is a gem
user=> (use 'korma.core)
nil
user=> (use 'korma.db)
nil
user=> (defdb dev (sqlite3 {:classname "org.sqlite.JDBC"
:subprotocol "sqlite"
:subname "db/dev.sqlite3"}))
{:pool #<Delay@4471dfd7: :pending>, :options {:naming {:keys #<core$identity clojure.core$identity@76612ef6>, :fields #<core$identity clojure.core$identity@76612ef6>}, :delimiters ["\"" "\""]}}
user=> (defentity users)
#'user/users
@daveray
daveray / listbox-model-example.clj
Created March 20, 2012 21:20
List box model binding example
; very basic example of driving a listbox with binding in Seesaw
(use 'seesaw.core)
(require '[seesaw.bind :as b])
; create a text box and a listbox next to each other
(defn make-ui []
(frame
:size [400 :by 400]
:content (left-right-split
(scrollable (text :id :text :multi-line? true))
@daveray
daveray / dosync.rb
Created February 18, 2012 03:24
dosync test
# https://github.com/daveray/familiar
require 'familiar'
class DoSyncTest
def initialize()
@my_ref = Familiar.ref 0
end
def test_threaded_refs
threads = []
@daveray
daveray / dosync.java
Created February 18, 2012 03:11
Working JRuby/Clojure dosync
// Hacked from headius' version here: https://github.com/headius/clojr/blob/master/src/main/java/com/headius/clojr/ClojrLibrary.java
// See also https://jira.codehaus.org/browse/JRUBY-6149
public static IRubyObject dosync(final ThreadContext context, final IRubyObject self, final Block block) throws Exception {
final Ruby ruby = context.runtime;
return (IRubyObject) LockingTransaction.runInTransaction(new Callable() {
public Object call() throws Exception {
// re-get transaction in case this gets run in different threads
try {