This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn ellip-2 [words] | |
(let [sentlist (re-split #"\s+" words)] | |
(str (str-join " " (take 3 sentlist)) "..."))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns pc.core | |
(str 1 2 nil 3) | |
(+ 1 3) | |
(Character/toUpperCase \s) | |
(def y (apply str (interleave "Attack at midnight" "The purple elephant chortled"))) | |
(apply str (take-nth 2 y)) | |
; (if part) (else part), () evaluates true | |
(if () "We are in clojure!" "We are in common Lisp!") | |
; zero is true too. that's uh, pretty absurd. | |
(if 0 "Zero is true" "Zero is false") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn ellip-2 [words] | |
(str (->> words (re-split #"\s+") (take 3) (str-join " ")) "...")) | |
; What does this do? Well, it ellipsizes sentences. it's an improvement upon the book's version. | |
; we send it strings like "Yo this is a test sentence!" and we get back "Yo this is..." | |
; legitimately useful for creating things like short descriptions to articles. | |
; you call it like | |
(ellip-2 "Yo this is a test sentence!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "json" | |
require "httparty" | |
require "zip/zipfilesystem" | |
$tmp = "/home/callen/tmp/" | |
def judgments_url(job_id) | |
"https://api.crowdflower.com/v1/jobs/#{job_id}.csv?type=json&key=88530fff071fd1301c1279efb35281997b3b9e10" | |
end | |
def zip_path(job_id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns irc | |
(:import (java.net Socket) | |
(java.io PrintWriter InputStreamReader BufferedReader))) | |
(require 'clojure.contrib.duck-streams) | |
(:use 'clj-time.core :only [in-secs interval epoch now]) ;; stashing until I understand | |
(def network {:name "irc.freenode.net" :port 6667}) | |
(def user {:name "callen-bot" :nick "callen-bot"}) | |
(declare conn-handler) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chat.js:176 | |
Uncaught TypeError: Cannot call method 'get' of undefined | |
(anonymous function) | |
f.event.dispatch | |
f.event.add.h.handle.i | |
var windowName = irc.chatWindows.getActive().get('name'); | |
Uncaught TypeError: Cannot call method 'get' of undefined (repeated 10 times) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bash --init-file <(cat <<EOF | |
source `which virtualenvwrapper.sh`; | |
workon $PROJECT_NAME; | |
EOF | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The Computer Language Benchmarks Game | |
# http://shootout.alioth.debian.org/ | |
# | |
# contributed by Karl von Laudermann | |
# modified by Jeremy Echols | |
# modified by Detlef Reichl | |
# modified by Joseph LaFata | |
# modified by Peter Zotov | |
size = ARGV.shift.to_i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from array import array | |
from multiprocessing import Pool | |
def do_row(fy): | |
local_abs = abs | |
two_over_size = 2.0 / size | |
xr_offs = range(7, -1, -1) | |
xr_iter = range(50) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Searching on my elasticsearch instance returns an empty list | |
class Dish(Document): | |
# ... some content removed | |
search = { u'name': {'boost': 1.0, | |
'index': 'analyzed', | |
'store': 'yes', | |
'type': u'string', | |
'term_vector' : 'with_positions_offsets'}, | |
u'venue': {'boost': 1.0, | |
'index': 'analyzed', |
OlderNewer