Skip to content

Instantly share code, notes, and snippets.

View dsedivec's full-sized avatar

Dale Sedivec dsedivec

View GitHub Profile
@dsedivec
dsedivec / gist:199309
Created October 1, 2009 23:04
Example of using c.c.zip-filter.xml
(require '[clojure.xml :as xml]
'[clojure.zip :as zip]
'[clojure.contrib.zip-filter.xml :as zfx])
(def reddit-rss-xml (xml/parse "http://www.reddit.com/.rss"))
(def zipped-xml (zip/xml-zip reddit-rss-xml))
;; xml1-> treats keywords as "search for this tag." xml/node at the
;; end says "return me that one part of the XML map" (format specified
import java.util.HashMap;
public class EmptyCollectionMap extends HashMap {
Class collectionType;
public EmptyCollectionMap(Class collectionType) {
super();
this.collectionType = collectionType;
}
print "hello world"
In one window:
$ python2.6 /tmp/wsgiexample.py
In another:
$ curl http://localhost:9977
POST some text to me.
$ curl -d 'This is xxx a test.' http://localhost:9977
I found 3 X(es).
\documentclass{article}
\usepackage{tabularx}
\newenvironment{tableenv}[0]{%
\tabularx{1\linewidth}{|l|X|}%
}{%
\endtabularx%
}
@dsedivec
dsedivec / gist:765957
Created January 5, 2011 05:03
use with :as and :only
user=> replace
#<core$replace clojure.core$replace@175bc6c8>
user=> split
java.lang.Exception: Unable to resolve symbol: split in this context (NO_SOURCE_FILE:0)
user=> (use '[clojure.string :as s :only (replace split)])
WARNING: replace already refers to: #'clojure.core/replace in namespace: user, being replaced by: #'clojure.string/replace
nil
user=> replace
#<string$replace clojure.string$replace@4245c97b>
user=> split
@dsedivec
dsedivec / gist:2154361
Created March 22, 2012 00:17
Make simple CREATE TABLE from the first line of a tab-delimited data file
# Put this in a file and run it like "python yourscript.py name_of_your_file.csv".
import sys
import csv
csv_file_obj = csv.reader(open(sys.argv[1], "rb"), dialect=csv.excel_tab)
first_row = csv_file_obj.next()
# first_row is now a list of column names, we hope. Feel free to print it out.
print "CREATE TABLE tablename (%s);" % (", ".join("%s TEXT" % (name,) for name in first_row),)
#!/usr/bin/env python
import sys
import re
import argparse
CSI = "\033["
RESET = CSI + "0m"
COLORS = dict((name, value) for value, name
@dsedivec
dsedivec / vimkill.sh
Last active August 29, 2015 13:57
vimkill command: pgrep + vim + kill
vimkill () {
local temp_file
temp_file=$(mktemp -t vimkillXXXXXXXXXX)
if [ $? -ne 0 ]; then
echo "mktemp failed" >&2
return 1
fi
if ! pgrep -fl "$@" > "$temp_file"; then
rm "$temp_file"
echo "no matching processes found" >&2
;; The desire for this is obvious once you use comment-dwim-2, but the
;; implementation ideas come from a comment by Fuco1 (author of
;; smartparens AFAIK) on
;; http://endlessparentheses.com/a-comment-or-uncomment-sexp-command.html.
;; Artur's code there breaks on uncommenting when there's a nearby
;; string with ";" in it, e.g. (untested simplified test case for the
;; problem I experienced):
;;
;; (define-key blah "M-;" #'foo)
;;