Skip to content

Instantly share code, notes, and snippets.

@uvtc
uvtc / foo.clj
Created February 24, 2017 22:38
first attempt at sorting hiccup table rows
#!/usr/bin/env inlein
'{:dependencies [[org.clojure/clojure "1.8.0"]
[hiccup "1.0.5"]]}
(require '[hiccup.page :as hic-p])
;; Note, some :td's may contain links, or have
;; attributes, or both.
(def tbl [:table {:stuff "yo"}
@uvtc
uvtc / gist:03304823f8d03b3931f2
Created December 30, 2015 19:16
panda install Readline, error
$ panda install Readline
==> Fetching Readline
==> Building Readline
==> Testing Readline
===SORRY!=== Error while compiling /home/john/.panda-work/1451502005_1/lib/Readline.pm
In 'remove_history' routine declaration - Not an accepted NativeCall type for parameter [1] : Int
-->For Numerical type, use the appropriate int32/int64/num64...
at /home/john/.panda-work/1451502005_1/lib/Readline.pm:769
===SORRY!=== Error while compiling /home/john/.panda-work/1451502005_1/lib/Readline.pm
In 'remove_history' routine declaration - Not an accepted NativeCall type for parameter [1] : Int
@uvtc
uvtc / gist:c1c4cbd6f57c85466e7e
Created July 19, 2014 02:05
Best way to find a particular map in a set of them?
#!/usr/bin/env lein-exec
(def people
#{{:id 1 :name "Gorf"}
{:id 2 :name "Riff"}
{:id 3 :name "Raff"}
;; ... snip lots more
{:id 10000 :name "Grum"}})
;; Quick, find Raff's id!
@uvtc
uvtc / gist:7837784
Last active December 30, 2015 13:49
#!/usr/bin/env perl
use Modern::Perl;
use autodie qw/:all/;
use File::Copy;
my @tar_files = glob '*.tar'; # All the tar files in the curr dir.
unless (@tar_files) {
die "No tar files here. Exiting!\n";
@uvtc
uvtc / gist:6896279
Last active December 25, 2015 01:39
decoding base64-encoded text
(require '[clojure.data.codec.base64 :as base64])
;;---------------------------------------------------
;; From <http://en.wikipedia.org/wiki/Base64>
(def input "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz
IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg
dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu
dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo
ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=")
@uvtc
uvtc / gist:6895758
Created October 9, 2013 03:28
using pomegranate in a script
#!/usr/bin/env lein-run
(require '[cemerick.pomegranate :as pome])
(pome/add-dependencies
:coordinates '[[org.clojure/math.combinatorics "0.0.4"]]
:repositories (merge cemerick.pomegranate.aether/maven-central
{"clojars" "http://clojars.org/repo"}))
(require '[clojure.math.combinatorics :as combo])
@uvtc
uvtc / gist:6894751
Last active December 25, 2015 01:28
(def items ["florian" "fluid" "flack" "flask" "flan"])
;; Find the item that begins with "flu".
(println (first (filter (fn [s]
(re-find #"^flu" s))
items)))
#!/bin/bash
lein run -m clojure.main/main -i "$@"
@uvtc
uvtc / gist:6894554
Created October 9, 2013 01:07
Running this via lein-exec, and also, without it.
(require 'leiningen.exec)
(leiningen.exec/deps '[[org.clojure/math.combinatorics "0.0.4"]])
(require '[clojure.math.combinatorics :as combo])
(println
(combo/combinations [1 2 3] 2))
#!/usr/bin/java -jar /home/john/opt/clojure-1.5.1/clojure-1.5.1.jar
(println "hi")