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 "java" | |
require "./lib/weka.jar" | |
def read_data(filename) | |
Java::WekaCoreConverters::ConverterUtils::DataSource.new(filename).get_data_set | |
end | |
def normalize(data) | |
puts data.first.to_double_array.inspect | |
normalizer = Java::WekaFiltersUnsupervisedAttribute::Normalize.new |
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
;; Now I know what dense means :) | |
(defn neighbors | |
([size yx] (neighbors [[-1 0] [1 0] [0 -1] [0 1]] | |
size yx)) | |
([deltas size yx] | |
(filter (fn [new-yx] | |
(every? #(< -1 % size) new-yx)) | |
(map #(vec (map + yx %)) | |
deltas)))) |
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
# python manage.py shell | |
from polls.models import Poll, Choice | |
p = Poll.objects.all()[0] | |
import datettime | |
import random | |
def pick_random(choices): | |
rand_index = random.randint(0, len(choices) - 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
def done_remote(self, result): | |
remote_loc = result.split()[0] | |
repo_url = re.sub('^git(@|://)', 'http://', remote_loc) | |
# Replace the "tld:" with "tld/". See http://rubular.com/r/FK3w7CVnx5 | |
tld_pattern = r'\.(com|net|org|co\..{2}):' | |
repo_url = re.sub(tld_pattern, r'.\1/', repo_url) | |
repo_url = re.sub('\.git$', '', repo_url) | |
self.repo_url = repo_url |
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
stuff = (1..10).to_a | |
# => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
stuff = stuff.detect { |stuff| stuff.even? } ? stuff : 'none found' | |
#### Ruby 1.8 ####### | |
# => 2 | |
# So, #detect first runs, finds 2 and the result is reassigned into "stuff" | |
# the ternary operation follows, with "stuff" set to 2 |
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
-- Data from http://download.geonames.org/export/dump/ | |
-- More details at http://download.geonames.org/export/dump/readme.txt | |
-- Steps at https://gist.github.com/EspadaV8/1357237 | |
DROP TABLE geoname CASCADE; | |
CREATE TABLE geoname ( | |
geonameid INT, | |
name VARCHAR(200), | |
asciiname VARCHAR(200), |
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
ruby ./get_prices.rb And the Mountains Echoed | |
search for: And+the+Mountains+Echoed | |
flipkart: http://www.flipkart.com/search/a/all?query=And+the+Mountains+Echoed | |
ebay: http://search.ebay.in/And+the+Mountains+Echoed | |
junglee: http://www.junglee.com/mn/search/junglee?field-keywords=And+the+Mountains+Echoedinfibeam: http://www.infibeam.com/search?q=And+the+Mountains+Echoed | |
Aggregated reults: | |
store title price | |
========== ========================================================================================== =========== |
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
class ExampleControllerTest < Test::Unit | |
# setup etc. | |
test "something should do something" do | |
get :new | |
# assert something | |
end | |
# more tests | |
end |