query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Never trust parameters from the scary internet, only allow the white list through.
def kpi_type_params params.require(:kpi_type).permit(:name,:code) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
SQL Studio puts bullshit characters into first column name
def clean_string s s.gsub(/\s/, "") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def column_name(column)\n tmp = ''\n column.name.gsub(/_/, ' ').gsub(/id/,\"\").split.each{|word| tmp += word.capitalize + ' '}\n return tmp\n end", "def column_name; end", "def default_column_prefix\n \"\"\n end", "def rails_column_name(column_name)\n column_name.underscore.gsub...
[ "0.67904806", "0.67714685", "0.66960335", "0.6689355", "0.6643317", "0.6585114", "0.6479279", "0.63700175", "0.6305285", "0.6278356", "0.62226486", "0.6221626", "0.6198898", "0.6172996", "0.6163289", "0.6159078", "0.6134138", "0.61275274", "0.6089388", "0.60751456", "0.60093"...
0.0
-1
add_suffix "somefile.xml", "_1234" => somefile_1234.xml""
def add_suffix filename, suffix parts = filename.split("\.") base = parts[0..-2] parts2 = base << suffix << parts[-1] fn = parts2.join(".") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_suffix\n file_name.split('.').last \n end", "def suffix(num)\n namespace + '_suffix_' + num.to_s\n end", "def suffix; end", "def suffix; end", "def suffix; end", "def suffix; end", "def suffix; end", "def formatted_filename(name, version, suffix, extension)\n name.gsub(\"#{vers...
[ "0.7029925", "0.6958982", "0.69057006", "0.69057006", "0.69057006", "0.69057006", "0.69057006", "0.67959976", "0.66103756", "0.655469", "0.6530568", "0.64537233", "0.6397378", "0.6339435", "0.630913", "0.61896306", "0.61211896", "0.611881", "0.609876", "0.59724325", "0.595064...
0.76751864
0
hash defines key => value for updating template
def replace_strings(str, rhash) s = str.to_s return s if ! (s && rhash) rhash.each do |k,v| s.gsub!(k.to_s, v.to_s) end s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def template_replace template, myhash\n #tmpltext=File::read(template);\n\n t = template.dup\n t.gsub!( /##(.*?)##/ ) {\n #raise \"Key '#{$1}' found in template but the value has not been set\" unless ( myhash.has_key?( $1 ) )\n myhash[ $1 ].to_s\n }\n t\n end", "def hash_template\n ...
[ "0.6947101", "0.6938895", "0.67419475", "0.6569435", "0.6507296", "0.63537", "0.6277459", "0.61571515", "0.61491185", "0.6125935", "0.61001676", "0.6075857", "0.606582", "0.6011686", "0.5998922", "0.5998922", "0.5947136", "0.59470016", "0.5946143", "0.5933196", "0.5919809", ...
0.0
-1
Subscribe for messages coming from Live Stream with name 'name' Each subscriber will receive a copy of messages flowing through the Live Stream
def message_from(name, options = {}, &block) receive_message_from name, options, &block end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subscribed\n stream_from channel_name\n end", "def subscribed\n \t#stream_from 'demo_chan'\n end", "def subscribed\n super\n increase_current_users\n stream_from channel\n end", "def subscribe\n debug [self.name, \"incoming\"]\n subscribe_request\n end", "def subscribe(name...
[ "0.7166819", "0.6991081", "0.6792625", "0.65793186", "0.6559165", "0.64436126", "0.63945264", "0.6386571", "0.63276446", "0.63206464", "0.63154405", "0.63038754", "0.6244479", "0.6235195", "0.6203951", "0.6202698", "0.61762524", "0.6153444", "0.61477673", "0.6132806", "0.6044...
0.0
-1
Subscribe for messages coming from cache of Live Stream with name 'name' The Live Stream will dispatch a message to the first ready subscriber in a roundrobin fashion.
def message_from_cache(name, options = {}, &block) options[:from_cache] = true receive_message_from name, options, &block end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subscriber(name)\n subscriber_name = \"#{@name}.#{name}\"\n @client.sadd @name, subscriber_name\n queue = ::Qup::Adapter::Redis::Queue.new(@uri, subscriber_name, @name)\n ::Qup::Subscriber.new( self, queue )\n end", "def subscribe(name, config = {})\n return if subscriptions.has_k...
[ "0.6611188", "0.65202487", "0.6279059", "0.6273242", "0.6239245", "0.59274143", "0.5902124", "0.58827585", "0.58807975", "0.5837619", "0.5830744", "0.5804832", "0.57631284", "0.57379323", "0.5686241", "0.5590389", "0.55828106", "0.5571048", "0.5568643", "0.55573237", "0.55169...
0.57253116
14
For a key :'foo.bar.baz' return ['foo', 'foo.bar', 'foo.bar.baz']
def expand_keys(key) key.to_s.split(FLATTEN_SEPARATOR).inject([]) do |keys, k| keys << [keys.last, k].compact.join(FLATTEN_SEPARATOR) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keys_for(key = EMPTY_STRING)\n key.split(NAMESPACE_PATTERN)\n end", "def keys_for(key = EMPTY_STRING)\n key.split(NAMESPACE_PATTERN)\n end", "def expand_key( key )\n ek = case key\n when Array\n key\n when /\\./\n key.split(\".\")\n else\n [ ...
[ "0.69623184", "0.69623184", "0.686235", "0.6850566", "0.6773774", "0.6711386", "0.658199", "0.6488892", "0.6447253", "0.64398766", "0.6357553", "0.63287884", "0.63220304", "0.63102543", "0.62830657", "0.6273429", "0.62575173", "0.62079704", "0.61721337", "0.61657137", "0.6161...
0.57886624
58
GET /audits GET /audits.json
def index @audits = Audit.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @audits = Audit.all\n respond_with @audits\n end", "def GetTicketAudits id,params = {}\n\n params = params.merge(path: \"tickets/#{id}/audits.json\")\n APICall(params)\n\n end", "def api_v11_audits_get(opts = {})\n api_v11_audits_get_with_http_info(opts)\n return...
[ "0.7364113", "0.72233295", "0.719439", "0.6943966", "0.6802076", "0.6756935", "0.670212", "0.6689906", "0.6683649", "0.6499298", "0.6444208", "0.62354165", "0.6169862", "0.6126515", "0.60289246", "0.6023746", "0.6009955", "0.59787846", "0.58859754", "0.5877257", "0.58609015",...
0.72450244
2
GET /audits/1 GET /audits/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @audits = Audit.all\n respond_with @audits\n end", "def index\n @audits = Audit.all\n end", "def index\n @audits = Audit.all\n end", "def new\n @audit = current_user.audits.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @aud...
[ "0.70631754", "0.69209284", "0.69209284", "0.6917547", "0.6843327", "0.67088115", "0.66736084", "0.6651741", "0.6501181", "0.6455143", "0.6343996", "0.62900674", "0.6148835", "0.6115155", "0.60926425", "0.6089214", "0.6001902", "0.6001902", "0.59414244", "0.58673716", "0.5820...
0.0
-1
POST /audits POST /audits.json
def create @audit = Audit.new(audit_params) respond_to do |format| if @audit.save format.html { redirect_to @audit, notice: 'Audit was successfully created.' } format.json { render :show, status: :created, location: @audit } else format.html { render :new } format.json { render json: @audit.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @audit = current_user.audits.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @audit }\n end\n end", "def create\n @audit = @project.audits.build(audit_params)\n\n respond_to do |format|\n if @audit.save\n format.html { redir...
[ "0.65188664", "0.6374931", "0.6218359", "0.6076659", "0.59978354", "0.5991787", "0.5988801", "0.5988801", "0.57903355", "0.56510735", "0.56487465", "0.5566443", "0.55445915", "0.5504159", "0.5500728", "0.55001765", "0.5450015", "0.54122585", "0.53990656", "0.5399045", "0.5379...
0.6010442
4
PATCH/PUT /audits/1 PATCH/PUT /audits/1.json
def update respond_to do |format| if @audit.update(audit_params) format.html { redirect_to @audit, notice: 'Audit was successfully updated.' } format.json { render :show, status: :ok, location: @audit } else format.html { render :edit } format.json { render json: @audit.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @recording = Recording.find(params[:id])\n\n respond_to do |format|\n if @recording.update_attributes(params[:recording])\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n end\n end\n end", "def update\n id = params[:id]\n...
[ "0.62754935", "0.61398065", "0.61359316", "0.6010058", "0.59871", "0.5985566", "0.59275275", "0.58998513", "0.58940655", "0.58903617", "0.5878485", "0.5874587", "0.58714235", "0.5835737", "0.5824104", "0.5819092", "0.5807568", "0.57836604", "0.5762287", "0.57359064", "0.57198...
0.651764
0
DELETE /audits/1 DELETE /audits/1.json
def destroy @audit.destroy respond_to do |format| format.html { redirect_to audits_url, notice: 'Audit was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n \n @audit = current_user.audits.find(params[:id])\n @audit.destroy\n \n UserMailer.audit_deleted_auditor(@audit,current_user).deliver\n UserMailer.audit_deleted_auditee(@audit,current_user).deliver\n respond_to do |format|\n format.html { redirect_to audits_url }\n format....
[ "0.7506409", "0.72189516", "0.69374704", "0.6898264", "0.6835532", "0.67364204", "0.67183477", "0.67174584", "0.6707446", "0.6698856", "0.66728926", "0.66654", "0.66302913", "0.66241074", "0.65913737", "0.65548253", "0.6525144", "0.65009105", "0.6457753", "0.644951", "0.64312...
0.7294166
1
Use callbacks to share common setup or constraints between actions.
def set_audit @audit = Audit.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def audit_params params.require(:audit).permit(:user_id, :mod_action_id, :obj_id, :interactionDate) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
we receive a request: GET /questions/56 params[:id] will be '56'
def show @answer = Answer.new respond_to do |format| format.html {render} # render questions/show.html.erb format.json {render json: @question.to_json} format.xml {render xml: @question.to_xml} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_question\n\t\t@question = Question.where(id:params[:id])[0]\n\t\trender json: {success: false, message: 'Invalid Question ID !'}, status: 400 if @question.nil?\n\tend", "def question_by_id(id)\n\t\t\t\tbegin \n\t\t\t\t\tquestion = Question.find(id)\n\t\t\t\trescue ActiveRecord::RecordNotFound\n\t\t\t\t\...
[ "0.667184", "0.6616867", "0.6544606", "0.653479", "0.651962", "0.6417866", "0.6400528", "0.63655317", "0.63566685", "0.63515216", "0.6319808", "0.63007754", "0.62128717", "0.61836505", "0.61555564", "0.6148156", "0.6144812", "0.6103929", "0.6068086", "0.60625094", "0.6035445"...
0.0
-1
Renders a notification field for a Redmine::Notifiable option
def notification_field(notifiable) tag_data = if notifiable.parent.present? {:parent_notifiable => notifiable.parent} else {:disables => "input[data-parent-notifiable=#{notifiable.name}]"} end tag = check_box_tag('settings[notified_events][]', notifiable.name, setting_value('notified_events').include?(notifiable.name), :id => nil, :data => tag_data) text = l_or_humanize(notifiable.name, :prefix => 'label_') options = {} if notifiable.parent.present? options[:class] = "parent" end content_tag(:label, tag + text, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def notification_text(notification)\n notifiable = notification.notifiable\n text = if notification.medium?\n t('notifications.new_medium')\n elsif notification.course?\n course_notification_card_text(notifiable)\n elsif notification.lecture?\n lecture_...
[ "0.6050053", "0.5751158", "0.5661299", "0.55503964", "0.55464524", "0.5511461", "0.5509745", "0.54960275", "0.54883045", "0.54687226", "0.54348433", "0.54084367", "0.54008037", "0.53999835", "0.53223747", "0.52933663", "0.52825105", "0.52367043", "0.52354634", "0.52270263", "...
0.7223191
0
Returns the options for the date_format setting
def date_format_setting_options(locale) Setting::DATE_FORMATS.map do |f| today = ::I18n.l(User.current.today, :locale => locale, :format => f) format = f.delete('%').gsub(/[dmY]/) do {'d' => 'dd', 'm' => 'mm', 'Y' => 'yyyy'}[$&] end ["#{today} (#{format})", f] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def date_format_options\n DATE_FORMATS.collect {|f| [\"#{Date.today.strftime(f)} - #{f}\", f]}\n end", "def default_options_date_format(format)\n format || '%Y-%m-%d - %l:%M:%S%p'\n end", "def date_format\n return @date_format\n end", "def datepicker_options(format, valu...
[ "0.8548332", "0.77671754", "0.72053105", "0.71642554", "0.6801605", "0.6669466", "0.6666883", "0.6627941", "0.66279304", "0.65945774", "0.6588877", "0.6540272", "0.6439241", "0.6423599", "0.6423166", "0.63802356", "0.6343782", "0.63327307", "0.63242227", "0.63144076", "0.6295...
0.7815651
1
GET /orf_models/1 GET /orf_models/1.json
def show @orf_model = OrfModel.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @orf_model } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def model\r\n\t\t\t@model ||= json['model']\r\n\t\tend", "def index\n @oid_models = OidModel.all\n end", "def get_model\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/response/model'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepar...
[ "0.65786946", "0.6238855", "0.61046416", "0.6029444", "0.60079145", "0.59760475", "0.59760475", "0.59065425", "0.59057623", "0.58922684", "0.5887183", "0.5846745", "0.5807929", "0.5745284", "0.57041675", "0.56968236", "0.5691075", "0.5687457", "0.56665486", "0.56414896", "0.5...
0.7106116
0
This method is called when the form containing the search parameters is submitted. It saves the search parameters in a cookie for use in paging.
def create admin_last_url cookies[:product_search] = {:value => YAML::dump(params[:product_search]), :path => admin_product_search_path} logger.info "Admin::ProductSearchesController#create params=#{params[:product_search]}" do_search params[:product_search] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @search = Product.search(params[:q])\n \n if params[:q].present?\n cookies.permanent.signed[:search_keyword] = {\n value: params[:q]\n }\n else\n cookies.permanent.signed[:search_keyword] = {\n value: \"\"\n }\n end\n @products = @search.result\n @s...
[ "0.6593286", "0.6562131", "0.65237576", "0.6464136", "0.6346279", "0.63273585", "0.6295499", "0.6275071", "0.62446964", "0.61636", "0.6052698", "0.601004", "0.59869725", "0.5979788", "0.5943326", "0.5943326", "0.5883371", "0.57890505", "0.5781959", "0.5779849", "0.57701564", ...
0.6161681
10
This method is called only through "will_paginate" to get the indicated page of search results.
def show admin_last_url search_params = YAML::load(cookies[:product_search]) search_params[:page] = params[:page] do_search search_params end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_search\n if self.class == Alchemy::Admin::PagesController && params[:query].blank?\n params[:query] = 'lorem'\n end\n return if params[:query].blank?\n @search_results = search_results\n if paginate_per\n @search_results = @search_results.page(params...
[ "0.7311441", "0.66956997", "0.66386884", "0.66051054", "0.6562758", "0.6500251", "0.6445051", "0.6438352", "0.6436384", "0.64190847", "0.6402931", "0.63792646", "0.63735193", "0.6367329", "0.6364901", "0.6364477", "0.6353947", "0.6351873", "0.6350624", "0.63218665", "0.629763...
0.59201455
80
Use callbacks to share common setup or constraints between actions.
def set_admin_message @admin_message = AdminMessage.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a trusted parameter "white list" through.
def admin_message_params params.require(:admin_message).permit(:from_name, :from_email, :content) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
The method should return a boolean indicating whether or not the sentences consist of the same exact words, but not necessarily in the same order. Your solution should have a linear O(n) runtime, where n is the combined length of the input strings. Scoring: 8 points maximum 4 points awarded for passing all test cases 4 points awarded for linear runtime This component of the assessment is estimated to take 10 minutes.
def savvy_shuffled_sentence(s1,s2) hash1,hash2 = Hash.new(0),Hash.new(0) s1.split(' ').each {|word| hash1[word] += 1} s2.split(' ').each {|word| hash2[word] += 1} hash1 == hash2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def step_through_with(s)i\n # It doesn't solve the kata because it returns true even if same chars are met in diffrent part of the word. Like \"ThaT\"\n s.chars.count == s.chars.uniq.count\nend", "def common_substrings(string1, string2)\n string2.downcase.chars.each do |char|\n return false if string2....
[ "0.69401675", "0.6727691", "0.6596002", "0.658769", "0.65419126", "0.6508416", "0.6435602", "0.64097345", "0.64027095", "0.6395559", "0.63883406", "0.6387713", "0.6381688", "0.6365369", "0.63397217", "0.63150173", "0.63077605", "0.6295656", "0.628425", "0.6275146", "0.6269561...
0.6578527
4
Called before a task is created, sends a request to the Scale API
def create_task #Assign url url="https://api.scaleapi.com/v1/task/phonecall" #Auth credentials setup auth = {:username=>ENV["SCALE_API_KEY"], :password=>""} #Assign headers headers = {"Content-Type"=>"application/json"} #Create payload params = {callback_url: 'https://mysterious-ridge-35983.herokuapp.com/survey_callback', instruction: "Call this person and ask him his calorie counts for yesterday and the number of coffees he drank. Then, ask him if he took his morning and evening medications.", script: "Hey! (pause) How many calories did you eat yesterday? (pause) What about protein grams (pause)?"\ " What about carbohydrate grams (pause)? What about fat grams (pause)? What about fiber grams (pause)?"\ " How many coffees did you drink (pause)? Did your take your morning and evening meds (pause)?", phone_number: ENV["PHONE_NUMBER"], entity_name: ENV["OWNER_NAME"], fields: { total_calories: 'Total Calories', protein_grams: 'Protein Grams', carbohydrate_grams: 'Carbohydrate Grams', fiber_grams: 'Fiber Grams', fat_grams: 'Fat Grams', number_of_coffees: 'Coffees per Day'}, urgency: "immediate", choices: ['only_took_morning_meds', 'only_took_evening_meds', 'took_both_morning_and_evening','no_meds_taken']} #Send request begin request=HTTParty.post(url,:basic_auth=>auth, :headers=> headers, :body=>params.to_json) #Receive request and store response self.scale_api_id=request["task_id"] self.json_data=JSON.dump(request) rescue #If there's an error, raise an exception to prevent DailySurvey object being created raise "Bad Scale API request" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n GpsJob.perform_later(request_params)\n head(:ok)\n end", "def tasks\n uri = URI(BASE_URL + TASKS_ENDPOINT)\n\n make_request(uri)\n end", "def create\n @task = Task.new(task_state: TaskState.where(name: \"Pending\")[0] )\n\n if params[:all]\n # get task IDs from system, map...
[ "0.6006873", "0.596223", "0.5961344", "0.5896093", "0.58250946", "0.5758471", "0.575588", "0.5752058", "0.5737704", "0.5719859", "0.57064813", "0.5706156", "0.57034546", "0.5687715", "0.56832296", "0.5666971", "0.5622342", "0.56175256", "0.56154364", "0.55883", "0.55785984", ...
0.6873843
0
Parse callback from Scale on the survey and assign response to a model
def parse_response(response) if response["outcome"]=="success" #Assign calorie counts and grams breakdown self.total_calories=response["fields"]["total_calories"].to_i self.protein_grams=response["fields"]["total_calories"].to_i self.fat_grams=response["fields"]["fat_grams"].to_i self.carbohydrate_grams=response["fields"]["carbohydrate_grams"].to_i self.fiber_grams=response["fields"]["fiber_grams"].to_i #Number of coffees self.number_of_coffees=response["fields"]["number_of_coffees"].to_i #Assign medications based on response if response["choice"]=='only_took_morning_meds' self.morning_medications=true self.evening_medications=false elsif response["choice"]=='only_took_evening_meds' self.morning_medications=false self.evening_medications=true elsif response["choice"]=='took_both_morning_and_evening' self.morning_medications=true self.evening_medications=true else self.morning_medications=false self.evening_medications=false end self.save else raise "Bad Scale API callback data" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(savon_response)\n new(savon_response)\n end", "def parse(savon_response)\n response = new(savon_response)\n response.raw[\"#{key}_response\".to_sym][\"#{key}_result\".to_sym][:response_type]\n end", "def set_survey_response\n @survey_response = SurveyRespon...
[ "0.5876006", "0.5854425", "0.58517605", "0.5786045", "0.5706179", "0.5706179", "0.5706179", "0.5706179", "0.5638147", "0.5517288", "0.54785043", "0.54246616", "0.5389937", "0.5389937", "0.5389937", "0.53821015", "0.5318267", "0.53106934", "0.53016645", "0.52799904", "0.526871...
0.64945865
0
Return daily ratios of calories
def macro_percentages if self.total_calories!=nil and self.protein_grams != nil and self.carbohydrate_grams!=nil and self.fat_grams!=nil return {:protein=>protein_grams.to_f/total_calories, :carbohydrate => carbohydrate_grams.to_f/total_calories, :fat=> fat_grams.to_f/total_calories} end return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def daily_rate\n yearly_rate / 365\n end", "def daily_rate\n\t\t yearly_rate / 365\n\t\t end", "def daily_interest\n @apr / 100.0 / 365\n end", "def calorie_sum_by_day\n\n end", "def rates_per_day\n @rates_per_day ||= raw_fx_rates['Cube'][0]['Cube']\n end", "def total\n number...
[ "0.7035991", "0.68995506", "0.6670552", "0.66185725", "0.6554045", "0.64075446", "0.63313407", "0.6307545", "0.62790525", "0.6260448", "0.6237834", "0.62094015", "0.6197452", "0.61426365", "0.613566", "0.6112865", "0.61052215", "0.6089164", "0.60696054", "0.60365486", "0.6003...
0.0
-1
execute a command against a remote windows machine using psexec
def psexec(host, command) exec = "psexec \\\\#{Array(host).join ','}" if @options[:user] exec << " -u \"#{@options[:user]}\"" @options[:password] = ask("--> Enter password for #{@options[:user]}@#{host}: ") {|q| q.echo = '*'} unless @options[:password] exec << " -p \"#{@options[:password]}\"" end exec << " /accepteula" exec << " cmd /c \"#{command}\"" exec << ' > NUL 2>&1' unless logger.debug? logger.debug "--> #{exec}" system exec raise "Failed to execute command \"#{command}\" on host: #{host}" if $?.to_i != 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execute_interactively(host, command)\n user = host.user\n hostname = host.hostname\n port = host.port || 22\n\n # execute in shell\n exec \"ssh -l #{user} #{hostname} -p #{port} -t '#{command}'\"\nend", "def execute_ssh_command(command)\n\t\tresult = ''\n\t\tNet::SSH.start(ip_string, settings.ss...
[ "0.6539553", "0.64589566", "0.64333165", "0.641589", "0.63199073", "0.63082355", "0.6295611", "0.6227712", "0.6208858", "0.6194346", "0.6190223", "0.6181252", "0.6148918", "0.6134624", "0.6109485", "0.61044806", "0.6086549", "0.607344", "0.60497504", "0.6021373", "0.60177416"...
0.7518728
0
Returns true when students are part of this section
def has_students? !students.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def coaches_student?(student)\n\t\tstudents.include?(student)\n\tend", "def sections?\n false\n end", "def student?\n if self.role and self.role == 4 \n true\n end\n end", "def student?\n return self.eduPersonAffiliation==\"student\"\n end", "def student?\n false\n end", "def ...
[ "0.72400045", "0.7115896", "0.6895543", "0.68816954", "0.68450016", "0.6843175", "0.68228024", "0.67637867", "0.67336667", "0.67146975", "0.6714005", "0.6713313", "0.6709402", "0.6682034", "0.6669727", "0.66680026", "0.66568124", "0.66251636", "0.6569253", "0.65572023", "0.65...
0.68111396
8
returns the number of students in this section
def count_students students.size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_students\n self.students.count\n end", "def num_grades (student)\n @grades[student].length\n end", "def active_student_count\n if self.students.present?\n self.students.select { |s| s.sign_in_count > 0 }.size\n else\n 0\n end\n end", "def total_students\n students...
[ "0.7621935", "0.75866854", "0.72421867", "0.7111609", "0.69339824", "0.68719083", "0.68649083", "0.6856613", "0.679039", "0.66600674", "0.6588708", "0.6538169", "0.65213126", "0.6463719", "0.63386285", "0.6333991", "0.62659514", "0.62336826", "0.6223881", "0.61278695", "0.611...
0.78057146
1
Calculate the checksum from the page (or the pre packed data) If data it supplied it will be updated to record the checksum value
def compute_checksum(data_) data = data_.dup data[22..25] = [0].pack("V") crc = 0 data.each_byte do |byte| crc = (crc << 8)^CHECKSUM_TABLE[((crc >> 24)&0xff) ^ byte] crc = crc & 0xffffffff end crc end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calc_checksum\n # Checksum is only on header, so cannot use IP.sum16,\n # which also calculates checksum on #body.\n nb_words = ihl * 2\n self.checksum = 0\n checksum = to_s.unpack(\"n#{nb_words}\").sum\n self[:checksum].value = IP.reduce_checksum(checksum)\n end"...
[ "0.70415354", "0.69379395", "0.6750849", "0.65638494", "0.65250707", "0.6514308", "0.6493108", "0.64663786", "0.64663786", "0.64651674", "0.643656", "0.64114666", "0.64114666", "0.6371721", "0.6342957", "0.63137287", "0.6259493", "0.623863", "0.62170446", "0.61951697", "0.614...
0.6949942
1
GET /mergegraphs/1 GET /mergegraphs/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @mergegraph = Admin::Mergegraph.new(mergegraph_params)\n\n respond_to do |format|\n if @mergegraph.save\n format.html { redirect_to @mergegraph, notice: 'Mergegraph was successfully created.' }\n format.json { render action: 'show', status: :created, location: @mergegraph }\n ...
[ "0.64456177", "0.62740463", "0.62140226", "0.62084645", "0.6010337", "0.589591", "0.5892351", "0.58152014", "0.5772294", "0.56784415", "0.5654116", "0.5653906", "0.56126606", "0.54976624", "0.54972005", "0.5455182", "0.5449849", "0.54205143", "0.5407079", "0.5405673", "0.5378...
0.0
-1
POST /mergegraphs POST /mergegraphs.json
def create @mergegraph = Admin::Mergegraph.new(mergegraph_params) respond_to do |format| if @mergegraph.save format.html { redirect_to @mergegraph, notice: 'Mergegraph was successfully created.' } format.json { render action: 'show', status: :created, location: @mergegraph } else @merge = Admin::Merge.find(@mergegraph.merge_id) format.html { render action: 'new' } format.json { render json: @mergegraph.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mergegraph_params\n params.require(:admin_mergegraph).permit(:merge_id, :graph_id, :side, :y, :vieworder)\n end", "def create\n @graph = Graph.new(params[:graph])\n\n respond_to do |format|\n if @graph.save\n Action.log :controller => params[:controller], :action => params[:action],...
[ "0.6566948", "0.6156067", "0.6021743", "0.57612205", "0.56907773", "0.5583179", "0.5575224", "0.5553395", "0.5533411", "0.5502257", "0.5488648", "0.5474937", "0.5474751", "0.5455107", "0.53372693", "0.5304352", "0.53030854", "0.5257971", "0.5254713", "0.5199494", "0.5150038",...
0.7047132
0
PATCH/PUT /mergegraphs/1 PATCH/PUT /mergegraphs/1.json
def update respond_to do |format| if @mergegraph.update(mergegraph_params) format.html { redirect_to @mergegraph, notice: 'Mergegraph was successfully updated.' } format.json { head :no_content } else @merge = Admin::Merge.find(@mergegraph.merge_id) format.html { render action: 'edit' } format.json { render json: @mergegraph.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @graph = Graph.includes(:nodes).find(params[:id])\n\n respond_to do |format|\n if @graph.update_attributes(params[:graph])\n Action.log :controller => params[:controller], :action => params[:action], :target_id => params[:id], :user => current_user\n format.html { redirect_to ...
[ "0.64218163", "0.64172655", "0.6268077", "0.6160597", "0.6127228", "0.60015076", "0.599179", "0.59568465", "0.59373266", "0.5828153", "0.5791312", "0.5738112", "0.5738001", "0.57048553", "0.57011706", "0.56929356", "0.5603972", "0.5590948", "0.5532756", "0.55309254", "0.54936...
0.710164
0
DELETE /mergegraphs/1 DELETE /mergegraphs/1.json
def destroy @mergegraph.destroy respond_to do |format| format.html { redirect_to admin_mergegraph_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @graph.destroy\n\n respond_to do |format|\n format.html { redirect_to graphs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @graph.destroy\n respond_to do |format|\n format.html { redirect_to graphs_url }\n format.json { head :no_content }\...
[ "0.70091116", "0.69834864", "0.68997496", "0.68341494", "0.6780763", "0.6780763", "0.6719513", "0.67140996", "0.6644761", "0.66418374", "0.6597057", "0.6595819", "0.65829927", "0.6466911", "0.6449677", "0.6436914", "0.6348817", "0.6288825", "0.6287741", "0.6237578", "0.621974...
0.7861553
0
Use callbacks to share common setup or constraints between actions.
def set_mergegraph @mergegraph = Admin::Mergegraph.find(params[:id]) merge_id = @mergegraph.merge_id @merge = Admin::Merge.find(merge_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def mergegraph_params params.require(:admin_mergegraph).permit(:merge_id, :graph_id, :side, :y, :vieworder) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
initialize as the function that "boots up" each object the class creates.
def initialize(name, age) # we use @ before a variable to signify that # it's an instance variable @name = name @age = age @@people_count += 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def boot_classes!\n # very fiddly chicken 'n egg problem. Functions need to be in the right order, and in fact we have to define some \n # dummies, just for the other to compile\n obj = get_or_create_class :Object\n [:index_of , :_get_instance_variable , :_set_instance_variable].each do |f|\n ...
[ "0.72306347", "0.7181746", "0.69755507", "0.69755507", "0.6959519", "0.69363785", "0.69121456", "0.6910568", "0.68861943", "0.68861943", "0.68861943", "0.68861943", "0.6863431", "0.685854", "0.68149334", "0.67215294", "0.67215294", "0.67215294", "0.67088175", "0.6700901", "0....
0.0
-1
Redefines an object's method with a Command of the same name.
def redefine_command(obj, command) cmd_block = redefine_command_block(obj, command) @no_option_commands << command if command.options.nil? [command.name, command.alias].compact.each {|e| obj.singleton_class.send(:define_method, e, cmd_block) } rescue Error warn "Error: #{$!.message}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def redefine_command(obj, command)\n cmd_block = redefine_command_block(obj, command)\n @no_option_commands << command if command.options.nil?\n [command.name, command.alias].compact.each {|e|\n obj.instance_eval(\"class<<self;self;end\").send(:define_method, e, cmd_block)\n }\n end",...
[ "0.8310975", "0.7890691", "0.6899113", "0.66847795", "0.6453737", "0.641819", "0.6383475", "0.6363545", "0.6350759", "0.6343646", "0.62662417", "0.62594396", "0.6251353", "0.62326586", "0.62326586", "0.62326586", "0.62010646", "0.6198705", "0.61512995", "0.6123135", "0.612167...
0.81944
1
The actual method which redefines a command's original method
def redefine_command_block(obj, command) object_methods(obj)[command.name] ||= begin obj.method(command.name) rescue NameError raise Error, "No method exists to redefine command '#{command.name}'." end lambda {|*args| Scientist.analyze(obj, command, args) {|args| Scientist.object_methods(obj)[command.name].call(*args) } } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_original_commands; end", "def add_original_commands\n end", "def supercommand!() __supercommand__ end", "def original_run_command; end", "def original_method; end", "def redefine_command(obj, command)\n cmd_block = redefine_command_block(obj, command)\n @no_option_commands << command i...
[ "0.78605133", "0.7667384", "0.7453307", "0.72344786", "0.70955473", "0.7014593", "0.70133823", "0.69590515", "0.6937103", "0.67832106", "0.67799205", "0.671952", "0.671952", "0.671952", "0.671952", "0.671952", "0.671952", "0.6597022", "0.6586141", "0.6555429", "0.6534272", ...
0.70384467
5
Returns hash of methods for an object
def object_methods(obj) @object_methods[obj] ||= {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash #:nodoc:\n __getobj__.hash ^ self.class.hash\n end", "def to_hash\n ret = {}\n \n self.methods.select{ |it| it.id2name[-1] == '=' and !['==', '!='].include?(it.id2name) }.each do |method|\n name = method.id2name.gsub('=', '')\n \n ...
[ "0.70811844", "0.6702198", "0.6667372", "0.6595375", "0.6525205", "0.65250003", "0.6520784", "0.64524466", "0.64524466", "0.64524466", "0.64524466", "0.64524466", "0.64524466", "0.64524466", "0.64149994", "0.64149994", "0.64149994", "0.64149994", "0.64149994", "0.64149994", "...
0.67921484
1
option command for given command
def option_command(cmd=@command) @option_commands[cmd] ||= OptionCommand.new(cmd) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def command\n return @command if !@opt_set && @command\n @opt_set = false\n @command = [@binary, options]\n end", "def option(option)\n \"--\" << option.to_s.gsub('_', '-')\n end", "def command\n return \"#{@command} #{options}\"\n end", "def treat_as_option doption\n o...
[ "0.7271766", "0.71792614", "0.7144048", "0.7092695", "0.7064922", "0.7041221", "0.7025596", "0.7024947", "0.6922264", "0.6918408", "0.69139236", "0.6825444", "0.6771537", "0.6750897", "0.66939247", "0.66923183", "0.6692272", "0.6679929", "0.6652789", "0.6635822", "0.66274226"...
0.8038478
0
Runs a command given its object and arguments
def analyze(obj, command, args, &block) @global_options, @command, @original_args = {}, command, args.dup @args = translate_args(obj, args) return run_help_option(@command) if @global_options[:help] during_analyze(&block) rescue OptionParser::Error, Error raise if Boson.in_shell warn "Error: #{$!}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(command, *args)\n send(command, *args)\n end", "def run( args )\n args = args.dup\n\n parse args\n init args\n self.__send__(*@command)\n end", "def cmd(*args) self.class.cmd(*args) end", "def execute(command_args)\n command_args = split_command(command_args)\n command = comm...
[ "0.75068367", "0.72298723", "0.72270304", "0.7074162", "0.7067062", "0.7045217", "0.7037785", "0.7017059", "0.69880724", "0.6975897", "0.6846388", "0.68084484", "0.68076754", "0.68017644", "0.67384285", "0.67370963", "0.6680271", "0.66713476", "0.6655561", "0.66397613", "0.66...
0.0
-1
Overridable method called during analyze
def during_analyze(&block) process_result call_original_command(@args, &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auto_analyze; end", "def auto_analyze=(_arg0); end", "def analyze\n analysis = self.class.analysis\n raise unless analysis\n\n analysis.call(@params)\n end", "def diagnostics; end", "def diagnostics; end", "def diagnostics; end", "def diagnostics; end", "def analyze\n ...
[ "0.7510012", "0.70198274", "0.65513736", "0.6463264", "0.6463264", "0.6463264", "0.6463264", "0.6463193", "0.6443608", "0.6443608", "0.6443608", "0.6443608", "0.6443608", "0.6443608", "0.6443608", "0.6443608", "0.6443608", "0.6443608", "0.6443608", "0.6235614", "0.6234241", ...
0.0
-1
Hook method available after parse in translate_args
def after_parse; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate(*args, **opts); end", "def _lex_trans_targs=(_arg0); end", "def _lex_trans_targs=(_arg0); end", "def _lex_trans_targs=(_arg0); end", "def _lex_trans_targs=(_arg0); end", "def translate(args)\n Config.instance.translate(args.first)\n end", "def _lex_trans_targs; end", "def _lex_t...
[ "0.7090619", "0.6694957", "0.6694957", "0.6694957", "0.6694957", "0.6655081", "0.6643141", "0.6643141", "0.6643141", "0.6643141", "0.63690126", "0.63519883", "0.6217786", "0.6217786", "0.6217786", "0.6217786", "0.6203082", "0.6203082", "0.6203082", "0.617942", "0.61665577", ...
0.5716089
54
def sync_roles if abstract? sync ALL concrete roles abstract_role_permissions = Permission.where(role_id: id) Role.all.each do |role| sync_one(abstract_role_permissions, role) end else sync only current concrete roles abstract_role_permissions = Permission.where(role_id: Role.abstract.id) sync_one(abstract_role_permissions, self) end end
def duplicate n = "#{self.name} copy" while !(r = Role.find_by(name: n)).nil? n = SecureRandom.hex.first(6) end c = n.parameterize.underscore r = Role.create(name: n, code: c, description: "-- Copy of #{self.description}") Permission.all.each do |perm| bool = PermissionRole.find_by(role: self, permission: perm)&.permitted || false PermissionRole.create(role: r, permission: perm, permitted: bool) end r end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_permissions\n return permissions unless role\n (permissions + role.permissions).uniq\n end", "def sync_cluster_role\n save_cluster_general_data\n end", "def setup_role \n if self.role_ids.empty? \n self.role_ids = [Role.find_by_name(\"User\").id] \n end\n end", "def han...
[ "0.58430797", "0.5827227", "0.5648994", "0.5558113", "0.5558113", "0.5474935", "0.54747057", "0.54578495", "0.5399092", "0.53843355", "0.53801304", "0.5377019", "0.5375818", "0.5374203", "0.5360095", "0.53585774", "0.5342192", "0.53239864", "0.5293868", "0.5275154", "0.527515...
0.0
-1
A name is valid is if satisfies all of the following: contains at least a first name and last name, separated by spaces each part of the name should be capitalized Hint: use str.upcase or str.downcase "a".upcase => "A"
def is_valid_name(str) str_arr = str.split check = [] str_arr.each do |ele| formatted = ele[0].upcase + ele[1..-1].downcase check << formatted end if check.length < 2 || check.join(" ") != str return false else return true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_valid_name(str)\n split_name = str.split(' ')\n\n first_and_last_name = split_name.length > 1; # Has a first and last name ?\n capitalized = true; # Each part of the name is properly capitalized ?\n\n split_name.each do | word |\n capitalized = word[0] == word[0].upcase && word[1..-1] == word[1..-1]....
[ "0.8481082", "0.786001", "0.783987", "0.77975756", "0.77851516", "0.77706265", "0.7735286", "0.7680342", "0.76645744", "0.7569165", "0.7556697", "0.7246888", "0.7231729", "0.7164296", "0.71579325", "0.71579325", "0.7156234", "0.70890385", "0.7019955", "0.7015272", "0.6993298"...
0.80682504
1
AUTHORIZATION / LOGIN / LOGOUT
def tumblr_authorized? !!(session[:tumblr_oauth_token] && session[:tumblr_oauth_token_secret]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_out\n\t\tsession.delete(:authorization)\n\tend", "def authenticate\n begin\n if !session[:user_guid]\n redirect_to(root_path)\n elsif session[:user_guid] != User.find_by(id: session[:user_id].to_i).guid\n redirect_to(logout_user_path)\n end\n rescue\n redirect_to(l...
[ "0.68827647", "0.68454933", "0.6782965", "0.67743105", "0.6773835", "0.6763406", "0.6730516", "0.6725961", "0.67240626", "0.67223334", "0.67223334", "0.67195123", "0.6710257", "0.6710257", "0.6659332", "0.6659332", "0.6659332", "0.6659332", "0.6659332", "0.6659332", "0.665933...
0.0
-1
====================================================== Public: create a new promotion params: in hash format, from the top to the bottom/from left to right |description|promo code|discount type|discount value|valid from|Monthly|1 Year|2 Year|through|COM|UK|IE|FR|DE|code usage limit|valid on renewal| return: None ======================================================
def new_promotion(hashes) log('set description') unless hashes['description'].nil? log('[Decription] is ' + hashes['description']) promp_description.type_text(hashes['description']); end log('set prom code') unless hashes['promo code'].nil? log('[Promo Code] is ' + hashes['promo code']) promo_code.type_text(hashes['promo code']) end log('set discounts type') unless hashes['discount type'].nil? log('[Discount Type] is ' + hashes['discount type']) promo_discount_type.select(hashes['discount type']) end log('set discounts value') unless hashes['discount value'].nil? log('[Discount Value] is - ' + hashes['discount value']) promo_discount_value.type_text(hashes['discount value']) end log('set valid from') unless hashes['valid from'].nil? log('[Discount Value] is - ' + hashes['valid from']) promo_eff_date.type_text(hashes['valid from']) end log('set good for product(s)/subscription(s) - Monthly') if hashes['Monthly'] == 'Yes' log('[Monthly] is - ' + hashes['Monthly'] + ' , [Monthly] is checked.') promo_subscription_Monthly.set(true) elsif hashes['Monthly'] == 'No' log('[Monthly] is - ' + hashes['Monthly'] + ' , [Monthly] is unchecked.') promo_subscription_Monthly.set(false) else log('[Monthly] is by default.') end log('set good for product(s)/subscription(s) - 1 Year') if hashes['1 Year'] == 'Yes' log('[1 Year] is - ' + hashes['1 Year'] + ' , [1 Year] is checked.') promo_subscription_1_Year.set(true) elsif hashes['1 Year'] == 'No' log('[1 Year] is - ' + hashes['1 Year'] + ' , [1 Year] is unchecked.') promo_subscription_1_Year.set(false) else log('[1 Year] is by default.') end log('set good for product(s)/subscription(s) - 2 Year') if hashes['2 Year'] == 'Yes' log('[2 Year] is - ' + hashes['2 Year'] + ' , [2 Year] is checked.') promo_subscription_2_Year.set(true) elsif hashes['2 Year'] == 'No' log('[2 Year] is - ' + hashes['2 Year'] + ' , [2 Year] is unchecked.') promo_subscription_2_Year.set(false) else log('[2 Year] is by default.') end log('set through') unless hashes['through'].nil? log('[through] is - ' + hashes['through']) promo_expire_date.type_text(hashes['through']) end log('set good for domain(s) - COM') if hashes['COM'] == 'Yes' log('[COM] is - ' + hashes['COM'] + ' , [COM] is checked.') promo_valid_domains_COM.set(true) elsif hashes['COM'] == 'No' log('LogQA: [COM] is - ' + hashes['COM'] + ' , [COM] is unchecked.') promo_valid_domains_COM.set(false) else log('LogQA: [COM] is by default.') end log('LogQA: set good for domain(s) - UK') if hashes['UK'] == 'Yes' log('[UK] is - ' + hashes['UK'] + ' , [UK] is checked.') promo_valid_domains_UK.set(true) elsif hashes['UK'] == 'No' log('[UK] is - ' + hashes['UK'] + ' , [UK] is unchecked.') promo_valid_domains_UK.set(false) else log('[UK] is by default.') end log('set good for domain(s) - IE') if hashes['IE'] == 'Yes' log('[IE] is - ' + hashes['IE'] + ' , [IE] is checked.') promo_valid_domains_IE.set(true) elsif hashes['IE'] == 'No' log('[IE] is - ' + hashes['IE'] + ' , [IE] is unchecked.') promo_valid_domains_IE.set(false) else log('[IE] is by default.') end log('set good for domain(s) - FR') if hashes['FR'] == 'Yes' log('[FR] is - ' + hashes['FR'] + ' , [FR] is checked.') promo_valid_domains_FR.set(true) elsif hashes['FR'] == 'No' log('[FR] is - ' + hashes['FR'] + ' , [FR] is unchecked.') promo_valid_domains_FR.set(false) else log('[FR] is by default.') end log('set good for domain(s) - DE') if hashes['DE'] == 'Yes' log('[DE] is - ' + hashes['DE'] + ' , [DE] is checked.') promo_valid_domains_DE.set(true) elsif hashes['DE'] == 'No' log('[DE] is - ' + hashes['DE'] + ' , [DE] is unchecked.') promo_valid_domains_DE.set(false) else log('[DE] is by default.') end log('set code useage limit') unless hashes['code usage limit'].nil? log('[Code usage limit] is ' + hashes['code usage limit']) promo_times.type_text(hashes['code usage limit']) end log('set valid no renewal') if hashes['valid on renewal'] == 'Yes' log('[Valid on renewal] is - ' + hashes['valid on renewal'] + ' , [valid on renewal] is true.') promo_valid_on_renewal_true.click elsif hashes['valid on renewal'] == 'No' log('[Valid on renewal] is - ' + hashes['valid on renewal'] + ' , [valid on renewal] is false.') promo_valid_on_renewal_false.click else log('[Valid on renewal] is by default.') end log('click save changes') promo_save_changes.click end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def promotion_params\n params.require(:promotion).permit(:name, :description, :start_hr, :start_min, :end_hr, :end_min, :start_date, :end_date, :media_id, :min_sale_value, :discount_percent, :discount_value, :free_product_list_id, :active, :unique_code, :promo_cost)\n end", "def promotion_params\n ...
[ "0.7339023", "0.73070526", "0.70700485", "0.70330703", "0.69642144", "0.69430506", "0.67900425", "0.6747111", "0.6740695", "0.67228645", "0.67018515", "0.66115004", "0.6611214", "0.6491016", "0.6424513", "0.6364343", "0.6309591", "0.62699157", "0.6222079", "0.6184785", "0.611...
0.66889244
11
====================================================== public: Get Message once promotion creaion is successful return: success message ======================================================
def get_creation_success_message log('returned text is - " + success_msg.text()') return success_msg.text() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status\n return nil if self.nexmo_message_id.nil?\n\n client = NexmoClientFactory.client\n client.get_message(nexmo_message_id)\n end", "def get_message\n get_status[:message]\n end", "def get_message()\n m = @RESPONSE_HASH['MESSAGE']\n if (m == nil or m == \"\")\n return \"ERR...
[ "0.6328493", "0.6197211", "0.6011732", "0.5980916", "0.5936125", "0.5829666", "0.5826266", "0.5809513", "0.58044076", "0.57988846", "0.5765322", "0.5678265", "0.5660866", "0.56430715", "0.5641193", "0.5634102", "0.5621757", "0.55711466", "0.55711466", "0.55711466", "0.5571146...
0.6084504
2
Sets the owner attributes on the given record
def set_owner_attributes(record) if @owner.persisted? construct_owner_attributes.each { |key, value| record[key] = value } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def owner=(v) self['Owner'] = v end", "def owner=(new_owner)\n if new_owner\n attributes[:owner] = {\n :display_name => new_owner['DisplayName'],\n :id => new_owner['ID']\n }\n end\n end", "def set_owner(id)\n self.ow...
[ "0.7617755", "0.719221", "0.7087667", "0.68537277", "0.68537277", "0.6841061", "0.68264353", "0.67995536", "0.6788768", "0.67817754", "0.67817754", "0.67817754", "0.67817754", "0.67817754", "0.67817754", "0.67817754", "0.67578393", "0.67467326", "0.67467326", "0.67467326", "0...
0.8964834
0
Returns a hash linking the owner to the association represented by the reflection
def construct_owner_attributes(reflection = @reflection) attributes = {} if reflection.macro == :belongs_to attributes[reflection.association_primary_key] = @owner.send(reflection.primary_key_name) else attributes[reflection.primary_key_name] = @owner.send(reflection.active_record_primary_key) if reflection.options[:as] attributes["#{reflection.options[:as]}_type"] = @owner.class.base_class.name end end attributes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash\n [_hash, name, owner].hash\n end", "def owner_association\n owner_ref(self).send(owner_association_name.to_sym)\n end", "def hash\n [principals, relation].hash\n end", "def association_owner_key(assoc, key)\n k = 'activerecord.associations.models.'\n k << assoc.active_...
[ "0.68757844", "0.6538791", "0.6401935", "0.6383943", "0.6272353", "0.62587225", "0.6254022", "0.62203896", "0.619685", "0.61707145", "0.6166494", "0.61453474", "0.59729564", "0.5965282", "0.59565276", "0.59565276", "0.5937785", "0.59173775", "0.5905549", "0.58312654", "0.5811...
0.66429985
1
Builds an array of arel nodes from the owner attributes hash
def construct_owner_conditions(table = aliased_table, reflection = @reflection) construct_owner_attributes(reflection).map do |attr, value| table[attr].eq(value) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attributes\n attribute_nodes.each_with_object({}) do |node, hash|\n hash[node.node_name] = node\n end\n end", "def build_internal_nodes\n names.each do |tmp_geo_area|\n recurse_nodes(tmp_geo_area.parent_names, tmp_geo_area)\n end\n end",...
[ "0.56830907", "0.5679426", "0.5667093", "0.563284", "0.5626856", "0.5610518", "0.5460397", "0.5420931", "0.54174846", "0.52575815", "0.52226764", "0.5220743", "0.5220743", "0.52176994", "0.5190655", "0.5183664", "0.5174312", "0.51666325", "0.51519465", "0.5149283", "0.5147903...
0.5057177
29
More Info: ShodanHQ results as at 20110515 11,928 for Rimon: RWC_BLOCK 125 for Rimon RWC_BLOCK Google results as at 20110515 311 for "You are not recognized in the system !!!" Passive
def passive m=[] # HTTP Rimon Header m << { :string=>@headers["rimon"].to_s } unless @headers["rimon"].nil? # Return passive matches m end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_rbs_availability!; end", "def spotlight_block_internet_results\n return @spotlight_block_internet_results\n end", "def test_00010_profanity_blocker\n \t@loginpage.login($user1)\n enable_profanity_blocker($networkslug, true)\n #check community post\n title_before = ...
[ "0.57736164", "0.5772527", "0.5506065", "0.54126227", "0.5354543", "0.5297236", "0.52799034", "0.5244843", "0.5211339", "0.5160886", "0.51358545", "0.513258", "0.5124375", "0.51205873", "0.5113083", "0.51106924", "0.50933784", "0.50806177", "0.50635993", "0.505202", "0.501350...
0.0
-1
Private: checks the mapper policy against its class opts The Hash containing the policy filter data. Return: true if it fulfills the policy and false if it does not.
def verify_policy(opts) result = policy.constantize.call(opts) rescue NameError result = true ensure return result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_policy(hosts, facts, classes)\n if hosts and not parse_hosts(hosts)\n return false\n end\n if not classes\n return parse_compound(facts)\n else\n return parse_facts(facts) && parse_classes(classes)\n end\n end", "def meets_restrictions?...
[ "0.55878156", "0.5470052", "0.5415447", "0.53895444", "0.5330231", "0.5261278", "0.5173917", "0.5155703", "0.51412326", "0.5125277", "0.51230836", "0.5112458", "0.508078", "0.50254714", "0.49620473", "0.4951802", "0.49440658", "0.48520997", "0.48173445", "0.48167518", "0.4812...
0.633603
0
+host+:: Host of request. Required if no :url param was provided. +path+:: Path of request. Should start with '/'. Default: '/' +query+:: Query for request. Should be in format "aaa=bbb&ccc=ddd" +secure+:: Defines protocol to use. If true then wss://, otherwise ws://. This option will not change default port it should be handled by programmer. +port+:: Port of request. Default: nil +opts+:: Additional options: :reconnect if true, it will try to reconnect :retry_time how often should retries happen when reconnecting [default = 1s] Alternatively it can be called with a single hash where key names as symbols are the same as param names
def initialize(opts) # Initializing with a single hash @options = opts.symbolize_keys @auto_pong = @options.fetch(:auto_pong, nil) || CapistranoSentinel.config.auto_pong @read_buffer_size = @options.fetch(:read_buffer_size, nil) || CapistranoSentinel.config.read_buffer_size @reconnect = @options.fetch(:reconnect, nil) || CapistranoSentinel.config.reconnect @retry_time = @options.fetch(:retry_time, nil) || CapistranoSentinel.config.retry_time @secure = @options.fetch(:secure, nil) || CapistranoSentinel.config.secure @host = @options.fetch(:host, nil) || CapistranoSentinel.config.host @port = @secure ? 443 : (@options.fetch(:port, nil) || CapistranoSentinel.config.port) @path = @options.fetch(:path, nil) || CapistranoSentinel.config.path @query = @options.fetch(:query, nil) @actor ||= @options.fetch(:actor, nil) @channel ||= @options.fetch(:channel, nil) @closed = false @opened = false @on_open = lambda { log_to_file("native websocket client websocket connection opened") subscribe(@channel) if @channel.present? } @on_close = lambda { |message| log_to_file("#{@actor.class} client received on_close #{message.inspect}") if @actor.present? && @actor.respond_to?(:on_close) if @actor.respond_to?(:async) @actor.async.on_close(message) else @actor.on_close(message) end end } @on_ping = lambda { |message| log_to_file("#{@actor.class} client received PING #{message.inspect}") if @actor.present? && @actor.respond_to?(:on_ping) if @actor.respond_to?(:async) @actor.async.on_ping(message) else @actor.on_ping(message) end end } @on_error = lambda { |error| log_to_file("#{@actor.class} received ERROR #{error.inspect} #{error.backtrace}") if @actor.present? && @actor.respond_to?(:on_error) if @actor.respond_to?(:async) @actor.async.on_error(error) else @actor.on_error(error) end end } @on_message = lambda { |message| message = parse_json(message) log_to_file("#{@actor.class} websocket client received JSON #{message}") if @actor.present? && @actor.respond_to?(:async) log_to_file("#{@actor.class} works async on message #{message.inspect}") @actor.async.on_message(message) else @actor.on_message(message) end } connect end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request(method, path, opts)\n response = connection.send(method) do |request|\n request.url(path, opts)\n request.options[:timeout] = timeout\n request.options[:open_timeout] = open_timeout\n\n unless client_id.nil?\n request.headers['Authorization'] = \"Client #{clien...
[ "0.5861014", "0.5769508", "0.55753684", "0.5493264", "0.53579754", "0.5347453", "0.5288416", "0.52617806", "0.5240445", "0.5232819", "0.5217577", "0.52027893", "0.51894563", "0.5173272", "0.51656663", "0.5163462", "0.5148872", "0.5143202", "0.5138545", "0.51004404", "0.506792...
0.0
-1
subscribes to a channel . need to be used inside the connect block passed to the actor
def subscribe(channel, data = {}) log_to_file("#{self.class} tries to subscribe to channel #{channel} with #{data.inspect}") send_action('subscribe', channel, data) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subscribe_to_channel; end", "def subscribe(channel, *channels, &block); end", "def subscribed\n \t#stream_from 'demo_chan'\n end", "def subscribe_to(channel, &block)\n subscriptions[channel].subscribe(&block)\n end", "def subscribe_to_channel(*)\n synchronize_entrypoint! { super }\n ...
[ "0.8191055", "0.7680548", "0.7530543", "0.7519236", "0.74094284", "0.7320657", "0.73168546", "0.7305912", "0.7242643", "0.72143435", "0.7063089", "0.69621795", "0.69348615", "0.6924723", "0.68589544", "0.6847837", "0.68411654", "0.6794809", "0.6787589", "0.67196274", "0.67154...
0.6814656
17
publishes to a channel some data (can be anything)
def publish(channel, data) send_action('publish', channel, data) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def publish(data)\n @consumer_channel.push data\n end", "def publish_to(channel, data)\n\t\t\tpublish_message(message(channel, data))\n\t\tend", "def publish_to(channel, data)\n publish_message(message(channel, data))\n end", "def publish(channel, data, id=nil, prev_id=nil)\n @pub.publish(channel,...
[ "0.84043056", "0.82010657", "0.81019866", "0.80586153", "0.80376184", "0.7995907", "0.79003143", "0.79003143", "0.7818992", "0.7472918", "0.7419547", "0.7326863", "0.73206365", "0.7292828", "0.7282665", "0.72237986", "0.719854", "0.70937556", "0.7073669", "0.70231277", "0.699...
0.8230917
1
unsubscribes current client from a channel
def unsubscribe(channel) send_action('unsubscribe', channel) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unsubscribe_from_channel; end", "def unsubscribe_clients(channel)\n send_action('unsubscribe_clients', channel)\n end", "def unsubscribe_from_channel # :nodoc:\n run_callbacks :unsubscribe do\n unsubscribed\n end\n end", "def unsubscribe\n check_subscribed!\n ...
[ "0.8092683", "0.79990596", "0.7920888", "0.7843475", "0.76694816", "0.75097483", "0.7467353", "0.7467353", "0.7346723", "0.7248031", "0.7246957", "0.72377366", "0.71406513", "0.71259797", "0.70814955", "0.7068814", "0.705975", "0.70401657", "0.70401657", "0.70354986", "0.7020...
0.72944313
9
unsubscribes all clients subscribed to a channel
def unsubscribe_clients(channel) send_action('unsubscribe_clients', channel) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unsubscribed\n # Any cleanup needed when channel is unsubscribed\n stop_all_streams\n end", "def unsubscribed\n # Any cleanup needed when channel is unsubscribed\n stop_all_streams\n end", "def unsubscribe(*channels); end", "def unsubscribe_from_channel; end", "def punsubscribe(*channels)...
[ "0.77854276", "0.77854276", "0.7680194", "0.7469042", "0.74636924", "0.7463368", "0.7217584", "0.71967125", "0.70995325", "0.7059307", "0.7048241", "0.699649", "0.6902584", "0.6890386", "0.6890386", "0.6877078", "0.6845015", "0.67963475", "0.6792432", "0.6766172", "0.67391133...
0.8085907
0
unsubscribes all clients from all channels
def unsubscribe_all send_action('unsubscribe_all') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unsubscribed\n # Any cleanup needed when channel is unsubscribed\n stop_all_streams\n end", "def unsubscribed\n # Any cleanup needed when channel is unsubscribed\n stop_all_streams\n end", "def unsubscribe(*channels); end", "def unsubscribe_clients(channel)\n send_action('unsubscribe_c...
[ "0.7930613", "0.7930613", "0.7799601", "0.7630624", "0.7598016", "0.75197184", "0.7247687", "0.703141", "0.69960517", "0.697477", "0.69413614", "0.69394964", "0.69394964", "0.69332886", "0.69317347", "0.6920092", "0.6872361", "0.6834311", "0.68197453", "0.68146366", "0.680573...
0.72361296
7
method used to send messages to the webserver checks too see if the message is a hash and if it is it will transform it to JSON and send it to the webser otherwise will construct a JSON object that will have the key action with the value 'message" and the key message witth the parameter's value
def chat(message) final_message = nil if message.is_a?(Hash) final_message = message.to_json else final_message = JSON.dump(action: 'message', message: message) end log_to_file("#{self.class} sends JSON #{final_message}") send_data(final_message) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_message(message_hash)\n socket_id = message_hash[\"socket_id\"]\n message = message_hash[\"message\"]\n type = message[\"type\"]\n\n post(send(type, message_hash))\n end", "def send(hash)\n Hammer.logger.debug \"Websocket sending: #{hash}\" if config[:logger][:show_traffic]\n ...
[ "0.64630187", "0.6411132", "0.63846236", "0.6372812", "0.63547486", "0.6353235", "0.63348615", "0.6319651", "0.6243127", "0.6243127", "0.6239985", "0.62027514", "0.618329", "0.6130725", "0.6118807", "0.6084757", "0.60483766", "0.6025956", "0.59947616", "0.5980335", "0.5980298...
0.6747904
0
Send the data given by the data param if running on a posix system this uses Ruby's fork method to send if on windows fork won't be attempted. +data+:: the data to send +type+:: :text or :binary, defaults to :text
def send_data(data, type = :text) pid = Thread.new do do_send(data, type) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _send_data(data)\n send_data(data + \"\\r\\n\")\n end", "def send_data(data)\n str_data = data.pack('C*')\n super(str_data)\n end", "def send_data(data)\n case data\n when nil\n put_string(\"NIL\")\n when String\n send_string_data(data)\n w...
[ "0.7245496", "0.71410024", "0.7053566", "0.7043369", "0.701183", "0.68845046", "0.68845046", "0.6847166", "0.68200195", "0.67849225", "0.6743939", "0.667417", "0.6670131", "0.6663493", "0.6640174", "0.6599512", "0.65946305", "0.6562405", "0.6481626", "0.6396668", "0.6396668",...
0.77660716
0
Use one thread to perform blocking read on the socket
def init_messaging @read_thread = Thread.new { read_loop } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run\n while true; async.handle_message @socket.read; end\n end", "def blocking_read\r\n raise RuntimeError, \"CONN_UDP: blocking_read: Not connected!\" unless connected?\r\n begin\r\n data=@sock.recvfrom(8192)[0]\r\n return nil if data.empty?\r\n data\r\...
[ "0.71309006", "0.70741934", "0.6993665", "0.69767046", "0.6951769", "0.6927007", "0.68976706", "0.6877204", "0.68422115", "0.675105", "0.6691335", "0.6652521", "0.66467726", "0.65784806", "0.6575161", "0.6571189", "0.65613854", "0.65613484", "0.6512499", "0.6511758", "0.64798...
0.0
-1
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
def combine_names(first, last) first + ' ' + last end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def given\n [6,5,3,1,8,7,2,3]\nend", "def sequence(num)\r\n new_arr = []\r\n (1..num).step(1) { |n| new_arr << n }\r\n new_arr\r\nend", "def sequence(number)\n (1..number).to_a\nend", "def sequence(number)\n (1..number).to_a\nend", "def range(start,finish)\n if start == finish\n return [start]\n ...
[ "0.7267974", "0.65121126", "0.64591336", "0.64591336", "0.64455307", "0.6391807", "0.6372647", "0.6372647", "0.6372647", "0.63660204", "0.63281906", "0.6308762", "0.63040966", "0.62938297", "0.6276288", "0.6276288", "0.6269063", "0.6250008", "0.62460184", "0.6241537", "0.6237...
0.0
-1
this method is lifted from image_processing gem copies the original image to a tempfile because we don't want to mess with the original
def _copy_to_tempfile(file) args = [File.basename(file.path, ".*"), File.extname(file.path)] if file.respond_to?(:path) tempfile = Tempfile.new(args || "image", binmode: true) IO.copy_stream(file, tempfile.path) file.rewind tempfile end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tempfile\n @tempfile ||= ::Tempfile.new(filename, tempfile_path).tap do |t|\n t.close\n image.write(t.path)\n end\n end", "def _copy_to_tempfile(file)\n args = [File.basename(file.path, \".*\"), File.extname(file.path)] if file.respond_to?(:path)\n tem...
[ "0.7118234", "0.68954945", "0.68207026", "0.67693514", "0.6742517", "0.6735271", "0.6435347", "0.6431835", "0.636968", "0.63153666", "0.62780744", "0.62558055", "0.6225623", "0.6166958", "0.6164401", "0.61597097", "0.61592823", "0.61592823", "0.6159278", "0.6117659", "0.61027...
0.7130066
0
this method is from mini_magick using posix_spawn
def _run_command(command) require "posix-spawn" pid, stdin, stdout, stderr = POSIX::Spawn.popen4(command) Process.waitpid(pid) # $?.exitstatus contains exit status do something with it if non zero raise error maybe end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def spawn\n Process.spawn(*spawn_args)\n end", "def spawn(cmd)\n puts \">> #{cmd}\"\n\n cmd += ' 2>&1'\n PTY.spawn cmd do |r, w, pid|\n begin\n r.sync\n r.each_char { |chr| STDOUT.write(chr) }\n rescue Errno::EIO => e\n # simply ignoring this\n ensure\n ::Process.wait pid\n ...
[ "0.68219876", "0.6212604", "0.60967004", "0.60239035", "0.5999302", "0.59604627", "0.5764037", "0.5745316", "0.57418483", "0.57201093", "0.5715334", "0.5706591", "0.5624999", "0.56179565", "0.5604674", "0.55741477", "0.55693066", "0.5560377", "0.5556088", "0.5555733", "0.5534...
0.0
-1
game_hash[:home][:players].collect do |ke,va| if ke == player return va[:shoe] end end game_hash[:away][:players].collect do |k,v| if k == player return v[:shoe] end end end
def team_colors(team) game_hash.each do |side, value| if value[:team_name] == team return value[:colors] end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shoe_size(player)\n out=\"no player\"\n x= game_hash[:home][:players]\n x.each do |playa|\n #this is where the players are listed and his stats\n out = playa[:shoe] if playa[:player_name]==player\n # playa.each do |key,value|\n # puts \"This is the key #{key} and this is the value #{valu...
[ "0.77439094", "0.76093245", "0.757968", "0.7477942", "0.74649817", "0.7461113", "0.7421426", "0.73780763", "0.73740244", "0.7354368", "0.73344254", "0.73238623", "0.7307648", "0.7305775", "0.72832406", "0.7281554", "0.72787476", "0.72727823", "0.72676015", "0.72521496", "0.72...
0.0
-1
def team_colors(team) game_hash[:home].each do |ke,va| if va == team return game_hash[:home][:colors] end end game_hash[:away].each do |k,v| if v == team end return game_hash[:away][:colors] end end
def team_names new_array = [] game_hash.each do |k,v| new_array.push(v[:team_name]) end new_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def team_colors(team)\n game_hash.each do |side, value|\n if value[:team_name] == team\n return value[:colors]\n end\n end\n end", "def team_colors(team)\n game_hash.each do |location, team_data|\n if team_data[:team_name] == team\n return team_data[:colors]\n end\n end\nend", "def team_colors...
[ "0.93868095", "0.9194478", "0.9161517", "0.9128551", "0.90809095", "0.90202874", "0.89922494", "0.8990041", "0.89654744", "0.8905889", "0.8902755", "0.8876859", "0.8872983", "0.88667846", "0.8851137", "0.8814347", "0.8797141", "0.8776963", "0.87734103", "0.87635815", "0.87451...
0.0
-1
def player_numbers(team_name) new_array = [] game_hash[:home].each do |ke,va| if va == team_name puts va game_hash[:home][:players].collect do |ke,va| new_array.push (va[:number]) end return new_array end end game_hash[:away].each do |ke,va| if va == team_name puts va game_hash[:away][:players].collect do |ke,va| new_array.push (va[:number]) end return new_array end end end
def player_stats(player_name) game_hash.each do |side, value| value[:players].each do |name, stats| if name == player_name return stats end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def player_numbers(teamname)\n outArray = []\n if game_hash[:home][:team_name] == teamname\n game_hash[:home][:players].each do |k,v|\n #puts \"#{k} TEST #{v}\"\n v.each do |result,number|\n if result == :number\n outArray << number\n end\n end\n end\n outArray\n\n ...
[ "0.92847747", "0.9172286", "0.9138928", "0.9042388", "0.8964447", "0.89488435", "0.89378804", "0.88983834", "0.88934535", "0.88729185", "0.8854876", "0.88488024", "0.88102967", "0.88002765", "0.87799734", "0.8763897", "0.87636507", "0.874045", "0.86990726", "0.86731595", "0.8...
0.7128942
97
def player_stats(name) game_hash[:home][:players].collect do |ke,va| if ke == name return va end end game_hash[:away][:players].collect do |k,v| if k == name return v end end end
def big_shoe_rebounds new_array = [] size = 0 rebounds = 0 game_hash.each do |side, value| value[:players].each do |name, stats| if stats[:shoe] > size size = stats[:shoe] rebounds = stats[:rebounds] new_array[0] = name new_array[1] = stats[:shoe] new_array[2] = stats[:rebounds] end end end return new_array.last end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def player_stats(player_name)\n game_hash.each do |side, value|\n value[:players].each do |name, stats|\n\n if name == player_name\n return stats\n end\n\n end\n end\nend", "def all_stats_for_player(name, game)\n game[:home_team][:players].each do |player_hash|\n return player_hash[:stats] if player_h...
[ "0.8928426", "0.8891636", "0.88884217", "0.88279295", "0.877949", "0.8758135", "0.87192523", "0.8681998", "0.86585397", "0.86573666", "0.8621141", "0.86071295", "0.85996675", "0.8547762", "0.8547755", "0.8535157", "0.85081875", "0.8502993", "0.8498725", "0.8436477", "0.842059...
0.0
-1
playing one round of game till the word is not found in the dictionary
def play_round until dictionary.include?(fragment) && fragment != "" puts "Current player : #{current_player.name}" add_letter(current_player) print "Current fragment of a word: " puts "'#{fragment}'".green next_player! end if losses[previous_player] + 1 == "ghost".length puts "#{previous_player.name} it's a ghost and lost this game!".red.bold else puts "#{previous_player.name} lost this round!".red.bold end losses[previous_player] += 1 @fragment = "" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play\n while @tries.positive?\n print_guesses_remaining\n print_used_letters\n print_word\n\n input = scan_letter\n\n result = process_letter(input)\n\n if %w[save exit].include? result\n process_forced_exit(result)\n return\n end\n\n next unless win?\n\...
[ "0.7017566", "0.68730474", "0.6781907", "0.6778089", "0.6763997", "0.6715527", "0.66985714", "0.6687126", "0.66843826", "0.6584243", "0.6571828", "0.6564845", "0.6538154", "0.6507142", "0.64864975", "0.64619064", "0.6456214", "0.6431511", "0.6415187", "0.6371767", "0.63660717...
0.74488264
0
main method of the game
def play @fragment = "" until @losses.keys.length == 1 system("clear") update_status play_round check_status puts "Next round in 5 seconds...".bold sleep(5) end final_status end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def game; end", "def game; end", "def game; end", "def game; end", "def game; end", "def game; end", "def game; end", "def main\n rounds = Game.start\n game = Game.new(rounds)\n roshambo = Roshambo.new(game)\n Roshambo.play(roshambo)\nend", "def main\r\n welcome\r\n process_cmd_line\r...
[ "0.7932658", "0.7932658", "0.79323006", "0.79323006", "0.79323006", "0.79323006", "0.79323006", "0.77711886", "0.771133", "0.7628913", "0.7627597", "0.7476931", "0.7472028", "0.7393083", "0.7359178", "0.7331043", "0.7321877", "0.7293849", "0.725242", "0.7235749", "0.71853334"...
0.0
-1
A helper to make paths relative to the root easier.
def rel relative_path return File.dirname(__FILE__) + "/../" + relative_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def root_path(*args)\n relative = File.join(*args)\n return relative if relative.expand_path == relative\n root.expand_path / relative\n end", "def root_path(*args)\n relative = File.join(*args)\n return relative if relative.expand_path == relative\n root.expand_pat...
[ "0.8022697", "0.8022697", "0.8017785", "0.7732808", "0.76919407", "0.7600917", "0.7534335", "0.74475276", "0.73570514", "0.7348611", "0.733614", "0.7328759", "0.72711414", "0.7267728", "0.7267728", "0.7229102", "0.7202504", "0.71939605", "0.7179582", "0.7156275", "0.7156275",...
0.7127656
25
Preview this email at
def enviar Email.enviar end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preview\n @email = Email.find(params[:id])\n render :text => @email.body\n end", "def preview\n @email = DirectEmail.find(params[:id])\n render :text => @email.body\n end", "def preview\n @email = EventEmail.find(params[:id])\n render :text => @email.body\n end", "def preview_email\r...
[ "0.71475905", "0.71186084", "0.70552814", "0.6985626", "0.6848472", "0.6848472", "0.6832406", "0.6663229", "0.64324814", "0.631654", "0.6304366", "0.6181875", "0.6167911", "0.61338973", "0.61305445", "0.6115152", "0.61100966", "0.61100966", "0.60882556", "0.60132533", "0.5982...
0.0
-1
I worked on this challenge by myself. Your Solution Below
def do_something(something, something_else, another_thing) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solution4(input)\n end", "def challenge; end", "def solution(s, p, q)\r\n # write your code in Ruby 2.2\r\n # A -1\r\n # C -2\r\n # G -3\r\n # T -4\r\n # s - string with n charactekrs\r\n #cagccta\r\n #0123345\r\n #p,q - not empty arrays\r\n #\r\n #p[0]=2 q[0]=4 gcc 322 ...
[ "0.66699874", "0.65802413", "0.6146916", "0.6141384", "0.60677093", "0.6048339", "0.6008928", "0.5924959", "0.5917534", "0.5897405", "0.5886607", "0.5859519", "0.58535683", "0.5827131", "0.58258575", "0.5825749", "0.5824339", "0.57750577", "0.5770655", "0.57650816", "0.576445...
0.0
-1
end of setup =========================================================================== Method: teardown Description: Before every testcase Test::Unit runs setup ===========================================================================
def teardown puts2("\nTestcase finished in " + calc_elapsed_time(@@tTestCase_StartTime) + " seconds.") # Restore the Global variable's original settings $VERBOSE = @@VERBOSE_ORIG $DEBUG = @@DEBUG_ORIG $FAST_SPEED = @@FAST_SPEED_ORIG $HIDE_IE = @@HIDE_IE_ORIG end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def teardown; end", "def teardown; end", "def teardown\r\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end"...
[ "0.8156411", "0.8156411", "0.81105447", "0.8108799", "0.8108799", "0.80933803", "0.80933803", "0.80933803", "0.80933803", "0.80933803", "0.80933803", "0.80933803", "0.80933803", "0.803258", "0.8011994", "0.8011994", "0.8011994", "0.8011994", "0.8011994", "0.8011994", "0.80119...
0.0
-1
end of teardown =========================================================================== Testcase method: test_Currency_001_Format_To_Amount Description: Tests PyWorks method: format_to_currency(...) Attempts to convert strings to amounts ===========================================================================
def te_st_Currency_001_CommaDelimit puts2("") puts2("#######################") puts2("Testcase: test_Currency_001_CommaDelimit") puts2("#######################") fFloatsToDelimit = [1.00, 12.00, 123.00, 1234.00, 12345.00, 123456.00, 1234567.00,12345678.1234, 0.000000] for fFloat in fFloatsToDelimit sFloat = fFloat.comma_delimit(",") puts2("Delimited: " + fFloat.to_s + " to: " + sFloat.to_s) end #end convert_StringToCurrency end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_Currency_003_Format_From_Amount\n\n\n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_Currency_003_Format_From_Amount\")\n puts2(\"#######################\")\n\n begin # convert_StringFromCurrency\n\n\n ############################\n sThisTaskName = \"$1,...
[ "0.8010059", "0.7927569", "0.6757907", "0.6672394", "0.6119681", "0.6064522", "0.606368", "0.6036254", "0.59897155", "0.59673375", "0.5908482", "0.58114237", "0.57842463", "0.57696116", "0.5628063", "0.55999917", "0.55829656", "0.5582104", "0.5582104", "0.5564438", "0.5562517...
0.55966675
16
End of test method test_Currency_001_CommaDelimit =========================================================================== Testcase method: test_Currency_002_Format_To_Amount Description: Tests WatirWorks method: format_to_currency(...) Attempts to convert strings to amounts ===========================================================================
def test_Currency_002_Format_To_Amount puts2("") puts2("#######################") puts2("Testcase: test_Currency_002_Format_To_Amount") puts2("#######################") begin # convert_ToCurrency ############################ sThisTaskName = "1000 to $1,000.00" puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "1000".format_to_currency() puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "1000 to �1.000.00" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "1000".format_to_currency("�", ".") puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = " 1000 to �1.000.00" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = " 1000 ".format_to_currency("�", ".") puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "1000.5 to $1,000.50" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "1000.5".format_to_currency() puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "1.1 to $1.10" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "1.1".format_to_currency() puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "1 to $1.00" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "1".format_to_currency() puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = ".01 to $0.01" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = ".01".format_to_currency() puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = ".1 to $0.10" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = ".1".format_to_currency() puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "1. to $1.00" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "1.".format_to_currency() puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "1000000.99 to 1,000,000.99" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "1000000.99".format_to_currency("", ",") puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "1000000.99 to �1.000.000.99" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "1000000.99".format_to_currency("�", ".") puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "1000000.999 to �1:000:000.99" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "1000000.999".format_to_currency("�", ":") puts2("Formatted value = #{sConvertedValue.to_s}") ############################ rescue => e puts2("*** ERROR and Backtrace: " + e.message + "\n" + e.backtrace.join("\n"),"ERROR") # Raise the error raise("*** TESTCASE - test_Currency_002_Format_To_Amount") ensure end # convert_StringToCurrency end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_Currency_003_Format_From_Amount\n\n\n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_Currency_003_Format_From_Amount\")\n puts2(\"#######################\")\n\n begin # convert_StringFromCurrency\n\n\n ############################\n sThisTaskName = \"$1,...
[ "0.75067717", "0.6833451", "0.6640417", "0.6573491", "0.64119256", "0.5991208", "0.59187347", "0.58869374", "0.58498573", "0.577752", "0.57726", "0.5769322", "0.5752853", "0.571004", "0.5699625", "0.5643189", "0.56113106", "0.5605286", "0.560388", "0.56036747", "0.55952466", ...
0.7295269
1
End of test method test_Currency_002_Format_To_Amount ============================================================================= Testcase method: test_Currency_003_Format_From_Amount Description: Tests WatirWorks method: format_from_currency(...) Attempts to convert amounts to strings =============================================================================
def test_Currency_003_Format_From_Amount puts2("") puts2("#######################") puts2("Testcase: test_Currency_003_Format_From_Amount") puts2("#######################") begin # convert_StringFromCurrency ############################ sThisTaskName = "$1,000 to 1000" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "$1,000".format_from_currency("$", ",", true) puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "$1,000,000.00 to 1000000.00" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "$1,000,000.00".format_from_currency("$", ",", false) puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "�1.000.50 to 1000" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "�1.000.50".format_from_currency("�", ".", true) puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "$1.000.5 to 1000.50" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "$1.000.5".format_from_currency("$", ",", false) puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "$1,000,000.50 to $1000000" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "$1,000,000.50".format_from_currency( "", ",",true) puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "�1,000,000.5 to 1000000.50" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "�1,000,000.5".format_from_currency("�", ",", false) puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "0.5 to 0.50" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "0.5".format_from_currency("", ",", false) puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = ".5 to 0.50" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = ".5".format_from_currency("", ",", false) puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "$1. to 1.00" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "$1.".format_from_currency("$", ",", false) puts2("Formatted value = #{sConvertedValue.to_s}") ############################ sThisTaskName = "$. to 0.00" puts2("") puts2(" # BEGIN: " + sThisTaskName + " #") sConvertedValue = "$.".format_from_currency("$", ",", false) puts2("Formatted value = #{sConvertedValue.to_s}") ############################ rescue => e puts2("Error and Backtrace: " + e.message + "\n" + e.backtrace.join("\n"),"error") # Raise the error raise("*** TESTCASE - test_Currency_003_Format_From_Amount") ensure end # convert_StringFromCurrency end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_Currency_002_Format_To_Amount\n\n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_Currency_002_Format_To_Amount\")\n puts2(\"#######################\")\n\n begin # convert_ToCurrency\n\n ############################\n sThisTaskName = \"1000 to $1,000.00\"...
[ "0.7666352", "0.6993375", "0.6877273", "0.65676624", "0.64904284", "0.6437494", "0.6318273", "0.63112074", "0.6294731", "0.6290442", "0.62497383", "0.6223843", "0.6213673", "0.61882263", "0.6166752", "0.61393404", "0.61085856", "0.6106045", "0.6091225", "0.6088542", "0.606385...
0.7910124
0
rerieve and pass the rss feed returning status information about the feed.
def check_feed(feed, &block) begin rss = RSS::Parser.parse(open(feed.link) { |s| s.read }, false) if rss.nil? [:ok, 1, 0] else cnt = rss.items.size if block_given? cnt = 0 rss.items.each do |item| cnt += yield(feed,item) end end [:ok, 1, cnt] end rescue OpenURI::HTTPError [:error, 3, "HTTPError: #{$!.message}"] # 404 Not Found rescue RSS::NotWellFormedError [:error, 4, "Not Well Formed RSS: #{$!.message}"] rescue Errno::ETIMEDOUT [:error, 2, "Timedout"] rescue Errno::ENOENT [:error, 5, "No entity found: #{$!.message}"] rescue SocketError [:error, 5, "Couldn't connect #{$!.message}"] rescue URI::InvalidURIError [:error, 4, "Invalid URI, #{$!.message}"] rescue NoMethodError [:error, 4, "Invalid RSS? #{$!.message}"] rescue OpenSSL::SSL::SSLError [:error, 5, "SSLError: #{$!.class.name}"] rescue [:error, 9, "unknown error: [#{$!.class.name}]: #{$!.message}"] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_feed url=rss_url, now = Time.now\n\n options = {\n user_agent: 'Geolinguist Test',\n max_redirects: 2,\n compress: true\n }\n\n\n f = Feedjira::Feed.fetch_and_parse url, options\n if f.url != rss_url.sub(RSS_SUFFIX,'')\n self.base_url = f.url.sub(RSS_SUFFIX,'').sub(S...
[ "0.6500521", "0.63392884", "0.6295202", "0.62594444", "0.61890996", "0.6143581", "0.6139181", "0.61067504", "0.6092461", "0.6085524", "0.60491186", "0.6041774", "0.60319316", "0.601841", "0.59696245", "0.59650654", "0.59375095", "0.592991", "0.5927799", "0.5911539", "0.588617...
0.6047212
11
Function that is called from within Model to push a notification
def perform(token, alert, badge) notification = Grocer::Notification.new( device_token: token, alert: alert, badge: badge ) pusher.push(notification) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_notification\n\n\n end", "def create_notification; end", "def push(notif)\n\n end", "def send_notifications\n end", "def send_notification(method, params); end", "def push_notification\n NotificationMailer.push_notification\n end", "def notifications\n end", "def notify_by_push\n ...
[ "0.79129845", "0.7632947", "0.7573457", "0.72734666", "0.7170966", "0.7135296", "0.70779693", "0.7059019", "0.68738437", "0.6821967", "0.67372805", "0.6642225", "0.6638041", "0.6633493", "0.66221046", "0.66221046", "0.6606825", "0.65995437", "0.65596133", "0.6550375", "0.6460...
0.0
-1
abstractions for connection, which fail automatically
def agent return @agent if @agent if ready? && private_ip_address @agent = RestClient::Resource.new( "#{private_ip_address}:#{AGENT_PORT}/", timeout: 999999 ) else fail 'Server is not ready.' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_error(connection, reason)\n end", "def connect_reset_safe\n\t\tbegin\n\t\t\tconnect\n\t\trescue Rex::ConnectionRefused\n\t\t\treturn :refused\n\t\tend\n\t\treturn :connected\n\tend", "def connection(connection, didFailWithError:error)\n @room.streamFailed\n rejoin\n end", "def on_tcp_conne...
[ "0.71100324", "0.6929631", "0.682656", "0.6676495", "0.6666836", "0.6643399", "0.6626798", "0.66036546", "0.66036546", "0.66036546", "0.66036546", "0.66036546", "0.66036546", "0.6577808", "0.6562181", "0.6501566", "0.64547396", "0.6439998", "0.64176136", "0.641657", "0.637828...
0.0
-1
GET /tipo_actividads GET /tipo_actividads.json
def index @tipo_actividads = TipoActividad.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @tipo_actividad = TipoActividad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_actividad }\n end\n end", "def index\n @actividads = Actividad.all\n end", "def show\n @activo = Activo.find(params[:id])\n\n re...
[ "0.7129683", "0.6676199", "0.66501236", "0.66076255", "0.6606381", "0.6558203", "0.65266496", "0.65253615", "0.64946395", "0.644516", "0.64268714", "0.64155716", "0.63872033", "0.6355061", "0.63419795", "0.6315225", "0.62956417", "0.62670964", "0.62420577", "0.6238409", "0.62...
0.72707134
0
GET /tipo_actividads/1 GET /tipo_actividads/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @tipo_actividad = TipoActividad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_actividad }\n end\n end", "def index\n @tipo_actividads = TipoActividad.all\n end", "def show\n @activo = Activo.find(params[:id])\...
[ "0.74239", "0.71713233", "0.6860721", "0.68318653", "0.68100595", "0.6721111", "0.6671315", "0.6654853", "0.6599203", "0.6559442", "0.65287685", "0.65218997", "0.64728725", "0.64614415", "0.6460771", "0.64467186", "0.6421764", "0.637686", "0.6373645", "0.6368257", "0.634844",...
0.0
-1
POST /tipo_actividads POST /tipo_actividads.json
def create @tipo_actividad = TipoActividad.new(tipo_actividad_params) respond_to do |format| if @tipo_actividad.save format.html { redirect_to @tipo_actividad, notice: 'Tipo actividad se creó correctamente.' } format.json { render :show, status: :created, location: @tipo_actividad } else format.html { render :new } format.json { render json: @tipo_actividad.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @tipo_actividad = TipoActividad.new(params[:tipo_actividad])\n\n respond_to do |format|\n if @tipo_actividad.save\n format.html { redirect_to @tipo_actividad, notice: 'Tipo actividad was successfully created.' }\n format.json { render json: @tipo_actividad, status: :created, l...
[ "0.67348546", "0.6442891", "0.62742347", "0.6253749", "0.62522805", "0.6203949", "0.6197207", "0.61944884", "0.61769533", "0.61542404", "0.6140967", "0.6110963", "0.60681707", "0.6025925", "0.60028255", "0.5994297", "0.5980875", "0.59744686", "0.5971107", "0.59681594", "0.595...
0.6750269
0
PATCH/PUT /tipo_actividads/1 PATCH/PUT /tipo_actividads/1.json
def update respond_to do |format| if @tipo_actividad.update(tipo_actividad_params) format.html { redirect_to @tipo_actividad, notice: 'Tipo actividad se actualizo correctamente.' } format.json { render :show, status: :ok, location: @tipo_actividad } else format.html { render :edit } format.json { render json: @tipo_actividad.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @tipo_actividad = TipoActividad.find(params[:id])\n\n respond_to do |format|\n if @tipo_actividad.update_attributes(params[:tipo_actividad])\n format.html { redirect_to @tipo_actividad, notice: 'Tipo actividad was successfully updated.' }\n format.json { head :no_content }\n ...
[ "0.71816164", "0.7045413", "0.6900843", "0.687196", "0.6855516", "0.6833924", "0.6760118", "0.6756357", "0.67532533", "0.67474467", "0.6728945", "0.6721714", "0.66494745", "0.663381", "0.6614378", "0.6612885", "0.6593857", "0.6574866", "0.656132", "0.65597636", "0.652284", ...
0.6824906
6
DELETE /tipo_actividads/1 DELETE /tipo_actividads/1.json
def destroy @tipo_actividad.destroy respond_to do |format| format.html { redirect_to tipo_actividads_url, notice: 'Tipo actividad se elimino correctamente.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @tipo_actividad = TipoActividad.find(params[:id])\n @tipo_actividad.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_actividads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @actividad = Actividad.find(params[:id])\n @actividad...
[ "0.76893437", "0.7383738", "0.72604406", "0.71526295", "0.7123539", "0.7116351", "0.7107664", "0.708317", "0.7082692", "0.7078241", "0.7053908", "0.6991266", "0.69856894", "0.6976074", "0.6941976", "0.6931941", "0.6929264", "0.69285107", "0.69122094", "0.69119054", "0.6911905...
0.7429858
1
Use callbacks to share common setup or constraints between actions.
def set_tipo_actividad @tipo_actividad = TipoActividad.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def tipo_actividad_params params.require(:tipo_actividad).permit(:nombre) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
TODO: simplify this (reduce duplication)
def get_exceptions if @exceptions1 == nil filename = "../../../tex/generic/hyph-utf8/patterns/tex/hyph-#{@code}.tex"; lines = IO.readlines(filename, '.').join("") exceptions = lines.gsub(/%.*/,''); if (exceptions.index('\hyphenation') != nil) @exceptions1 = exceptions.gsub(/.*\\hyphenation\s*\{(.*?)\}.*/m,'\1'). gsub(/\s+/m,"\n"). gsub(/^\s*/m,''). gsub(/\s*$/m,''). split("\n") else @exceptions1 = "" end end return @exceptions1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def schubert; end", "def formation; end", "def offences_by; end", "def suivre; end", "def custom; end", "def custom; end", "def common\n \n end", "def transformations; e...
[ "0.69712687", "0.60538334", "0.5995105", "0.5995105", "0.5995105", "0.5995105", "0.5858518", "0.5621973", "0.5602077", "0.55734813", "0.55452204", "0.55452204", "0.5510428", "0.5488014", "0.548535", "0.548535", "0.5471465", "0.5471465", "0.5469301", "0.54511654", "0.5440506",...
0.0
-1
Class to create a graph
def create_graph(arr) nodes = [] (0...arr.size).each do |i| node = Node.new(i) nodes.push(node) end nodes.each_with_index do |node,i| arr[i].each {|val| node.connections.push(nodes[val])} end nodes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_graph\n end", "def initialize\n @vertices = {}\n create_graph\n end", "def initialize(graph)\n @graph = graph\n end", "def make_graph\n\t\t@graph = Graph.new(@width2, @height2, @maze)\n\tend", "def initialize graph\n # Make the data entry easier with default hash values\n @...
[ "0.77965236", "0.72949564", "0.72111744", "0.70105463", "0.6987603", "0.6939793", "0.6939793", "0.6902709", "0.685777", "0.6834346", "0.68074447", "0.67889756", "0.6744311", "0.6664424", "0.6625337", "0.6620179", "0.6612398", "0.658939", "0.658701", "0.65771496", "0.65551853"...
0.66124845
17
Method to process multiline string into a list of arrays of numbers
def input_processing(multi_line) multi_line.split("\n").map {|nums| nums.split.map {|str| str.to_i}} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def array_from_rows(str)\n str.split(\"\\n\").map { |x| x.split(' ').map { |y| y.to_i } }\n end", "def parse_to_array(line_as_string)\n as_array = line_as_string.split(\" \")\nend", "def arrayify(str)\n str.split(\"\\n\")\n end", "def parse_row_data_from_input(input_str)\n rows = input_str.split(\"...
[ "0.7214057", "0.696559", "0.6905479", "0.67756516", "0.67296475", "0.6696657", "0.65957826", "0.6582713", "0.634262", "0.6280463", "0.6275392", "0.62730265", "0.62306803", "0.6170491", "0.6166549", "0.6105601", "0.6071568", "0.6052773", "0.6039341", "0.6004562", "0.59593713",...
0.6984879
2
Extract unique numbers from multiline input and return a sorted array of those
def convert_to_sorted(arr_of_arr) sorted = [] arr_of_arr.each {|arr| arr.each {|num| sorted.push(num) if !sorted.include?(num)}} sorted.sort end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def array_to_unique\n a = File.readline(\"./tmp/database_doings/doing_phrases/phrases_to_sort.txt\")\n b = a.sort\n c = b.uniq\n while d = c.shift\n puts d unless nil?\n end\n end", "def read_and_sort_unique_numbers_from_file(filename)\n fh = File.new(filename, 'r')\n\n numbers = Hash.ne...
[ "0.69916975", "0.6939333", "0.69217306", "0.6628614", "0.65559846", "0.6490298", "0.6396486", "0.6257641", "0.6214652", "0.6188274", "0.60925776", "0.60897994", "0.60771984", "0.6072651", "0.59944344", "0.59373873", "0.5932871", "0.58856833", "0.5756978", "0.57533854", "0.573...
0.0
-1
Returns string of unique numbers
def depth_first_graph(node, visited = []) if !visited.include? node visited.push(node) output = node.data.to_s + " " output += node.connections.map do |connection| depth_first_graph(connection, visited) end.join("") end output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def input(number_string)\n\t\tnumber_string = number_string.split(\" \").to_a.uniq!.sort!.map{|num| num.to_i}\n\t\tputs \"Uniqe Values: #{number_string}\"\n\tend", "def unique_transaction_number\n chars = [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten\n string = (0...10).map{ chars[rand(chars...
[ "0.72859997", "0.723734", "0.69769025", "0.694031", "0.6684781", "0.6645648", "0.65625715", "0.65506375", "0.6537579", "0.6529515", "0.64639395", "0.64434075", "0.63922924", "0.6372563", "0.63432455", "0.6293495", "0.62917864", "0.628021", "0.6241527", "0.6175539", "0.6158431...
0.0
-1
GET /informacoes_ged GET /informacoes_ged.json
def index if !params[:orgao_id].blank? && current_user.admin @informacoes_ged = InformacaoGed.where(orgao_id: params[:orgao_id]) elsif current_user.admin @informacoes_ged = InformacaoGed.all else @informacoes_ged = InformacaoGed.where(orgao_id: current_user.orgao_id) end #@informacoes_ged = InformacaoGed.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def emergencias_en_curso\n @emergencies = Emergency.where(:estado => 'f')\n render json: @emergencies\n end", "def index\n @ginasios = Ginasio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ginasios }\n end\n end", "def show\n @ecg =...
[ "0.60160863", "0.59186107", "0.5896917", "0.581409", "0.5717624", "0.57070917", "0.5677353", "0.5673586", "0.56652355", "0.5643754", "0.5639112", "0.5635476", "0.56164503", "0.5612588", "0.5602261", "0.5592503", "0.5589428", "0.5588241", "0.55565405", "0.5542427", "0.5512123"...
0.0
-1
GET /informacoes_ged/1 GET /informacoes_ged/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end", "def show\n @colegiatura = Colegiatura.find(params[:id])\n\n respond_to do |format|\n format.htm...
[ "0.61214983", "0.61150044", "0.6107142", "0.60935175", "0.6066525", "0.6053255", "0.5974792", "0.5962492", "0.59600025", "0.5948444", "0.5927653", "0.59230924", "0.5899387", "0.5827401", "0.582138", "0.58095396", "0.5800823", "0.57961845", "0.57502866", "0.57498854", "0.57474...
0.0
-1
POST /informacoes_ged POST /informacoes_ged.json
def create @informacao_ged = InformacaoGed.new(informacao_ged_params) respond_to do |format| if @informacao_ged.save format.html { redirect_to @informacao_ged, notice: 'Informação sobre o GED criada com sucesso.' } format.json { render action: 'show', status: :created, location: @informacao_ged } else format.html { render action: 'new' } format.json { render json: @informacao_ged.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def informacao_ged_params\n params.require(:informacao_ged).permit(:orgao_id, :processo_digitalizacao, :numero_digitalizacao, :documentos_indexados, :hospedado_sepog)\n end", "def create\n @iglesia = Iglesia.new(iglesia_params)\n\n respond_to do |format|\n if @iglesia.save\n format.html...
[ "0.61919296", "0.5664271", "0.5592055", "0.55362755", "0.54687685", "0.5461491", "0.5444696", "0.5438037", "0.5422431", "0.5421057", "0.53874725", "0.5376109", "0.5353349", "0.5352899", "0.53444093", "0.53421116", "0.5342051", "0.5331872", "0.5320823", "0.5291916", "0.5288176...
0.6628796
0
PATCH/PUT /informacoes_ged/1 PATCH/PUT /informacoes_ged/1.json
def update respond_to do |format| if @informacao_ged.update(informacao_ged_params) format.html { redirect_to @informacao_ged, notice: 'Informação sobre o GED atualizada com sucesso.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @informacao_ged.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @iglesia.update(iglesia_params)\n format.html { redirect_to @iglesia, notice: 'La iglesia #{@iglesia.nombre} ha sido actualizada.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { re...
[ "0.6117247", "0.61013395", "0.6085796", "0.6083696", "0.60835725", "0.6041479", "0.60056084", "0.60016745", "0.5988916", "0.598638", "0.5985714", "0.5942156", "0.59323734", "0.5915774", "0.59122556", "0.5898158", "0.5880322", "0.58672965", "0.58635664", "0.5850036", "0.583121...
0.65446734
0
DELETE /informacoes_ged/1 DELETE /informacoes_ged/1.json
def destroy @informacao_ged.destroy respond_to do |format| format.html { redirect_to informacoes_ged_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end", "def delete\n client.delete(\"/#{id}\...
[ "0.6847203", "0.6821208", "0.679435", "0.67873424", "0.6773591", "0.6754265", "0.6725233", "0.6665187", "0.66379046", "0.663154", "0.663154", "0.663154", "0.663154", "0.6624666", "0.65945697", "0.65843564", "0.657652", "0.655621", "0.65480536", "0.65317947", "0.6528203", "0...
0.70700896
0
Use callbacks to share common setup or constraints between actions.
def set_informacao_ged @informacao_ged = InformacaoGed.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1