Skip to content

Instantly share code, notes, and snippets.

View brutuscat's full-sized avatar

Mauro Asprea brutuscat

View GitHub Profile
May 31, 2012 3:30:22 PM org.apache.solr.common.SolrException log
SEVERE: org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: SimpleFSLock@/home/entretenerse/src/apache-solr-3.6.0/example
/data/index/write.lock
at org.apache.lucene.store.Lock.obtain(Lock.java:84)
at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:1098)
at org.apache.solr.update.SolrIndexWriter.<init>(SolrIndexWriter.java:84)
at org.apache.solr.update.UpdateHandler.createMainIndexWriter(UpdateHandler.java:101)
at org.apache.solr.update.DirectUpdateHandler2.openWriter(DirectUpdateHandler2.java:171)
at org.apache.solr.update.DirectUpdateHandler2.delete(DirectUpdateHandler2.java:286)
at org.apache.solr.update.processor.RunUpdateProcessor.processDelete(RunUpdateProcessorFactory.java:68)
@brutuscat
brutuscat / gist:2944180
Created June 17, 2012 10:46
Steps for POW to reload its config
sudo pow --install-system
sudo launchctl unload /Library/LaunchDaemons/cx.pow.firewall.plist
sudo launchctl load /Library/LaunchDaemons/cx.pow.firewall.plist
# Quit pow process (it will restart itself) via Activity Monitor (MacOSX)
pow --print-config
# Your new config will be there and picked up by POW
@brutuscat
brutuscat / gist:2974188
Created June 22, 2012 17:49
Facebook Graph api places geo-query for autocomplete
https://graph.facebook.com/search?q=coffee&type=place&center=-34.58,-58.427&distance=1000&fields=location,name,id,checkins
@brutuscat
brutuscat / interpolation.rb
Created August 31, 2012 16:39
Completes an array with missing consecutive numbers. Kind of a linear interpolation. Read something more here http://stackoverflow.com/questions/4570755/calculate-missing-values-in-an-array-from-adjacent-values
list = [2, 3, 4, 6, 7, 9, 12]
[].tap{ |array|
[0, *list, 0].each_cons(3).map do |p, x, n|
array << x;
(n - x).times{|i| array << x + i if i > 0}
end
} # => [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
@brutuscat
brutuscat / helper.rb
Created August 31, 2012 17:23
helpers in console
>> helper.truncate("Testing", length: 4)
=> "T..."
>> helper.link_to "Home", app.root_path
=> "<a href=\"/\">Home</a>"
@brutuscat
brutuscat / gist:3893558
Created October 15, 2012 16:49 — forked from mattb/gist:3888345
Some pointers for Natural Language Processing / Machine Learning

Here are the areas I've been researching, some things I've read and some open source packages...

Nearly all text processing starts by transforming text into vectors: http://en.wikipedia.org/wiki/Vector_space_model

Often it uses transforms such as TFIDF to normalise the data and control for outliers (words that are too frequent or too rare confuse the algorithms): http://en.wikipedia.org/wiki/Tf%E2%80%93idf

Collocations is a technique to detect when two or more words occur more commonly together than separately (e.g. "wishy-washy" in English) - I use this to group words into n-gram tokens because many NLP techniques consider each word as if it's independent of all the others in a document, ignoring order: http://matpalm.com/blog/2011/10/22/collocations_1/

@brutuscat
brutuscat / gist:3919594
Created October 19, 2012 17:47
Variable set to properly compile MRI ruby in Mountain Lion
CONFIGURE_OPTS='--with-openssl-dir=/opt/local --with-opt-dir=/opt/local'
@brutuscat
brutuscat / gist:3996311
Created November 1, 2012 20:34
dotcloud.yml
www:
type: ruby
exclude_bundler_groups:
- development
config:
ruby-version: 1.9.3
# ws:
# type: custom
@brutuscat
brutuscat / gist:3996338
Created November 1, 2012 20:37
config.ru
# encoding: UTF-8
# config.ru
require 'rack'
require 'haml'
require 'haml_file'
app = proc do |env|
HamlFile.new('views').call(env)
end
getCurrentRange = function () {
var sel = window.getSelection();
var active = document.activeElement;
if (editor[0] == active && sel.getRangeAt && sel.rangeCount) {
return sel.getRangeAt(0);
}
},