This file contains 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
*.beam |
This file contains 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
# mongo_template.rb | |
# fork of Ben Scofield's Rails MongoMapper Template (http://gist.github.com/181842) | |
# | |
# To use: | |
# rails project_name -m http://gist.github.com/gists/219223.txt | |
# remove unneeded defaults | |
run "rm public/index.html" | |
run "rm public/images/rails.png" | |
run "rm public/javascripts/controls.js" |
This file contains 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
-module(ann). | |
-define(SIG,fun(X) -> 1 / (1 + math:exp(-X)) end). | |
-define(SIG_DERIV,fun(X) -> math:exp(-X) / (1 + math:exp(-2 * X)) end). | |
-compile(export_all). | |
dp(X,Y) -> | |
lists:foldl(fun(E,Sum) -> E + Sum end, 0, | |
vector_map(fun(EX,EY) -> EX * EY end, X, Y)). |
This file contains 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
Getting a non replicated mongo instance's operation log for indexing: | |
db.oplog.$main.find({ ts: { t: {gte: last_processed_time } } }).sort({$natural:1}); |
This file contains 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
3> {_,I5,I6,H5,H6,O} = ann:run(),I5 ! {pass, 1.3}, I6 ! {pass, 1.8}. | |
NewInput: [{<0.47.0>,0.5},{<0.46.0>,1.3}] | |
NewInput: [{<0.47.0>,0.5},{<0.46.0>,1.3}] | |
{pass,1.8} | |
Output: 0.7109495026250039 | |
Output: 0.7109495026250039 | |
Sens: [<0.50.0>] | |
Sens: [<0.50.0>] | |
NewInput: [{<0.47.0>,1.8},{<0.46.0>,1.3}] | |
NewInput: [{<0.47.0>,1.8},{<0.46.0>,1.3}] |
This file contains 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
# This is based on the styles for the table paging found meow - http://pilu.github.com/web-app-theme/ | |
# total - total number of entries - Foo.count() | |
# current_page - the current page you are on | |
# per_page - how many Foo's you want displayed per page. | |
# uri - the URI to append "?page=#{page}" to, e.g. "/foos" | |
def display_paging_links(total,current_page,per_page,uri) | |
previous_page = current_page <= 1 ? 1 : current_page - 1 | |
pages = (total / per_page.to_f).ceil | |
next_page = current_page < pages ? (current_page + 1) : current_page |
This file contains 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
#eeeew, don't use this on anything "big" | |
# self here is representative of Model | |
def create_slug | |
return if self.name.blank? | |
tail, int = "", 2 | |
initial = convert_to_slug(self.name) | |
if Model.find_by_slug(initial).nil? | |
self.slug = initial | |
else | |
tail = "-#{int}" |
This file contains 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
def convert_to_slug(str) | |
if defined?(ActiveSupport::Inflector.parameterize) | |
ActiveSupport::Inflector.parameterize(str).to_s | |
else | |
ActiveSupport::Multibyte::Handlers::UTF8Handler. | |
normalize(str,:d).split(//u).reject { |e| e.length > 1 }.join.strip.gsub(/[^a-z0-9]+/i, '-').downcase.gsub(/-+$/, '') | |
end | |
end |
This file contains 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
/* | |
Remove rage-a-hol inducing keywords from HN | |
*/ | |
(function() { | |
var keywords = ["python","django"]; //add as you see fit. | |
var cleanse = []; | |
var a = document.getElementsByTagName('a'); | |
for (var i = 0; i < a.length; i++) { | |
for (var j = 0; j < keywords.length; j++) { | |
if (a[i].innerHTML.match(new RegExp(keywords[j], "gim"))) { |
This file contains 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 'PP' | |
class QueryParser | |
attr_accessor :terms | |
def initialize(terms = {}) | |
raise NotImplementedError unless terms.is_a? Hash | |
@terms = terms | |
end | |
def parse |