This file contains hidden or 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
# quality of classification | |
from sklearn.metrics import accuracy_score | |
y_true = test['numeric_status'] | |
y_pred = result | |
print "Predicted accuracy: %f" % accuracy_score(y_true, y_pred) | |
# let's also calculate "baseline accuracy" - when we just say "yes" every time (most common outcome) | |
baseline = [1] * len(y_pred) | |
print "Baseline accuracy: %f" % accuracy_score(y_true, baseline) |
This file contains hidden or 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 A | |
class << self | |
def meth1 | |
print 'hi' | |
end | |
private | |
def meth2 | |
print 'hi1' |
This file contains hidden or 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
column 'Endret', sortable: 'reviews.updated_at' do |review| | |
html << pretty_format(review.updated_at) | |
unless review.moderations.last.nil? | |
updated_by = review.moderations.order('updated_at DESC').first.user.email.sub(/@.*/, '') | |
html << raw("<div class=\"toned-down\"><br>#{updated_by}</div>") | |
end | |
end |
This file contains hidden or 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
From adc62760f101717507e67fcc71f1b24731084963 Mon Sep 17 00:00:00 2001 | |
From: Ekaterina Krivich <[email protected]> | |
Date: Thu, 6 Nov 2014 11:37:15 +0300 | |
Subject: [PATCH] checking for SSL error | |
also previos version does not check errors at all | |
errors raised not at the moment object crated, | |
but when we have first usage: | |
not here service = ::Plugins::IPDBAtScraper.new(ip_address) | |
but here isp = service.isp |
This file contains hidden or 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
# | |
# ContsestContorller | |
# TODO: some ugly logic here, it's better to add it to Survey gem? | |
# | |
def show | |
q = survey.questions.first | |
@total_answers = Survey::Answer.where(question: q).count | |
@options_answers = [] | |
q.options.each do |o| | |
@options_answers << { count: Survey::Answer.where(question: q, option: o).count, text: o.text } |
This file contains hidden or 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 create | |
@question = Question.new(params[:question]) | |
// @conversation = Conversation.create | |
if @question.save | |
@message = current_user.send_message(@question, @question.question, "You have a question from #{@question.sender_id}") | |
//messages.new(:subject => "You have a question from #{@question.sender_id}", | |
// :notification_id => @question.sender_id, | |
// :receiver_id => @question.recipient_id, | |
// :conversation_id => @conversation.id, |
This file contains hidden or 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 'sinatra/base' | |
require 'sinatra/config_file' | |
require 'json' | |
class Npi < Sinatra::Base | |
register Sinatra::ConfigFile | |
config_file 'config.yml' | |
get '/npi/:npi' do | |
content_type :json |
This file contains hidden or 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
# app/views/some/actionhtml.haml | |
some content here |
This file contains hidden or 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 get_content_blocks | |
page_name = "#{params[:controller]}_#{params[:action]}" | |
page = Page.where(name: page_name).first.contents rescue [] | |
page.each { |obj| instance_variable_set("@"+obj.name, obj.body) } | |
end |
This file contains hidden or 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
{ | |
'А' => 'a', 'Б' => 'b', 'В' => 'v', 'Г' => 'g', 'Д' => 'd', 'Е' => 'e', 'Ё' => 'yo', 'Ж' => 'zh', 'З' => 'z', | |
'И' => 'i', 'Й' => 'j', 'К' => 'k', 'Л' => 'l', 'М' => 'm', 'Н' => 'n', 'О' => 'o', 'П' => 'p', 'Р' => 'r', | |
'С' => 's', 'Т' => 't', 'У' => 'u', 'Ф' => 'f', 'Х' => 'kh', 'Ц' => 'c', 'Ч' => 'ch', 'Ш' => 'sh', 'Щ' => 'shh', | |
'Ъ' => '', 'Ы' => 'y', 'Ь' => '', 'Э' => 'e', 'Ю' => 'yu', 'Я' => 'ya', | |
'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo', 'ж' => 'zh', 'з' => 'z', | |
'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', | |
'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'kh', 'ц' => 'c', 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'shh', | |
'ъ' => '', 'ы' => 'y', 'ь' => '', 'э' => 'e', 'ю' => 'yu', 'я' => 'ya', | |
}.map { |k, v| self.title_url.gsub!(k, v) } |