Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'indextank'
url = 'http://:T9a+hLm76n+KgH@2834u.api.indextank.com'
api = IndexTank::Client.new url
index = api.indexes('test')
threads = []
text = "this /as3<<<<!>#!$%!$<<lis a test ta<Q@#L$#<!!!34lkj 431<!//1lkj4> lskfj o...43lk1j 988181<,G$?5ly?H>>>5//2\\\4\33...43''''/////ke it "# * 2000
2011-06-13T03:07:19+00:00 app[web.1]: /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in `require': /app/.bundle/gems/ruby/1.8/bundler/gems/tanker-2a9dd6877820/lib/tanker.rb:295: syntax error, unexpected ')', expecting '=' (SyntaxError)
2011-06-13T03:07:19+00:00 app[web.1]: /app/.bundle/gems/ruby/1.8/bundler/gems/tanker-2a9dd6877820/lib/tanker.rb:326: module definition in method body
2011-06-13T03:07:19+00:00 app[web.1]: /app/.bundle/gems/ruby/1.8/bundler/gems/tanker-2a9dd6877820/lib/tanker.rb:402: syntax error, unexpected kEND, expecting $end
2011-06-13T03:07:19+00:00 app[web.1]: from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in `require'
2011-06-13T03:07:19+00:00 app[web.1]: from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:in `each'
2011-06-13T03:07:19+00:00 app[web.1]: from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:in `require'
2011-06-13T03:07:19+00:00 app[web.1]:
restless
software
tools
check
twist
flaptor
twitter
trend
charts
blablaautora
@dbasch
dbasch / adndump.rb
Created September 1, 2012 21:50
Dump the ADN Global feed to your terminal
#!/usr/bin/env ruby
%w(open-uri json time).each { |dependency| require dependency }
#quick hack to see the ADN Global Timeline scrolling on your terminal
#by @dbasch - modify at will
toSleep = 3
color = 0
start = Time.now
ids, old_ids = [], []
@dbasch
dbasch / gist:4151277
Created November 26, 2012 23:08
Indexing text files using transient state in Clojure
;; Create in-memory mappins from each word to a set of files that contain it.
;; If you kill the server, you'll have to reindex everything.
(defn build-index[dirname]
(loop [files (map #(.getName %) (.listFiles (java.io.File. dirname))) idx (transient {})]
(if (empty? files) (persistent! idx)
(recur
(rest files)
(loop [tokens (-> (str dirname "/" (first files)) slurp tokenize)
iidx idx]
(if (empty? tokens) iidx
@dbasch
dbasch / gist:4159527
Created November 28, 2012 07:02
Indexing using state, not thread safe.
;; Create in-memory mappings from each word to a set of files that contain it.
(defn build-index[dirname]
(def idx (com.google.common.collect.ArrayListMultimap/create))
(doseq [file (map #(.getName %) (.listFiles (java.io.File. dirname)))]
(doseq [token (-> (str dirname "/" file) slurp tokenize)]
(.put idx token file)))
idx)
@dbasch
dbasch / gist:4159593
Created November 28, 2012 07:19
Creating an in-memory index in Java using a Multimap
import java.io.File;
import java.util.regex.Pattern;
import java.util.Scanner;
import com.google.common.collect.ArrayListMultimap;
/** create in-memory mappings from words to the files that contain them */
public class Indexer {
public static ArrayListMultimap<String,String> buildIndex(String dirName) throws java.io.IOException {
ArrayListMultimap<String,String> map = ArrayListMultimap.create();
Pattern p = Pattern.compile("[\\s#&!:,;\\.\\\\+-]+");
@dbasch
dbasch / gist:4176756
Created November 30, 2012 16:18
Quick and dirty text indexer
import java.io.File;
import java.util.regex.Pattern;
import java.util.Scanner;
import com.google.common.collect.ArrayListMultimap;
/** create in-memory mappings from words to the files that contain them */
public class Indexer {
public static ArrayListMultimap<String,String> buildIndex(String dirName) throws java.io.IOException {
ArrayListMultimap<String,String> map = ArrayListMultimap.create();
Pattern p = Pattern.compile("[\\s#&!:,;\\.\\\\+-]+");
(ns closearch.words
(:use [clojure.string :only (split)]))
(def dict (split (slurp "/usr/share/dict/words") #"\n"))
(defn -main[& args]
(dotimes [n (#(Integer/parseInt %) (first args))]
(spit (str "text/file." n) (apply str (interpose " " (take 5000 (shuffle dict)))))))
import java.io.File;
import java.util.regex.Pattern;
import java.util.Scanner;
import com.google.common.collect.ArrayListMultimap;
/** create in-memory mappings from words to the files that contain them */
public class Indexer {
public static ArrayListMultimap<String,String> buildIndex(String dirName) throws java.io.IOException {
ArrayListMultimap<String,String> map = ArrayListMultimap.create();
for (File f : new File(dirName).listFiles()) {