Skip to content

Instantly share code, notes, and snippets.

View eklitzke's full-sized avatar

Evan Klitzke eklitzke

View GitHub Profile
@eklitzke
eklitzke / gist:2907750
Created June 10, 2012 23:47
simple clojure agent program
(ns foo.core)
(use 'lamina.core 'lamina.connections 'aleph.http)
(defn print-agent [fmt & rest]
"prints a printf-style message, prefixed by the current agent"
(let [args (if (nil? rest) '(*agent*) (cons *agent* rest))]
(apply printf (str "%s " fmt "\n") args)))
(defn make-get-requests [_ ntimes url]
(ns cs.crawler)
(defn- read-forms
"Read all of the forms from a file, passed by name."
[file]
(let [reader-read-forms
(fn [rdr]
(let [inner-read (fn func [rslt]
(try
(func (conj rslt (read rdr)))
$('.ajax_paginate').click(function() {
setTimeout(engirdle, 500);
});
(ns clojure-crawler.core
(:require [cheshire.core :as cheshire]
[clj-http.client :as client]
[clojure.tools.cli :as cli]))
(defn- read-forms
"Read all of the forms from a file, passed by name."
[file]
(let [reader-read-forms
(fn [rdr]
commit 912767abf9ee5271061b35ec718f1d27482dbdbd
Author: Evan Klitzke <evan@eklitzke.org>
Date: Sun Jul 1 23:40:49 2012 -0700
add reader threads
diff --git a/src/index_reader.cc b/src/index_reader.cc
index adf7f27..f890b44 100644
--- a/src/index_reader.cc
+++ b/src/index_reader.cc
void NGramIndexReader::Find(const std::string &query,
SearchResults *results) {
if (query.size() < ngram_size_) {
FindSmall(query, results);
return;
}
// split the query into its constituent ngrams
std::set<std::string> ngrams;
for (std::string::size_type i = 0;
deb http://ftp.us.debian.org/debian/ wheezy main
deb-src http://ftp.us.debian.org/debian/ wheezy main
deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main
(function () {
var x = 1;
(function (x) {
function () {
// x is always 1 here, no matter what
}
})(x);
x = 2;
})
@eklitzke
eklitzke / mem.sh
Created July 23, 2012 15:45
find allocated memory for a process
#!/bin/bash
#
# Get "allocated" memory for a process (not including shmem!)
pmap $1 | egrep ' anon|stack ' | awk '{s += $2} END {printf "%1.1fM\n", s / 1024.}'
static void
decide_maybe_mmap (_IO_FILE *fp)
{
/* We use the file in read-only mode. This could mean we can
mmap the file and use it without any copying. But not all
file descriptors are for mmap-able objects and on 32-bit
machines we don't want to map files which are too large since
this would require too much virtual memory. */
struct _G_stat64 st;