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
as you can see here we did not call ' guess ' variable, nor 'guesses' at the end. Why? because the Conditional Statements will return a value(s), and the ' method ' will return that value. TRANSLATION
def my_guesses(my_name, gueeses) #<-- When we call the method, we have to write two parameters like this.... my_guess("Anthony", "friend") if guesses #<-- If there is guesses "Juan" # <-- give me this String.... NOTICE we didn't have to set it to a variable. else "Ordaz" #<-- If there is No guesses, print this String. end #<-- We don't have to write guesses variable to get something in return. The " Method" does it for us end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def guess(guess)\n \t@guess = guess\n \treturn :correct if solved?\n \t@guess > @answer ? :high : :low\n end", "def correct_guess(guess)\n end", "def speak_to_grandma(question)\n if question != question.upcase\n return \"HUH?! SPEAK UP, SONNY!\"\n elsif question == \"I LOVE YOU GRANDMA!\"\n retu...
[ "0.6602713", "0.65833277", "0.6504412", "0.64169455", "0.6414971", "0.6386976", "0.63685393", "0.63641", "0.636054", "0.6353414", "0.6347861", "0.6344343", "0.634301", "0.63412684", "0.6319658", "0.63193256", "0.63141227", "0.63141227", "0.63141227", "0.63141227", "0.6286966"...
0.6466627
3
GET /documents GET /documents.json
def index authorize Document @documents = apply_scopes(Document).valid.all if current_user.client? @documents = @documents.by_belongings([current_user.id]) end respond_with do |format| format.html format.json { render json: DocumentsDatatable.new(view_context, @documents) } format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def documents(params={})\n server.get(\"#{name}/_all_docs\", params)\n end", "def index\n @documents = Document.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @documents }\n end\n end", "def documents\n return bad_request unless params[...
[ "0.7656662", "0.7626486", "0.75327045", "0.7379236", "0.73293954", "0.73293954", "0.73293954", "0.73293954", "0.73293954", "0.73293954", "0.73293954", "0.7327912", "0.73046535", "0.7289063", "0.72620124", "0.7253349", "0.7240533", "0.7154175", "0.7143549", "0.7138256", "0.711...
0.6584786
57
GET /documents/1 GET /documents/1.json
def show authorize @document end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n \n @document = Document.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document }\n end\n \n end", "def index\n @documents = Document.all\n\n respond_to do |format|\n format.html # index.html.erb\n form...
[ "0.7391596", "0.73689586", "0.73263764", "0.73263764", "0.73263764", "0.73263764", "0.73263764", "0.73263764", "0.73263764", "0.73170596", "0.7306216", "0.7303724", "0.7286854", "0.72555476", "0.71793205", "0.71743375", "0.71661717", "0.714282", "0.71288323", "0.7051852", "0....
0.0
-1
POST /documents POST /documents.json
def create @document = Document.new(document_params) authorize @document respond_to do |format| if @document.save flash_label = "Document was successfully created." flash.now[:notice] = flash_label format.html { redirect_to @document, notice: flash_label } format.json { render :show, status: :created, location: @document } format.js else format.html { render :new } format.json { render json: @document.errors, status: :unprocessable_entity } format.js end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, :notice => 'Document was successfully created.' }\n format.json { render :json => @document, :status => :created, :location => @document }\n e...
[ "0.72675", "0.72270125", "0.7202067", "0.7202067", "0.71927583", "0.71516854", "0.7137915", "0.71379024", "0.712435", "0.7049302", "0.68928266", "0.6876889", "0.6837602", "0.6818319", "0.68161947", "0.6751123", "0.67454964", "0.6734003", "0.6723543", "0.66879636", "0.6685973"...
0.6440168
44
PATCH/PUT /documents/1 PATCH/PUT /documents/1.json
def update authorize @document respond_to do |format| if @document.update(document_params) flash_label = "Document was successfully updated." flash.now[:notice] = flash_label format.html { redirect_to @document, notice: flash_label } format.json { render :show, status: :ok, location: @document } format.js else format.html { render :edit } format.json { render json: @document.errors, status: :unprocessable_entity } format.js end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n document = Document.find(params[:id])\n document.update!(update_params)\n render json: {}\n end", "def update\n document = Document.find(params[:id])\n if document.update(params_document)\n render json: document, status: 200\n else\n render json: docum...
[ "0.7042587", "0.69301134", "0.68538636", "0.68145615", "0.6812295", "0.6795509", "0.6792733", "0.67758715", "0.67758715", "0.67758715", "0.67729616", "0.67479396", "0.6740137", "0.6725141", "0.67235345", "0.67068815", "0.6704021", "0.6689557", "0.6689557", "0.6689557", "0.668...
0.6064376
85
DELETE /documents/1 DELETE /documents/1.json
def destroy authorize @document @document.is_valid = false @document.save respond_to do |format| format.html { redirect_to documents_url, notice: 'Document was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n @client.delete_document(@path)\n end", "def delete_document index, id\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Delete.new(uri)\n run(uri, req)\n end", "def destroy\n @doc = Doc.find(params[:id])\n @doc.destroy\n\n respond...
[ "0.78232354", "0.761401", "0.7518423", "0.75177574", "0.7488822", "0.7488822", "0.7488822", "0.7488822", "0.7488822", "0.7483412", "0.7483412", "0.7474384", "0.7474384", "0.7474384", "0.7474384", "0.7474384", "0.7474384", "0.7474384", "0.7474384", "0.7474384", "0.74585146", ...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_document @document = Document.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 document_params params.require(:document).permit( :document_name, :project_id, :user_id, :doc_file, :is_valid ) 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 allow user to specify userlogin and password on intialize
def initialize(attributes={}) attributes.each do |k,v| respond_to?(:"#{k}=") ? send(:"#{k}=", v) : raise(NoMethodError, "Unknown method #{k}") end #set the cookie if @username and @password login = open("http://blip.tv/dashboard/?userlogin=#{@username}&password=#{@password}") @cookie = login.meta['set-cookie'].split('; ',2)[0] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(login, password)\n @login = login\n @password = password\n end", "def initialize user = { email: nil, password: nil }\n unless user[:email] == nil || user[:password] == nil\n @email = user[:email]\n @password = user[:password]\n login \n end\n end", "de...
[ "0.74952465", "0.73910713", "0.7299913", "0.7290865", "0.7290865", "0.7290162", "0.72690386", "0.725154", "0.7229634", "0.70906186", "0.707879", "0.7066061", "0.70005155", "0.6985195", "0.69642735", "0.6956004", "0.6956004", "0.6956004", "0.6901264", "0.68903595", "0.68827486...
0.0
-1
Implements the Blip.tv REST Upload API new_attributes hash should contain next required keys: title: The video title; file: The video file; and optionally: thumbnail: A thumbnail file; nsfw: true if explicit, false otherwise. Defaults to false; description: A description of the video username: Username password: Password keywords: A commaseparated string of keywords TODO this should be nice and also accept Arrays categories: A Hash of categories license: A license for the video interactive_post: Specify whether or not a post is interactive. More here[ Example: bliptv.upload_video(:title => 'Check out this guy getting kicked in the nuts!', :file => File.open('/movies/nuts.mov')) Returns BlipTV::Video instance.
def upload_video(new_attributes={}) BlipTV::ApiSpec.check_attributes('videos.upload', new_attributes) new_attributes = { :post => "1", :item_type => "file", :skin => "xmlhttprequest", :file_role => "Web" }.merge(new_attributes) # blip.tv requires the "post" param to be set to 1 request = BlipTV::Request.new(:post, 'videos.upload') request.run do |p| for param, value in new_attributes p.send("#{param}=", value) end end BlipTV::Video.new(request.response['post_url'].to_s) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def video_params\n params.require(:video).permit(:title,\n :description,\n :published,\n :external_url,\n :transcript,\n :director,\n ...
[ "0.6931163", "0.67784923", "0.67559236", "0.67054534", "0.66542834", "0.6635668", "0.6600266", "0.6567198", "0.65462184", "0.6484448", "0.64516985", "0.63962233", "0.6390413", "0.6382313", "0.6380842", "0.6373134", "0.63556826", "0.63544345", "0.6315744", "0.6302321", "0.6295...
0.8217706
0
Searches through and returns videos based on the search_string. This method is a direct call of Blip.tv's search method. You get what you get. No guarantees are made. Example: bliptv.search_videos("cool stuff") Returns an array of BlipTV::Video objects
def search_videos(search_string) url = "http://www.blip.tv/search/?search=#{search_string}&skin=json" request = open(url,{"UserAgent" => "Ruby-Wget"}).read json = JSON.parse(request[16...-3]) parse_json_videos_list(json) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_videos()\n\t\treturn SearchVideos.new(@credentials.client_key, @credentials.get_access_token)\n\tend", "def video_search(keyword, search_mode='all', options={})\n resp_types, opts = merge_defaults(options, %w(main artists releases tracks categories))\n self.class.get(\"/video/v1/list/search/#{se...
[ "0.7280883", "0.72127014", "0.7154276", "0.6875449", "0.6738651", "0.6728449", "0.65872735", "0.65305704", "0.6525326", "0.65166587", "0.6425841", "0.64246213", "0.64126843", "0.64126104", "0.6332405", "0.6292901", "0.62914413", "0.61588055", "0.611411", "0.61088127", "0.6058...
0.8336041
0
400 bad request blank parameter
def render_blank_parameter(parameter_name) result = { success: false, code: self.class::CODE_FAILURE_WRONG_PARAMETER, message: "#{parameter_name}参数不能为空。", collection: [], size: 0, errors: { parameter_name => [ '不能为空' ] } } respond_result :bad_request, result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bad_request\n [ 400, {'Content-Type'=>'text/plain', 'Content-Length'=>'0'},\n [''] ]\n end", "def valid_params_request?; end", "def validate_param\n render_endpoint_request do\n erb = EndpointRequestBuilder.new(@endpoint)\n erb.validate_param(@arguments.keys.first.to_s, @a...
[ "0.7151855", "0.7134517", "0.6998314", "0.6984237", "0.690104", "0.6884485", "0.68544513", "0.67343175", "0.66200024", "0.6617437", "0.6617437", "0.65081847", "0.6495829", "0.64851606", "0.648242", "0.6468331", "0.6447936", "0.6393074", "0.6384897", "0.6379715", "0.63539463",...
0.62956095
24
404 not found inexistent
def render_inexistent(parameter_name, message) result = { success: false, code: self.class::CODE_FAILURE_NOT_FOUND, message: message, collection: [], size: 0, errors: { parameter_name => [ '不存在' ] } } respond_result :not_found, result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_404\n end", "def not_found\n respond_with 404\n end", "def not_found\n render :nothing => true, :status => 404\n end", "def not_found\n render nothing: true, status: 404\n end", "def not_found\n render :status => 404\n end", "def not_found\n respond_with 404\n end", "...
[ "0.8354565", "0.8196609", "0.8117564", "0.8109188", "0.81080204", "0.8088697", "0.80852836", "0.80852836", "0.80852836", "0.8003923", "0.7901793", "0.7887253", "0.7858254", "0.785237", "0.7817236", "0.78086656", "0.7800879", "0.77820784", "0.77424836", "0.7731827", "0.7730611...
0.0
-1
409 conflict wrong parameter
def render_wrong_parameter(errors, message, collection = [], size = 0) result = { success: false, code: self.class::CODE_FAILURE_WRONG_PARAMETER, message: message, collection: collection, size: size, errors: errors } respond_result :conflict, result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def treat_reserved_as_conflict=(_arg0); end", "def treat_reserved_as_conflict; end", "def merge_conflict?; end", "def status_code; 422; end", "def status_code; 422; end", "def status_code; 422; end", "def status_code; 422; end", "def conflict(exception)\n # had to remove as gives away details ...
[ "0.64959604", "0.6435538", "0.6250944", "0.61571455", "0.61571455", "0.61571455", "0.61571455", "0.6041247", "0.59050554", "0.58019423", "0.56807554", "0.5631462", "0.5581446", "0.5581144", "0.5445897", "0.5429397", "0.5415799", "0.5414115", "0.54013443", "0.5364808", "0.5353...
0.5374261
19
Downloads the dependency from its source.
def download # noinspection RubyCaseWithoutElseBlockInspection case type when 'direct' dir = File.dirname(path) FileUtils.mkdir_p(dir) Attachment.download_from_url(source, dir) when 'git' FileUtils.mkdir_p(File.dirname(path)) ::Open3.capture3('git submodule update --init --recursive') end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_source\n unless @download_source\n if new_resource.package_url\n res = chase_redirect(new_resource.package_url)\n else\n params = URI.encode_www_form(full: 1,\n plat: node['platform_family'][0..2])\n res ...
[ "0.6813441", "0.67236334", "0.6660303", "0.6620669", "0.66032445", "0.6547744", "0.6338027", "0.6336121", "0.6249105", "0.6243468", "0.62351704", "0.6231473", "0.6226257", "0.61052024", "0.607988", "0.60666335", "0.6058958", "0.60525215", "0.6037844", "0.6036436", "0.60348886...
0.63401693
6
Returns the directory where the dependency is downloaded.
def dir Rails.root.join(ROOT, type, name).to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def downloaded_path\n @downloaded_path ||= File.join(install_path, file_name(url))\n return @downloaded_path\n end", "def output_dir_path\n @output_dir_path ||= download_dir_path\n end", "def workdir\n @workdir ||= ::File.join(::File.dirname(@repo_dir), 'download')\n end", "def downl...
[ "0.75394887", "0.75303435", "0.73188937", "0.6829536", "0.67805314", "0.6764884", "0.67613024", "0.6746089", "0.6742861", "0.67203635", "0.67057765", "0.6700781", "0.66924495", "0.6659541", "0.6636466", "0.6616449", "0.6561229", "0.6554174", "0.6550068", "0.65196204", "0.6512...
0.6184637
69
Returns the full path of directory with executable of the dependency.
def path Rails.root.join(ROOT, type, name, executable).to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def executable_path; end", "def gem_path\n `gem environment gemdir`.chomp\nend", "def relative_install_path\n a = artifact\n name = File.basename(a.to_s)\n a.respond_to?(:group) ? \"#{a.group.gsub('.', '/')}/#{name}\" : \"#{name}\"\n end", "def bin_path(_opts)\n '/bin'\n en...
[ "0.7315518", "0.68890375", "0.6705746", "0.6655115", "0.6655115", "0.6655115", "0.6623178", "0.6619747", "0.6578998", "0.6564108", "0.65622145", "0.6432822", "0.64316905", "0.64254886", "0.6402976", "0.6387956", "0.638721", "0.63815707", "0.6380947", "0.63592106", "0.635265",...
0.7219896
1
Deletes all local files of the dependency.
def delete_downloads FileUtils.remove_entry_secure(dir) if Dir.exist?(dir) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_up\n @files.each {|file| FileUtils.remove(file.path)}\n end", "def clean_remote\n to_delete = remote_assets - local_compiled_assets\n to_delete.each do |f|\n delete_remote_asset(bucket.files.get(f))\n end\n end", "def delete_files\n self.bruse_files.each do |file|\n ...
[ "0.7081689", "0.70680034", "0.691354", "0.6805513", "0.67923284", "0.67345715", "0.67088383", "0.67083037", "0.6692067", "0.66853684", "0.66839325", "0.6655882", "0.66528964", "0.66520745", "0.6650353", "0.6645214", "0.6644083", "0.6609488", "0.6609488", "0.6594842", "0.65945...
0.64170676
34
This is pulled out into a seperate method so that users can subclass and implement custom behavior if they'd like around this step.
def run_provisioner(env, p) env[:ui].info(I18n.t("vagrant.actions.vm.provision.beginning", :provisioner => p.class)) p.provision end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def step_result; end", "def post_process; end", "def probers; end", "def process_hook\n fail 'sub class to implement'\n end", "def implementation; end", "def implementation; end", "def actual_flow_control\n super\n end", "def after_processing_hook; end", "d...
[ "0.6692238", "0.61403036", "0.5949928", "0.5897474", "0.5847374", "0.5760616", "0.5760616", "0.5760508", "0.5731504", "0.572959", "0.572959", "0.5680386", "0.56587213", "0.56447905", "0.56075484", "0.55971605", "0.5593752", "0.5593752", "0.5593752", "0.5593752", "0.5581336", ...
0.0
-1
Remove a follow relationship between two IDs. After removing the follow relationship, if a reciprocated relationship was established, it is also removed.
def unfollow(from_id, to_id, scope = Amico.default_scope_key) return if from_id == to_id Amico.redis.multi do Amico.redis.zrem("#{Amico.namespace}:#{Amico.following_key}:#{scope}:#{from_id}", to_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{to_id}", from_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.reciprocated_key}:#{scope}:#{from_id}", to_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.reciprocated_key}:#{scope}:#{to_id}", from_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.pending_key}:#{scope}:#{to_id}", from_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.pending_with_key}:#{scope}:#{from_id}", to_id) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unfollow!(followed)\n relationships.find_by_followed_id(followed).destroy\n end", "def unfollow!(followed)\n relationships.find_by_followed_id(followed).destroy\n end", "def unfollow! followee\n following_ids.delete(followee.id)\n save\n followee.followers_ids.delete(id)\n followee.save...
[ "0.7898308", "0.7898308", "0.769041", "0.7589246", "0.7477668", "0.7477668", "0.7477668", "0.7477668", "0.7477668", "0.747376", "0.7472315", "0.74639606", "0.7343247", "0.72945863", "0.7288015", "0.72876126", "0.72876126", "0.72876126", "0.7264604", "0.7218996", "0.7210503", ...
0.6911424
34
Block a relationship between two IDs. This method also has the side effect of removing any follower or following relationship between the two IDs.
def block(from_id, to_id, scope = Amico.default_scope_key) return if from_id == to_id Amico.redis.multi do Amico.redis.zrem("#{Amico.namespace}:#{Amico.following_key}:#{scope}:#{from_id}", to_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.following_key}:#{scope}:#{to_id}", from_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{to_id}", from_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{from_id}", to_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.reciprocated_key}:#{scope}:#{from_id}", to_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.reciprocated_key}:#{scope}:#{to_id}", from_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.pending_key}:#{scope}:#{from_id}", to_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.pending_with_key}:#{scope}:#{to_id}", from_id) Amico.redis.zadd("#{Amico.namespace}:#{Amico.blocked_key}:#{scope}:#{from_id}", Time.now.to_i, to_id) Amico.redis.zadd("#{Amico.namespace}:#{Amico.blocked_by_key}:#{scope}:#{to_id}", Time.now.to_i, from_id) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unfollow(actor)\n contact = contact_to!(actor)\n contact.update_column(:blocked, true)\n contact\n end", "def unfollow! followee\n following_ids.delete(followee.id)\n save\n followee.followers_ids.delete(id)\n followee.save\n end", "def unfollow! followee\n return if !following? f...
[ "0.6214617", "0.6188778", "0.6183963", "0.6145835", "0.6145835", "0.6145835", "0.6145835", "0.6145835", "0.6135299", "0.6124108", "0.60985476", "0.6095672", "0.60426825", "0.6026489", "0.601904", "0.5987848", "0.59754664", "0.59726083", "0.59726083", "0.59726083", "0.5914382"...
0.61992836
1
Unblock a relationship between two IDs.
def unblock(from_id, to_id, scope = Amico.default_scope_key) return if from_id == to_id Amico.redis.multi do Amico.redis.zrem("#{Amico.namespace}:#{Amico.blocked_key}:#{scope}:#{from_id}", to_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.blocked_by_key}:#{scope}:#{to_id}", from_id) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deny(from_id, to_id, scope = Amico.default_scope_key)\n return if from_id == to_id\n\n Amico.redis.multi do\n Amico.redis.zrem(\"#{Amico.namespace}:#{Amico.pending_key}:#{scope}:#{to_id}\", from_id)\n Amico.redis.zrem(\"#{Amico.namespace}:#{Amico.pending_with_key}:#{scope}:#{from_id}\",...
[ "0.66670734", "0.63743895", "0.6323058", "0.6293458", "0.62134653", "0.6190902", "0.6190902", "0.6190902", "0.6190902", "0.6190902", "0.6185119", "0.6156318", "0.61328137", "0.61322874", "0.61322874", "0.61322874", "0.6113368", "0.61068875", "0.61041003", "0.60555255", "0.604...
0.7186227
0
Accept a relationship that is pending between two IDs.
def accept(from_id, to_id, scope = Amico.default_scope_key) return if from_id == to_id add_following_followers_reciprocated(from_id, to_id, scope) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accept_friend(other_user)\n relationship = self.get_relationship(other_user)\n \n\tif relationship && (relationship.friend_status == \"PENDING\" || relationship.friend_status == \"IGNORED\") && relationship.followed_id == self.id\n\t\trelationship.friend_status = \"FRIENDS\"\n\t\trelationship.follow1 = t...
[ "0.6439175", "0.64124703", "0.64015967", "0.62280643", "0.62248874", "0.61797494", "0.61514026", "0.615102", "0.61062557", "0.61062557", "0.6104542", "0.6098769", "0.6083592", "0.60703677", "0.6024931", "0.6023909", "0.59956825", "0.5994353", "0.59805983", "0.59643865", "0.59...
0.592904
25
Deny a relationship that is pending between two IDs.
def deny(from_id, to_id, scope = Amico.default_scope_key) return if from_id == to_id Amico.redis.multi do Amico.redis.zrem("#{Amico.namespace}:#{Amico.pending_key}:#{scope}:#{to_id}", from_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.pending_with_key}:#{scope}:#{from_id}", to_id) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ignore(other) \n\trelationship = get_relationship(other)\n\t\n\tif relationship && relationship.friend_status == \"PENDING\" && relationship.followed_id == self.id\t\n\t\trelationship.friend_status = \"IGNORED\"\n\t\t\n\t\treturn relationship.save\n\tend\n\t\n\treturn false\n end", "def deny\n self.gran...
[ "0.6629563", "0.63356256", "0.6104841", "0.6062844", "0.60509604", "0.602478", "0.59960693", "0.5901403", "0.58730316", "0.58200264", "0.58033144", "0.57816887", "0.5770549", "0.5752425", "0.5714189", "0.56997275", "0.5684723", "0.5684723", "0.5672567", "0.5620559", "0.561937...
0.7208889
0
Clears all relationships (in either direction) stored for an individual. Helpful to prevent orphaned associations when deleting users.
def clear(id, scope = Amico.default_scope_key) # no longer following (or followed by) anyone clear_bidirectional_sets_for_id(id, Amico.following_key, Amico.followers_key, scope) clear_bidirectional_sets_for_id(id, Amico.followers_key, Amico.following_key, scope) clear_bidirectional_sets_for_id(id, Amico.reciprocated_key, Amico.reciprocated_key, scope) # no longer blocked by (or blocking) anyone clear_bidirectional_sets_for_id(id, Amico.blocked_by_key, Amico.blocked_key, scope) clear_bidirectional_sets_for_id(id, Amico.blocked_key, Amico.blocked_by_key, scope) # no longer pending with anyone (or have any pending followers) clear_bidirectional_sets_for_id(id, Amico.pending_with_key, Amico.pending_key, scope) clear_bidirectional_sets_for_id(id, Amico.pending_key, Amico.pending_with_key, scope) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_relationships\n @relationships = {}\n end", "def cleanup_relationships\n @involved_relationships = self.relationships\n @iterations = @involved_relationships.length\n @iterations.times do |i|\n @involved_relationships[i].destroy\n end\n end", "def cleanup_relationships\n ...
[ "0.7231386", "0.6853005", "0.6701454", "0.64956594", "0.64865106", "0.62541443", "0.62324667", "0.6220253", "0.61600614", "0.6107806", "0.6107806", "0.60999656", "0.60616827", "0.6053393", "0.60482705", "0.5973459", "0.59702384", "0.5956788", "0.5937949", "0.59238666", "0.589...
0.5691131
31
Count the number of individuals that someone is following.
def following_count(id, scope = Amico.default_scope_key) Amico.redis.zcard("#{Amico.namespace}:#{Amico.following_key}:#{scope}:#{id}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def following_users_count\n following_users.count\n end", "def count_user\n count = 0\n @f_net.each do |followees|\n count += 1 unless !followees or followees.empty?\n end\n count\n end", "def number_of_followees\n return_list_of_followed_users.size\n end", "def followers_count\n ...
[ "0.79499865", "0.78008795", "0.7708318", "0.76625466", "0.7660824", "0.76554346", "0.7640759", "0.7572536", "0.75253963", "0.74330664", "0.74059397", "0.73679996", "0.72587407", "0.7230062", "0.71394414", "0.7106871", "0.7092122", "0.7089058", "0.70848155", "0.708354", "0.705...
0.6698672
29
Count the number of individuals that are following someone.
def followers_count(id, scope = Amico.default_scope_key) Amico.redis.zcard("#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{id}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_user\n count = 0\n @f_net.each do |followees|\n count += 1 unless !followees or followees.empty?\n end\n count\n end", "def following_users_count\n following_users.count\n end", "def followees_count\n follow_count_for_a(:followee)\n end", "def count_followed\n\t\t#...
[ "0.7681316", "0.7564623", "0.75114816", "0.7485347", "0.74649477", "0.73755735", "0.7349754", "0.7334655", "0.7329856", "0.7319147", "0.7246802", "0.7167223", "0.7114111", "0.70987964", "0.7025611", "0.7024007", "0.6985444", "0.6971595", "0.68644136", "0.6845697", "0.6798311"...
0.6544097
30
Count the number of individuals that someone has blocked.
def blocked_count(id, scope = Amico.default_scope_key) Amico.redis.zcard("#{Amico.namespace}:#{Amico.blocked_key}:#{scope}:#{id}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total_blocked\n (blocked_friend_ids + blocked_inverse_friend_ids + blocked_pending_inverse_friend_ids).count\n end", "def total_blocked\n self.blockades(false).count + self.blockades_by(false).count\n end", "def block_count\n request('getblockcount')\n end", "def count_pending_act...
[ "0.7902847", "0.76193273", "0.65872735", "0.64954156", "0.64167786", "0.63741255", "0.6348261", "0.6333591", "0.6315477", "0.624976", "0.6233502", "0.6231536", "0.6231306", "0.6218641", "0.62072605", "0.6185848", "0.61559224", "0.614347", "0.6115282", "0.6103816", "0.6093572"...
0.66721094
2
Count the number of individuals blocking another.
def blocked_by_count(id, scope = Amico.default_scope_key) Amico.redis.zcard("#{Amico.namespace}:#{Amico.blocked_by_key}:#{scope}:#{id}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total_blocked\n (blocked_friend_ids + blocked_inverse_friend_ids + blocked_pending_inverse_friend_ids).count\n end", "def total_blocked\n self.blockades(false).count + self.blockades_by(false).count\n end", "def count\n @mutex.synchronize do\n count_nonsynchronize\n end\n ...
[ "0.7283741", "0.71406174", "0.65167826", "0.6428041", "0.6407467", "0.6250063", "0.6250063", "0.6220429", "0.62125844", "0.61863714", "0.6180957", "0.6103227", "0.6103227", "0.6103227", "0.60898167", "0.6069896", "0.6069896", "0.60668564", "0.6056422", "0.6039451", "0.6011039...
0.5588128
80
Count the number of individuals that have reciprocated a following relationship.
def reciprocated_count(id, scope = Amico.default_scope_key) Amico.redis.zcard("#{Amico.namespace}:#{Amico.reciprocated_key}:#{scope}:#{id}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_followed\n\t\t#relationships.where(follower_id: self.id).count\n\tend", "def count_follower\n\t\t#relationships.count - count_followed\n\n\tend", "def num_followers\n follower_ids = Following.where(:followed_id => self.id).pluck(:follower_id)\n follower_ids.size - 1 #don't count yourself\n en...
[ "0.78507394", "0.76381224", "0.72764534", "0.7271806", "0.7166176", "0.7033488", "0.70109737", "0.6973344", "0.6955643", "0.6866347", "0.6801921", "0.6784672", "0.6730865", "0.6712202", "0.6666428", "0.665787", "0.6640645", "0.66345453", "0.6605349", "0.65980655", "0.6535311"...
0.0
-1
Count the number of relationships pending for an individual.
def pending_count(id, scope = Amico.default_scope_key) Amico.redis.zcard("#{Amico.namespace}:#{Amico.pending_key}:#{scope}:#{id}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_of_associated_requests\n self.requests.functional.count\n end", "def relation_count(relation)\n relation.unordered.count\n end", "def count_followed\n\t\t#relationships.where(follower_id: self.id).count\n\tend", "def pending_count\n @pendings.size\n end", "def count_f...
[ "0.66057974", "0.6434496", "0.64215946", "0.63239187", "0.62017524", "0.61643624", "0.6102375", "0.60521585", "0.6031948", "0.6010566", "0.59756595", "0.59664226", "0.5957834", "0.59504396", "0.5906981", "0.5886443", "0.58608425", "0.58580333", "0.5852931", "0.5845966", "0.58...
0.5529222
58
Count the number of relationships an individual has pending with another.
def pending_with_count(id, scope = Amico.default_scope_key) Amico.redis.zcard("#{Amico.namespace}:#{Amico.pending_with_key}:#{scope}:#{id}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_of_associated_requests\n self.requests.functional.count\n end", "def relation_count(relation)\n relation.unordered.count\n end", "def count_followed\n\t\t#relationships.where(follower_id: self.id).count\n\tend", "def sibling_count(*args)\n sibling_rels(*args).size\n end", "de...
[ "0.6732639", "0.6700518", "0.6548332", "0.64769405", "0.64082766", "0.63885295", "0.63602453", "0.63476807", "0.6317857", "0.63152266", "0.6286762", "0.62213933", "0.61775136", "0.6175016", "0.609518", "0.60880005", "0.6069809", "0.60559356", "0.60482895", "0.60350615", "0.60...
0.0
-1
Check to see if one individual is following another individual.
def following?(id, following_id, scope = Amico.default_scope_key) !Amico.redis.zscore("#{Amico.namespace}:#{Amico.following_key}:#{scope}:#{id}", following_id).nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def following?(other)\n followings.include?(other)\n end", "def following?(other)\n following.include?(other)\n end", "def following?(other)\n\t\tfollowing.include?(other)\n\tend", "def following?(other)\n\t\tfollowing.include?(other)\n\tend", "def following?(other)\n \tfollowing.include?(other)\n...
[ "0.80800784", "0.8071535", "0.8043379", "0.8043379", "0.7911401", "0.78182805", "0.77815074", "0.77692044", "0.77582294", "0.7741815", "0.7731858", "0.7731858", "0.7731858", "0.7710684", "0.7698461", "0.7698461", "0.7698461", "0.7698461", "0.7636541", "0.7636541", "0.7636541"...
0.0
-1
Check to see if one individual is a follower of another individual.
def follower?(id, follower_id, scope = Amico.default_scope_key) !Amico.redis.zscore("#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{id}", follower_id).nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def followed_by?(other_user)\n followers.include?(other_user)\n end", "def following?(other_user)\n followeds.include?(other_user)\n end", "def followee?(other_user)\n followee_relationships.include?(other_user)\n end", "def followed_by?(user)\n followers.include?(user)\n end", "def...
[ "0.8524888", "0.8325504", "0.8319553", "0.8303069", "0.8206013", "0.81442654", "0.8127516", "0.8127516", "0.8127516", "0.81003636", "0.8088828", "0.8083071", "0.8083071", "0.8083071", "0.8083071", "0.8063952", "0.8061648", "0.8058305", "0.80552024", "0.80419326", "0.8015473",...
0.0
-1
Check to see if one individual has blocked another individual.
def blocked?(id, blocked_id, scope = Amico.default_scope_key) !Amico.redis.zscore("#{Amico.namespace}:#{Amico.blocked_key}:#{scope}:#{id}", blocked_id).nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_blockable_by(another_user)\n return false unless is_associated_to_somebody_else_than(another_user)\n\n existing_friendship = @swimmer.associated_user.find_any_friendship_with(another_user)\n !!(\n existing_friendship &&\n existing_friendship.can_block?(another_user)\n )\n end", "def...
[ "0.7263177", "0.71833354", "0.7052957", "0.70520437", "0.6934225", "0.6906497", "0.68520737", "0.6840296", "0.68190575", "0.6799869", "0.67430645", "0.6699037", "0.6692394", "0.669071", "0.66286033", "0.66172206", "0.6556786", "0.65567595", "0.65443796", "0.65384316", "0.6495...
0.62956464
30
Check to see if one individual is blocked by another individual.
def blocked_by?(id, blocked_by_id, scope = Amico.default_scope_key) !Amico.redis.zscore("#{Amico.namespace}:#{Amico.blocked_by_key}:#{scope}:#{id}", blocked_by_id).nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_blockable_by(another_user)\n return false unless is_associated_to_somebody_else_than(another_user)\n\n existing_friendship = @swimmer.associated_user.find_any_friendship_with(another_user)\n !!(\n existing_friendship &&\n existing_friendship.can_block?(another_user)\n )\n end", "def...
[ "0.7338266", "0.71892333", "0.7076254", "0.70239365", "0.6973509", "0.69537395", "0.6926183", "0.69153416", "0.6898225", "0.68111026", "0.67756486", "0.67363226", "0.67251617", "0.6702979", "0.66981363", "0.6646964", "0.6640122", "0.659738", "0.6596241", "0.6579674", "0.65775...
0.68181896
9
Check to see if one individual has reciprocated in following another individual.
def reciprocated?(from_id, to_id, scope = Amico.default_scope_key) following?(from_id, to_id, scope) && following?(to_id, from_id, scope) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def following?(other_person)\n following.include?(other_person)\n end", "def following?(other)\n\t\tfollowing.include?(other)\n\tend", "def following?(other)\n\t\tfollowing.include?(other)\n\tend", "def following?(other)\n following.include?(other)\n end", "def following?(other)\n \tfollowing.incl...
[ "0.70806146", "0.69745654", "0.69745654", "0.687593", "0.68455744", "0.6840048", "0.6835998", "0.6812765", "0.67881536", "0.67734265", "0.6765957", "0.67499983", "0.6740533", "0.6732174", "0.6732174", "0.6732174", "0.6703783", "0.6703783", "0.6703783", "0.6703783", "0.6682769...
0.7326558
0
Check to see if one individual has a pending relationship in following another individual.
def pending?(from_id, to_id, scope = Amico.default_scope_key) !Amico.redis.zscore("#{Amico.namespace}:#{Amico.pending_key}:#{scope}:#{to_id}", from_id).nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pending?(other_user)\n\trelationship = get_relationship(other_user)\n\t\n\treturn relationship && relationship.friend_status == \"PENDING\" && relationship.follower_id == self.id\n end", "def is_pending_for(another_user)\n return false unless is_associated_to_somebody_else_than(another_user)\n\n exist...
[ "0.81616056", "0.7407082", "0.72200185", "0.7121991", "0.7083858", "0.70676076", "0.70676076", "0.70399004", "0.7039678", "0.7033349", "0.70212954", "0.6965519", "0.696001", "0.6957973", "0.69574213", "0.693915", "0.69369715", "0.6934646", "0.69204694", "0.6918557", "0.691765...
0.0
-1
Check to see if one individual has a pending relationship with another.
def pending_with?(from_id, to_id, scope = Amico.default_scope_key) !Amico.redis.zscore("#{Amico.namespace}:#{Amico.pending_with_key}:#{scope}:#{to_id}", from_id).nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pending?(other_user)\n\trelationship = get_relationship(other_user)\n\t\n\treturn relationship && relationship.friend_status == \"PENDING\" && relationship.follower_id == self.id\n end", "def is_pending_for(another_user)\n return false unless is_associated_to_somebody_else_than(another_user)\n\n exist...
[ "0.7961612", "0.7779925", "0.7265851", "0.7210407", "0.72092646", "0.71053284", "0.7084974", "0.70730495", "0.7052666", "0.7043355", "0.70091367", "0.69954073", "0.6943243", "0.6909148", "0.687391", "0.6861155", "0.6850217", "0.6847696", "0.68472207", "0.6840004", "0.68378896...
0.7142303
5
Retrieve a page of followed individuals for a given ID.
def following(id, page_options = default_paging_options, scope = Amico.default_scope_key) members("#{Amico.namespace}:#{Amico.following_key}:#{scope}:#{id}", page_options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def followers(id, page_options = default_paging_options, scope = Amico.default_scope_key)\n members(\"#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{id}\", page_options)\n end", "def user_follows user_id, pages: 1\n url = API + \"users/#{user_id}/follows?access_token=\" + @access_token\n page...
[ "0.70647377", "0.6807277", "0.67080146", "0.667875", "0.6627378", "0.6591255", "0.6591112", "0.6591112", "0.6591112", "0.6590572", "0.6588292", "0.65644956", "0.65606403", "0.65551466", "0.65491736", "0.6544523", "0.65385425", "0.6531495", "0.6531495", "0.6528636", "0.652808"...
0.7111086
0
Retrieve a page of followers for a given ID.
def followers(id, page_options = default_paging_options, scope = Amico.default_scope_key) members("#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{id}", page_options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def followers(id)\n perform_request_with_collection(:get,\n \"/api/v1/accounts/#{id}/followers\",\n {}, Mastodon::Account)\n end", "def followers\n @title = 'Followers'\n @user = User.find(params[:id])\n @users = @...
[ "0.77935815", "0.76870793", "0.76677513", "0.76232636", "0.75311685", "0.74880874", "0.74699163", "0.74618435", "0.72996724", "0.7268132", "0.7250156", "0.72138786", "0.72105587", "0.7163879", "0.715725", "0.7147379", "0.7145428", "0.7145428", "0.7140678", "0.7137445", "0.713...
0.81680113
0
Retrieve a page of blocked individuals for a given ID.
def blocked(id, page_options = default_paging_options, scope = Amico.default_scope_key) members("#{Amico.namespace}:#{Amico.blocked_key}:#{scope}:#{id}", page_options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def blocked_by(id, page_options = default_paging_options, scope = Amico.default_scope_key)\n members(\"#{Amico.namespace}:#{Amico.blocked_by_key}:#{scope}:#{id}\", page_options)\n end", "def blocked_by_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)\n total_pages(\"#{Ami...
[ "0.7559969", "0.65293294", "0.60746914", "0.59503835", "0.59005064", "0.57456356", "0.5724006", "0.5645058", "0.55988115", "0.55758446", "0.5568558", "0.54725355", "0.54427665", "0.54057646", "0.5377862", "0.53293484", "0.5302526", "0.52985126", "0.5292067", "0.52423227", "0....
0.7497722
1
Retrieve a page of individuals who have blocked a given ID.
def blocked_by(id, page_options = default_paging_options, scope = Amico.default_scope_key) members("#{Amico.namespace}:#{Amico.blocked_by_key}:#{scope}:#{id}", page_options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def blocked(id, page_options = default_paging_options, scope = Amico.default_scope_key)\n members(\"#{Amico.namespace}:#{Amico.blocked_key}:#{scope}:#{id}\", page_options)\n end", "def blocked_by_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)\n total_pages(\"#{Amico.nam...
[ "0.7659548", "0.64732045", "0.6296363", "0.6252048", "0.6059477", "0.60572356", "0.6056649", "0.6021041", "0.6015493", "0.5981693", "0.59098727", "0.57759315", "0.57334954", "0.5707712", "0.56008667", "0.55722934", "0.54888594", "0.545949", "0.5417788", "0.5394472", "0.534400...
0.7724767
0
Retrieve a page of individuals that have reciprocated a follow for a given ID.
def reciprocated(id, page_options = default_paging_options, scope = Amico.default_scope_key) members("#{Amico.namespace}:#{Amico.reciprocated_key}:#{scope}:#{id}", page_options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def followers(id, page_options = default_paging_options, scope = Amico.default_scope_key)\n members(\"#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{id}\", page_options)\n end", "def following(id, page_options = default_paging_options, scope = Amico.default_scope_key)\n members(\"#{Amico.names...
[ "0.69120437", "0.6808189", "0.66692436", "0.6662108", "0.6627988", "0.66249996", "0.6555427", "0.6510497", "0.6500891", "0.6500891", "0.6500891", "0.65002817", "0.6491711", "0.6482179", "0.6466226", "0.6462704", "0.6451794", "0.6451794", "0.6447956", "0.6436626", "0.6427233",...
0.57765436
89
Retrieve a page of pending relationships for a given ID.
def pending(id, page_options = default_paging_options, scope = Amico.default_scope_key) members("#{Amico.namespace}:#{Amico.pending_key}:#{scope}:#{id}", page_options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_relationship_by_id id\n headers = {\n 'Accept' => 'application/json; charset=UTF-8',\n }\n get_request 'relationship/' + id, headers\n end", "def pending_with(id, page_options = default_paging_options, scope = Amico.default_scope_key)\n members(\"#{Amico.namespace}:#{Amico.pending_wit...
[ "0.6751918", "0.64593375", "0.59076715", "0.58977735", "0.5823119", "0.577999", "0.5770479", "0.5766247", "0.57268393", "0.56692976", "0.56596255", "0.5605578", "0.55814093", "0.55709666", "0.55706674", "0.5570154", "0.5543523", "0.55164057", "0.55153644", "0.5504997", "0.541...
0.6610361
1
Retrieve a page of individuals that are waiting to approve the given ID.
def pending_with(id, page_options = default_paging_options, scope = Amico.default_scope_key) members("#{Amico.namespace}:#{Amico.pending_with_key}:#{scope}:#{id}", page_options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pending(id, page_options = default_paging_options, scope = Amico.default_scope_key)\n members(\"#{Amico.namespace}:#{Amico.pending_key}:#{scope}:#{id}\", page_options)\n end", "def pending\n @ledger_entries = @organization.ledger_entries.uninvoiced.page(params[:page])\n respond_with @organizati...
[ "0.62130255", "0.5809117", "0.56902575", "0.55989134", "0.55843", "0.55398303", "0.551169", "0.5506112", "0.5495496", "0.5456651", "0.54244167", "0.54041606", "0.53732413", "0.5291241", "0.5271655", "0.5257509", "0.5253372", "0.52321684", "0.52281576", "0.52253056", "0.519547...
0.6223034
0
Count the number of pages of following relationships for an individual.
def following_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key) total_pages("#{Amico.namespace}:#{Amico.following_key}:#{scope}:#{id}", page_size) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_follower\n\t\t#relationships.count - count_followed\n\n\tend", "def followers_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)\n total_pages(\"#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{id}\", page_size)\n end", "def count_followed\n\t\t#relationships.whe...
[ "0.725657", "0.7243671", "0.71301067", "0.69318", "0.6915136", "0.68657243", "0.67346066", "0.6716392", "0.66892856", "0.6649978", "0.6637543", "0.66212595", "0.6586803", "0.65716136", "0.65386903", "0.6489586", "0.64892423", "0.647186", "0.64465564", "0.6441544", "0.6408109"...
0.7639435
0
Count the number of pages of follower relationships for an individual.
def followers_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key) total_pages("#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{id}", page_size) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def followers_count\n follow_count_for_a(:follower)\n end", "def count_follower\n\t\t#relationships.count - count_followed\n\n\tend", "def following_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)\n total_pages(\"#{Amico.namespace}:#{Amico.following_key}:#{scope}:#...
[ "0.77816784", "0.75035834", "0.74213254", "0.73865825", "0.7292", "0.7288523", "0.71825475", "0.71256036", "0.7081986", "0.7010417", "0.697991", "0.69740677", "0.68702066", "0.6797758", "0.67083937", "0.6700919", "0.66981775", "0.66476786", "0.6508601", "0.6503532", "0.648286...
0.78961116
0
Count the number of pages of blocked relationships for an individual.
def blocked_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key) total_pages("#{Amico.namespace}:#{Amico.blocked_key}:#{scope}:#{id}", page_size) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def blocked_by_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)\n total_pages(\"#{Amico.namespace}:#{Amico.blocked_by_key}:#{scope}:#{id}\", page_size)\n end", "def total_blocked\n (blocked_friend_ids + blocked_inverse_friend_ids + blocked_pending_inverse_friend_ids).coun...
[ "0.6667772", "0.6601462", "0.60395795", "0.59553164", "0.59497356", "0.59091884", "0.59039104", "0.58574957", "0.58569944", "0.58072543", "0.57809895", "0.5744002", "0.57414985", "0.5720482", "0.5705054", "0.5705054", "0.5705054", "0.5705054", "0.56832236", "0.5654439", "0.56...
0.69081813
0
Count the number of pages of blocked_by relationships for an individual.
def blocked_by_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key) total_pages("#{Amico.namespace}:#{Amico.blocked_by_key}:#{scope}:#{id}", page_size) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def blocked_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)\n total_pages(\"#{Amico.namespace}:#{Amico.blocked_key}:#{scope}:#{id}\", page_size)\n end", "def total_blocked\n (blocked_friend_ids + blocked_inverse_friend_ids + blocked_pending_inverse_friend_ids).count\n ...
[ "0.696579", "0.6389266", "0.5903771", "0.5822773", "0.5736851", "0.5711893", "0.5684721", "0.5662139", "0.5660336", "0.5660336", "0.5660336", "0.5660336", "0.5632619", "0.56217873", "0.5566041", "0.5554587", "0.55054104", "0.55040795", "0.54995763", "0.5496462", "0.5446335", ...
0.6867875
1
Count the number of pages of reciprocated relationships for an individual.
def reciprocated_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key) total_pages("#{Amico.namespace}:#{Amico.reciprocated_key}:#{scope}:#{id}", page_size) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def page_count(id, type, page_size = Amico.page_size, scope = Amico.default_scope_key)\n validate_relationship_type(type)\n self.send(\"#{type.to_s}_page_count\".to_sym, id, page_size, scope)\n end", "def sibling_count(*args)\n sibling_rels(*args).size\n end", "def child_count(*args)\n chil...
[ "0.6624459", "0.63115025", "0.62864375", "0.61483", "0.6146385", "0.6104838", "0.603148", "0.60083413", "0.59831935", "0.592118", "0.5920037", "0.5891581", "0.5867696", "0.5865497", "0.5837271", "0.5819712", "0.5810152", "0.580799", "0.5798844", "0.5781831", "0.5738132", "0...
0.6712069
0
Count the number of pages of pending relationships for an individual.
def pending_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key) total_pages("#{Amico.namespace}:#{Amico.pending_key}:#{scope}:#{id}", page_size) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pending_with_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)\n total_pages(\"#{Amico.namespace}:#{Amico.pending_with_key}:#{scope}:#{id}\", page_size)\n end", "def page_count(id, type, page_size = Amico.page_size, scope = Amico.default_scope_key)\n validate_relations...
[ "0.6737193", "0.67110467", "0.6701324", "0.6303896", "0.6298906", "0.6280998", "0.62712115", "0.62631536", "0.61895704", "0.6139227", "0.6137278", "0.61343974", "0.61205566", "0.60655457", "0.60655457", "0.60655457", "0.60655457", "0.6056751", "0.60435045", "0.6038678", "0.60...
0.679254
0
Count the number of pages of individuals waiting to approve another individual.
def pending_with_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key) total_pages("#{Amico.namespace}:#{Amico.pending_with_key}:#{scope}:#{id}", page_size) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def approvals_count\n return 0 if self.id.nil?\n return RequestSearch.approvals_for(self, show: 'pending', per_page: 1000).count\n end", "def count_pending_actions\n # count actions pour navbar\n # les created dans le cas ou qqun a fait une résa sur ma pool\n # les accepted dans le cas ou j'ai fa...
[ "0.67311716", "0.65390086", "0.61767226", "0.5965471", "0.59399545", "0.59314084", "0.5917304", "0.59137744", "0.5885227", "0.5861176", "0.58250725", "0.579158", "0.57539016", "0.57169247", "0.56863934", "0.56747234", "0.56718934", "0.5665991", "0.566282", "0.5657025", "0.562...
0.6138446
3
Retrieve all of the individuals for a given id, type (e.g. following) and scope
def all(id, type, scope = Amico.default_scope_key) validate_relationship_type(type) count = self.send("#{type.to_s}_count".to_sym, id, scope) count > 0 ? self.send("#{type}", id, {:page_size => count}, scope) : [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_assignments(type, id)\n\t\tassignments = Array.new\n\t\t\n # Gather all assignments with this 'id' in the 'type' column\n\t\tlist = Relationship.where({ type.to_s => id })\n\n # In each assignment\n\t\tlist.each do |relationship|\n # Gather human readable parts\n assignm...
[ "0.5906065", "0.5636222", "0.5619705", "0.561569", "0.5565869", "0.55269235", "0.55227154", "0.5425901", "0.5406392", "0.54011595", "0.5398981", "0.53897506", "0.53713286", "0.53653544", "0.53510016", "0.53411657", "0.52689606", "0.524417", "0.5236477", "0.5224294", "0.521923...
0.6739063
0
Retrieve a count of all of a given type of relationship for the specified id.
def count(id, type, scope = Amico.default_scope_key) validate_relationship_type(type) self.send("#{type.to_s}_count".to_sym, id, scope) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all(id, type, scope = Amico.default_scope_key)\n validate_relationship_type(type)\n count = self.send(\"#{type.to_s}_count\".to_sym, id, scope)\n count > 0 ? self.send(\"#{type}\", id, {:page_size => count}, scope) : []\n end", "def page_count(id, type, page_size = Amico.page_size, scope = ...
[ "0.7044735", "0.6784218", "0.6511063", "0.6511063", "0.59612507", "0.59399533", "0.57885224", "0.57270986", "0.5668995", "0.56625473", "0.5634161", "0.55773383", "0.5554384", "0.55317605", "0.55282325", "0.5520082", "0.5490186", "0.54386705", "0.54079056", "0.5407688", "0.540...
0.79353553
0
Retrieve a page count of a given type of relationship for the specified id.
def page_count(id, type, page_size = Amico.page_size, scope = Amico.default_scope_key) validate_relationship_type(type) self.send("#{type.to_s}_page_count".to_sym, id, page_size, scope) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count(id, type, scope = Amico.default_scope_key)\n validate_relationship_type(type)\n self.send(\"#{type.to_s}_count\".to_sym, id, scope)\n end", "def following_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)\n total_pages(\"#{Amico.namespace}:#{Amico.following_...
[ "0.7540268", "0.642223", "0.6163219", "0.61014324", "0.60739195", "0.58753633", "0.57231915", "0.5711562", "0.56790817", "0.5663774", "0.5663774", "0.56171227", "0.5573387", "0.55159265", "0.5509635", "0.5451931", "0.541836", "0.53664255", "0.53431493", "0.53196007", "0.53071...
0.833794
0
Add the following, followers and check for a reciprocated relationship. To be used from the +follow+ and +accept+ methods.
def add_following_followers_reciprocated(from_id, to_id, scope) Amico.redis.multi do Amico.redis.zadd("#{Amico.namespace}:#{Amico.following_key}:#{scope}:#{from_id}", Time.now.to_i, to_id) Amico.redis.zadd("#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{to_id}", Time.now.to_i, from_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.pending_key}:#{scope}:#{to_id}", from_id) Amico.redis.zrem("#{Amico.namespace}:#{Amico.pending_with_key}:#{scope}:#{from_id}", to_id) end if reciprocated?(from_id, to_id, scope) Amico.redis.multi do Amico.redis.zadd("#{Amico.namespace}:#{Amico.reciprocated_key}:#{scope}:#{from_id}", Time.now.to_i, to_id) Amico.redis.zadd("#{Amico.namespace}:#{Amico.reciprocated_key}:#{scope}:#{to_id}", Time.now.to_i, from_id) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def follow!(followed)\n self.relationships.create!(:followed_id => followed.id)\n end", "def follow! (other)\n\t\tself.relationships.create!(followed_id: other.id)\n\tend", "def follow(user)\n user.add_follower(self)\n self\n end", "def follow! followee\n return if following? followee\n foll...
[ "0.7136997", "0.70573986", "0.7040938", "0.7012338", "0.69556516", "0.6911555", "0.6901265", "0.68902487", "0.6880399", "0.6845872", "0.6840733", "0.68378866", "0.68351513", "0.683107", "0.6822386", "0.68173873", "0.67967623", "0.67967373", "0.67967373", "0.67967373", "0.6796...
0.6468713
58
Removes references to an individual in sets that are named with other individual's keys. Assumes two set keys that are used together such as followers/following, blocked/blocked_by, etc...
def clear_bidirectional_sets_for_id(id, source_set_key, related_set_key, scope = Amico.default_scope_key) Amico.redis.zrange("#{Amico.namespace}:#{source_set_key}:#{scope}:#{id}", 0, -1).each do |related_id| Amico.redis.zrem("#{Amico.namespace}:#{related_set_key}:#{scope}:#{related_id}", id) end Amico.redis.del("#{Amico.namespace}:#{source_set_key}:#{scope}:#{id}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def difference(other_set)\n new_set = @set\n # Delete elements from our array that are in the other set\n other_set.set.each do |element|\n new_set.delete(element)\n end\n Set.new(new_set)\n end", "def apply_set_membership(sets)\n\t\t#We delete previous set memberships and move to new set\n ...
[ "0.650919", "0.6395487", "0.6357212", "0.6345165", "0.63103217", "0.63103217", "0.6206554", "0.61609465", "0.6013179", "0.59848726", "0.59790283", "0.5977989", "0.5956968", "0.59469426", "0.5860992", "0.5806567", "0.57968366", "0.5788222", "0.5788222", "0.57773507", "0.574075...
0.6316518
4
Count the total number of pages for a given key in a Redis sorted set.
def total_pages(key, page_size) (Amico.redis.zcard(key) / page_size.to_f).ceil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count\n with_redis { |redis| redis.scard(@set_key).to_i }\n end", "def count\n redis { |conn| conn.llen(key) }\n end", "def count(key)\n Sidekiq.redis do |conn|\n conn.llen(namespace_key(key))\n end\n end", "def count(key)\n @counter[key]\n ...
[ "0.7102254", "0.7022856", "0.69178176", "0.6826132", "0.6484473", "0.629995", "0.6137414", "0.6098832", "0.6087545", "0.6086041", "0.6084303", "0.6075133", "0.60722005", "0.60722005", "0.60523856", "0.6042444", "0.60300297", "0.598849", "0.59577626", "0.5928913", "0.58935976"...
0.728351
0
Retrieve a page of items from a Redis sorted set without scores.
def members(key, options = default_paging_options) options = default_paging_options.dup.merge!(options) if options[:page] < 1 options[:page] = 1 end if options[:page] > total_pages(key, options[:page_size]) options[:page] = total_pages(key, options[:page_size]) end index_for_redis = options[:page] - 1 starting_offset = (index_for_redis * options[:page_size]) if starting_offset < 0 starting_offset = 0 end ending_offset = (starting_offset + options[:page_size]) - 1 Amico.redis.zrevrange(key, starting_offset, ending_offset, :with_scores => false) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_all(qps=DEFAULT_QUERIES_PER_SECOND)\n response = execute\n items = response['items']\n\n while response['current_page'] < response['total_pages']\n self.page = response['current_page'] + 1\n response = execute\n items = items + response['items']\n \n slee...
[ "0.6009584", "0.6007164", "0.5796745", "0.5794739", "0.5708367", "0.56096935", "0.55868405", "0.55476755", "0.5520276", "0.54998785", "0.5469254", "0.5466713", "0.54616195", "0.53990084", "0.5389684", "0.53752345", "0.5364665", "0.5357987", "0.53571117", "0.53438795", "0.5336...
0.66700906
0
parses the body to an object
def object instance_variable_defined?(:@object) ? @object : @object = begin if media_type == 'application/json' JSON.parse(body) rescue nil elsif media_type == 'application/x-www-form-urlencoded' CGI.parse(body).map { |k, vs| {k => vs.last} }.inject({}, &:update) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_body\n JSON.load(body)\n end", "def parsed_body\n @body\n end", "def parse_body\n request.body.rewind\n Oj.load request.body.read\n end", "def parsed_body\n @parsed_body ||= JSON.parse(@body, symbolize_names: true)\n end", "def parsed_body\n @parsed_body ...
[ "0.76344806", "0.7611568", "0.7600306", "0.7499666", "0.7330663", "0.72470206", "0.6852725", "0.68241394", "0.68051565", "0.669075", "0.66766334", "0.6649839", "0.6646492", "0.65728545", "0.65585107", "0.6552282", "0.6542004", "0.65324235", "0.65296996", "0.6500567", "0.65005...
0.6989233
6
deal with the vagaries of getting the response body in a form which JSON gem will not cry about generating
def jsonifiable @jsonifiable ||= Body.new(catch(:jsonifiable) do original_body = self.body unless original_body.is_a?(String) begin # if the response body is not a string, but JSON doesn't complain # about dumping whatever it is, go ahead and use it JSON.generate([original_body]) throw :jsonifiable, original_body rescue # otherwise return nil - don't know what to do with whatever this object is throw :jsonifiable, nil end end # first try to change the string's encoding per the Content-Type header body = original_body.dup unless body.valid_encoding? # I think this always comes in as ASCII-8BIT anyway so may never get here. hopefully. body.force_encoding('ASCII-8BIT') end content_type_attrs = ContentTypeAttrs.new(content_type) if content_type_attrs.parsed? charset = content_type_attrs['charset'].first if charset && Encoding.list.any? { |enc| enc.to_s.downcase == charset.downcase } if body.dup.force_encoding(charset).valid_encoding? body.force_encoding(charset) else # I guess just ignore the specified encoding if the result is not valid. fall back to # something else below. end end end begin JSON.generate([body]) rescue Encoding::UndefinedConversionError # if updating by content-type didn't do it, try UTF8 since JSON wants that - but only # if it seems to be valid utf8. # don't try utf8 if the response content-type indicated something else. try_utf8 = !(content_type_attrs && content_type_attrs.parsed? && content_type_attrs['charset'].any? { |cs| !['utf8', ''].include?(cs.downcase) }) if try_utf8 && body.dup.force_encoding('UTF-8').valid_encoding? body.force_encoding('UTF-8') else # I'm not sure if there is a way in this situation to get JSON gem to generate the # string correctly. fall back to an array of codepoints I guess? this is a weird # solution but the best I've got for now. body = body.codepoints.to_a end end body end, content_type) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def response_body; end", "def response_body; end", "def json_body\n @json_body ||= Response.prepare_json_object(JSON.parse(body))\n end", "def response_body\n JSON.parse(response.body, symbolize_names: true)\n end", "def body\n JSON.parse(@response.body) unless @response.body.empty?\n ...
[ "0.74772424", "0.74772424", "0.70599055", "0.70175064", "0.69880694", "0.69880694", "0.69434935", "0.6942472", "0.6925903", "0.68684614", "0.68676984", "0.68354696", "0.682027", "0.68074644", "0.67771333", "0.6746651", "0.6745203", "0.67258203", "0.67258203", "0.67258203", "0...
0.6019225
96
Check if the game is over
def game_over? @life <= 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def over?\n \t@game_over = true\n end", "def game_over?\n true\n end", "def gameIsOver\n\t\treturn frameNumber() > @lastFrameNumber\n\tend", "def game_over\n end", "def game_is_over?\n (won? || draw? || full?) ? true : false\n end", "def game_over\n remaining_player.count == ...
[ "0.8881154", "0.8776892", "0.8162593", "0.80965585", "0.7995665", "0.7977663", "0.7921939", "0.79109085", "0.78492105", "0.7848183", "0.7847344", "0.78417605", "0.77903575", "0.77829564", "0.7772392", "0.7770994", "0.77600515", "0.77516675", "0.7746114", "0.7745898", "0.77392...
0.0
-1
Check for a winner
def win? if @player1.life == 0 sleep(1) puts "-- GAME OVER --" sleep(1) puts "#{@player2.name} wins!" sleep(1) elsif @player2.life == 0 sleep(1) puts "-- GAME OVER --" sleep(1) puts "#{@player1.name} wins!" sleep(1) else turn end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_winner\n cells_t = cells.transpose\n row_winner(cells)\n row_winner(cells_t)\n diagonal_winner unless winner\n announce_winner if winner\n winner\n end", "def check_winner\n if win_state == CHECK\n if players[0].get_hand_score >= players[1].get_hand_score\n self.win_st...
[ "0.8227301", "0.8089776", "0.8068036", "0.80216503", "0.7929976", "0.7890672", "0.78798634", "0.78670496", "0.7857331", "0.78334934", "0.78313494", "0.77997607", "0.77993804", "0.7795072", "0.77717626", "0.776283", "0.7761269", "0.77528477", "0.7748341", "0.77199715", "0.7707...
0.0
-1
output: rotated integer n = 1 returns original number n is always positive integer n > 1 returns new number data structure: integer algo: convert long integer into an array use rotate_array method from before modify method to take two arguments use second argument as index for array
def rotate_array(array) array[1..-1] + [array[0]] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_rotation(int)\n arr = int.digits.reverse\n arrdup = arr.dup # this code works without reduces whats deleted/pushed in.\n result = []\n arrdup.each.with_index do |_,idx|\n arr << arr[idx]\n arr.delete_at(idx)\n result = arr\n end\n result.join.to_i\nend", "def my_rotate!(array, amt)\n\nend"...
[ "0.72322583", "0.7227049", "0.72040826", "0.7139214", "0.70695966", "0.7035924", "0.6998251", "0.69627357", "0.6956273", "0.68989235", "0.68429434", "0.684156", "0.68353605", "0.6807166", "0.6799606", "0.67907566", "0.6777554", "0.67557055", "0.67516863", "0.67282444", "0.664...
0.62492144
98
end of additional data_passthroughs
def best_description if description? description else additional_description end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_data(data); end", "def run_with_data( data )\n fail \"Implement #run_with_data in #{self.class.name}.\"\n end", "def data=(_arg0); end", "def data=(_arg0); end", "def data=(_arg0); end", "def data=(_arg0); end", "def data(*args); end", "def data; end", "def data; end", "def...
[ "0.6853936", "0.63504785", "0.6271433", "0.6271433", "0.6271433", "0.6271433", "0.6269087", "0.62453717", "0.62453717", "0.62453717", "0.62453717", "0.62453717", "0.62453717", "0.62453717", "0.62453717", "0.62453717", "0.62453717", "0.62453717", "0.62453717", "0.6181645", "0....
0.0
-1
def self.merge(ports) ports = ports.compact return if ports.size <= 1 end
def to_param "#{id}-#{title.gsub(/[^\w]/, '-')}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ports *ports\n @ports = *ports unless ports.length == 0\n @ports\n end", "def ports\n # prevent original array from being changed\n @ports.dup\n end", "def combine_ports(other)\n # In this case, they should be identical, we just return self\n if !@ports and !other.po...
[ "0.6897545", "0.6673435", "0.6554373", "0.6077088", "0.5991702", "0.59231794", "0.5887619", "0.5877095", "0.58320564", "0.5713606", "0.5702966", "0.55009973", "0.5438214", "0.5420562", "0.54156065", "0.5335111", "0.527477", "0.52471226", "0.5239307", "0.5228393", "0.5217851",...
0.0
-1
return [probe, guid, key, meterid]
def parse_composite_key( ckey) kparts = ckey.split('/') if kparts[1]=="all_probes" kparts[1]="" end req_types = ["counters","fts","resources","sessions","alerts"] default_req_type="counters" if req_types.include?(kparts[2].downcase) default_req_type = kparts.delete_at(2) end if kparts[4] && kparts[4].match(/\(.*\)/) kparts[4] = kparts[4].split(/\(|\)/).last end kparts [4] = kparts[4] || 0 case default_req_type when "counters" ret = { :probe_id => kparts[1], :key => kparts[3], :meter => kparts[4].to_i, :counter_group => "", :meter_units => "", :meter_desc=>"", :meter_type => 4, :topper_bucket_size => 300, :bucket_size => 60 } if kparts[5] and (JSON.parse(kparts[5]) rescue nil) ret[:extra_options] = JSON.parse(kparts[5]) end # counter matching needs round trip use longest match, req =mk_request(TRP::Message::Command::COUNTER_GROUP_INFO_REQUEST, :get_meter_info => true ) get_response_zmq(@zmq_endpoint,req) do |resp| resp.group_details .sort{ |a,b| a.name.length <=> b.name.length} .each do |g| if g.name.downcase.start_with?(kparts[2].downcase) ret[:counter_group]=g.guid ret[:counter_group_name]=g.name ret[:bucket_size]=g.bucket_size ret[:topper_bucket_size]=g.topper_bucket_size ret[:meter_units]=g.meters[ ret[:meter]].units ret[:meter_type]=g.meters[ ret[:meter]].type ret[:meter_desc]=g.meters[ ret[:meter]].description break end end end return ret when "alerts" alert_group = "{9AFD8C08-07EB-47E0-BF05-28B4A7AE8DC9}" if kparts[2].downcase == "Badfellas".downcase alert_group = "{5E97C3A3-41DB-4E34-92C3-87C904FAB83E}" end return { alert_group:alert_group, alert_group_name:"IDS Alerts" } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fingerprints(key)\n unless @@vendors[key].nil? || (capability_lists = @@vendors[key][:capabilities]).nil?\n capability_lists.collect { |capability_ids|\n # get real names of capabilities and create ImapCapabilityArray\n Base::ImapCapabilityArray.new(capability_ids....
[ "0.57479215", "0.570767", "0.5652065", "0.55915236", "0.5567377", "0.5504809", "0.54598653", "0.5454081", "0.5454081", "0.5454081", "0.5416284", "0.5385521", "0.5356934", "0.5356934", "0.5356934", "0.53451645", "0.5339676", "0.5329319", "0.53173006", "0.5309074", "0.53055334"...
0.0
-1
Initialize new instance of model. settings Hash of attribute settings. Returns new model instance.
def initialize(settings={}) @table = {} settings.each do |k,v| s = "#{k}=".gsub('-','_') __send__(s,v) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new(attrs = {})\n instance = super()\n instance.load_attributes!\n instance.update(attrs)\n instance\n end", "def new(attrs = {})\n obj = self.model.new\n attrs.each do |k,v|\n obj.send(\"#{k}=\", v)\n end\n obj\n end", "def initial...
[ "0.7034142", "0.6950472", "0.66082996", "0.65403736", "0.63545126", "0.6299981", "0.62892383", "0.62892383", "0.62892383", "0.6263771", "0.6258456", "0.62584007", "0.62535805", "0.62134326", "0.6144754", "0.614293", "0.6137206", "0.6125636", "0.6094021", "0.6088602", "0.60837...
0.5623104
80
Fetch attribute. key String of attribute's name. Returns attribute value.
def [](key) @table[key.to_s] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_attribute(key)\n @attributes[key.to_sym]\n end", "def read_attribute(key)\n @attributes[key]\n end", "def read_attribute(key)\n @attributes[key]\n end", "def [](attr_name)\n @attributes.fetch_value(attr_name.to_s)\n end", "def read_attribute(key)\n @hash[key.to_s...
[ "0.8026507", "0.7945645", "0.7945645", "0.78797543", "0.7802166", "0.7759055", "0.7625808", "0.7528063", "0.75144494", "0.74208605", "0.7397622", "0.7397622", "0.73932964", "0.73822343", "0.73738337", "0.7310773", "0.7310773", "0.7306833", "0.7304933", "0.72844166", "0.725707...
0.0
-1
Store attribute. key String of attribute's name. value Object as value of attribute. Returns attribute value.
def []=(k,v) @table[k.to_s] = v end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_attribute(key, value)\n @hash[key.to_s] = value\n end", "def write_attribute(key, value)\n @attributes[key] = value\n end", "def set attribute, value\n attributes[attribute] = value\n end", "def attribute=(name, value)\n @attributes ||= {}\n @attributes[name] = val...
[ "0.7566497", "0.7537928", "0.73356754", "0.71846324", "0.71771365", "0.71771365", "0.7146756", "0.70774156", "0.70643705", "0.7048946", "0.7048946", "0.70467865", "0.70467865", "0.70033604", "0.6995292", "0.69564223", "0.6953279", "0.6953279", "0.6949737", "0.6915799", "0.690...
0.0
-1
Convert attributes to hash, including all nested object that repsond to to_h. Returns Hash of attribute's keyvalue pairs.
def to_h t = {} @table.each do |k,v| if v.respond_to?(:to_h) t[k] = v.to_h else t[k] = v end end t end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_h\n hash = {}\n attributes.each_pair do |key, value|\n hash[key] = deep_unwrap(value)\n end\n\n return hash\n end", "def to_hash\n {}.tap do |hash|\n _attributes.each do |key, value|\n if key == :data\n hash.merge!(value)\n else\n hash[...
[ "0.87522113", "0.82633317", "0.8226998", "0.8194341", "0.8188578", "0.81390035", "0.811494", "0.8096471", "0.8083204", "0.807712", "0.80168694", "0.8014389", "0.80007863", "0.799741", "0.79731023", "0.797222", "0.79577017", "0.79577017", "0.79577017", "0.79577017", "0.7957701...
0.0
-1
Type of documentation entry. Valid types are `document`, `script`, `method`, `class_method`, `constant` and, for one entry only, `(metadata)`. Retuns String of documentation entry type.
def type self['!'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def type\n DocInfoClasses.key(self.class)\n end", "def type_name\n \"_doc\"\n end", "def type ; metadata[:type] ; end", "def doc_type\n DOC_TYPES[self.TipoDoc.to_sym]\n end", "def type\n @type.to_s\n end", "def type\n @type || @document.root.attributes[\"type\"] || @doc...
[ "0.7329376", "0.7011192", "0.6862396", "0.65840006", "0.63256645", "0.63151354", "0.63098323", "0.63069636", "0.6280554", "0.62780327", "0.626085", "0.621257", "0.62097126", "0.61971503", "0.6159595", "0.6130018", "0.6112331", "0.6094591", "0.6094591", "0.6067126", "0.6067126...
0.0
-1
Create a new UnlessTag.
def initialize( body, linenum=nil, colnum=nil ) @inverted = false super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def form_element_unless(condition, *args, &block)\n form_element(*args, &block) unless condition\n end", "def unless!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 68 )\n\n type = UNLESS\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - ...
[ "0.58604497", "0.58290315", "0.56890476", "0.56660336", "0.537656", "0.53223777", "0.5278363", "0.5253857", "0.52415377", "0.5237449", "0.5214301", "0.5182017", "0.51763964", "0.51704824", "0.5153444", "0.5144857", "0.5114194", "0.5109533", "0.5100094", "0.5085615", "0.506603...
0.0
-1
Render the tag's contents if the condition is true, or any else or elsif sections if the condition isn't true.
def render( state ) evaluated_state = self.evaluate( state ) evaluated_state = ! evaluated_state if self.inverted # Start out with rendering *disabled* if the tag body evaluates trueishly if evaluated_state self.log.debug "Initial state was TRUE; disabling rendering" state.disable_rendering else self.log.debug "Initial state was FALSE; enabling rendering" state.enable_rendering end # Set the tag state to track whether or not rendering has been enabled during the # 'unless' for an 'else' tag. state.with_tag_data( :rendering_was_enabled => state.rendering_enabled? ) do self.render_subnodes( state ) end state.enable_rendering return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_contents( template, scope )\n\t\tcond = hasBeenTrue = self.evaluate( template, scope )\n\n\t\tnodes = []\n\t\t\n\t\t# Now splice out the chunk of nodes that should be rendered based on\n\t\t# the conditional.\n\t\t@subnodes.each do |node|\n\t\t\tcase node\n\t\t\twhen Arrow::Template::ElsifDirective\n\t\...
[ "0.71867895", "0.6622622", "0.6230259", "0.61723256", "0.61616004", "0.60951453", "0.6027186", "0.5940093", "0.5781912", "0.5714172", "0.5674832", "0.56065476", "0.5606109", "0.5584245", "0.55813855", "0.55113584", "0.5461024", "0.54447746", "0.5436992", "0.5405256", "0.54015...
0.6032746
6
GET /todo_lists GET /todo_lists.json
def index @todo_lists = TodoList.where(work_id: params[:id]).order("created_at").page(params[:page]).per(5) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @todo_lists = TodoList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @todo_lists }\n end\n end", "def get_list(id)\n record \"/todos/list/#{id}\"\n end", "def index\n @todos = @list.todos\n render json: @todos\n end", "de...
[ "0.77932733", "0.7712436", "0.7672927", "0.752435", "0.7513934", "0.7509121", "0.7488965", "0.747368", "0.7381777", "0.7369394", "0.7347438", "0.7339883", "0.73212737", "0.73175246", "0.7316859", "0.73104763", "0.73002625", "0.72688675", "0.72077155", "0.7187174", "0.71818423...
0.70121384
30
GET /todo_lists/1 GET /todo_lists/1.json
def show @task = Task.where(todo_list_id: params[:id]).order('status DESC').order('due_date').page(params[:page]).per(5) @task.each do |t| diff = (t.due_date - Date.today).to_i t.due_date = convert_due_date(diff) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_list(id)\n record \"/todos/list/#{id}\"\n end", "def show\n @todo = @list.todos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @todo }\n end\n end", "def show\n @todo_list = TodoList.find(params[:id])\n\n respond_to ...
[ "0.7793893", "0.77337384", "0.76925445", "0.7649732", "0.76380044", "0.7608267", "0.75595534", "0.75584215", "0.7526445", "0.75258726", "0.7449803", "0.7402509", "0.7379051", "0.734873", "0.72926897", "0.72268564", "0.7224417", "0.7218477", "0.72006327", "0.71755254", "0.7174...
0.0
-1
POST /todo_lists POST /todo_lists.json
def create @todo_list = TodoList.new(todo_list_params) respond_to do |format| if @todo_list.save format.html { redirect_to :back, notice: 'Todo list was successfully created.' } format.json { render :show, status: :created, location: :back } else format.html { render :new } format.json { render json: @todo_list.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @todo_list = TodoList.new(params[:todo_list])\n\n respond_to do |format|\n if @todo_list.save\n format.html { redirect_to @todo_list, :notice=>\"Todo list was successfully created.\" }\n format.json { render :json=>@todo_list, :status=>:created, :location=>@todo_list }\n ...
[ "0.7702233", "0.76956373", "0.76944226", "0.76051915", "0.7541543", "0.74640495", "0.74340224", "0.74240375", "0.7419789", "0.7383239", "0.73806715", "0.73765284", "0.7354166", "0.73494655", "0.73381454", "0.7326727", "0.72531617", "0.7205625", "0.7171424", "0.7163397", "0.71...
0.731613
16
PATCH/PUT /todo_lists/1 PATCH/PUT /todo_lists/1.json
def update respond_to do |format| if @todo_list.update(todo_list_params) format.html { redirect_to work_todo_list_path, notice: 'Todo list was successfully updated.' } format.json { render :show, status: :ok, location: work_todo_list_path } else format.html { render :edit } format.json { render json: @todo_list.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @todo = @list.todos.find(params[:id])\n\n respond_to do |format|\n if @todo.update_attributes(params[:todo])\n format.html { redirect_to list_todo_path(@list, @todo), notice: 'Todo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { rende...
[ "0.7537625", "0.7508705", "0.7444292", "0.7431681", "0.7429661", "0.7425529", "0.7329846", "0.73193794", "0.7306446", "0.72675025", "0.72281075", "0.72043365", "0.7204142", "0.7199845", "0.7177073", "0.7173038", "0.71536154", "0.71365017", "0.7072489", "0.7051926", "0.7007685...
0.72618306
10
DELETE /todo_lists/1 DELETE /todo_lists/1.json
def destroy @todo_list.destroy respond_to do |format| format.html { redirect_to todo_lists_url, notice: 'Todo list was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_list(id)\n record \"/todos/delete_list/#{id}\"\n end", "def destroy\n @todo_list = TodoList.find(params[:id])\n @todo_list.destroy\n\n respond_to do |format|\n format.html { redirect_to todo_lists_url }\n format.json { head :ok }\n end\n end", "def destroy\n @todo_list ...
[ "0.8001536", "0.790574", "0.7905642", "0.79003954", "0.7814487", "0.78143466", "0.7681469", "0.7669056", "0.76582783", "0.7630115", "0.7625297", "0.75475115", "0.75326294", "0.7526081", "0.7525262", "0.7525262", "0.75067693", "0.75058055", "0.7487393", "0.74842376", "0.745465...
0.7585526
11
Use callbacks to share common setup or constraints between actions.
def set_todo_list @todo_list = TodoList.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.6163754", "0.6045816", "0.5944853", "0.59169096", "0.58892167", "0.58342934", "0.5776148", "0.57057375", "0.57057375", "0.56534296", "0.56209534", "0.54244673", "0.54101455", "0.54101455", "0.54101455", "0.53951085", "0.5378493", "0.53563684", "0.53399915", "0.5338049", "0...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def todo_list_params params.require(:todo_list).permit(:name, :description, :work_id) 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.6980957", "0.6783065", "0.6747844", "0.6741468", "0.67356336", "0.6592548", "0.65036845", "0.64978707", "0.64825076", "0.64795035", "0.64560914", "0.64397955", "0.6379666", "0.6376688", "0.6366702", "0.6319728", "0.6300833", "0.6300629", "0.6294277", "0.6293905", "0.629117...
0.0
-1
Create a new regressor with the nearest neighbor rule.
def initialize(n_neighbors: 5, metric: 'euclidean') super() @params = { n_neighbors: n_neighbors, metric: (metric == 'precomputed' ? 'precomputed' : 'euclidean') } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def newRegressor\r\n\t\t@trained\t\t= false\r\n\t\t@lr \t\t\t= RubyLinearRegression.new\r\n\t\tputs trainingData.getDataStructure(useHash).first\r\n\t\t@lr.load_training_data trainingData.getDataStructure(useHash), trainingDataAsArray\r\n\tend", "def initialize data, target, parameters\r\n\t\tsuper(data, target,...
[ "0.53905386", "0.51658374", "0.51027155", "0.4998221", "0.49894348", "0.4966659", "0.48886585", "0.48221254", "0.47020018", "0.46677995", "0.45948705", "0.45884937", "0.45837495", "0.4547581", "0.45274627", "0.45224175", "0.4432405", "0.44257557", "0.4420589", "0.4415022", "0...
0.45634675
13
Fit the model with given training data.
def fit(x, y) x = ::Rumale::Validation.check_convert_sample_array(x) y = ::Rumale::Validation.check_convert_target_value_array(y) ::Rumale::Validation.check_sample_size(x, y) if @params[:metric] == 'precomputed' && x.shape[0] != x.shape[1] raise ArgumentError, 'Expect the input distance matrix to be square.' end @prototypes = x.dup if @params[:metric] == 'euclidean' @values = y.dup self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fit(x, y)\n x = Rumale::Validation.check_convert_sample_array(x)\n y = Rumale::Validation.check_convert_label_array(y)\n Rumale::Validation.check_sample_size(x, y)\n xx = fit_bias? ? expand_feature(x) : x\n @model = Numo::Liblinear.train(xx, y, liblinear_params)\n @wei...
[ "0.6924925", "0.68151647", "0.6707346", "0.6380383", "0.6327263", "0.63124955", "0.62570554", "0.62546253", "0.6231997", "0.61450773", "0.6088699", "0.6060084", "0.60080683", "0.59948736", "0.5990137", "0.5990137", "0.5966133", "0.5919537", "0.5836801", "0.5803742", "0.579635...
0.53167987
50
Predict values for samples.
def predict(x) x = ::Rumale::Validation.check_convert_sample_array(x) if @params[:metric] == 'precomputed' && x.shape[1] != @values.shape[0] raise ArgumentError, 'Expect the size input matrix to be n_testing_samples-by-n_training_samples.' end # Initialize some variables. n_samples = x.shape[0] n_prototypes, n_outputs = @values.shape n_neighbors = [@params[:n_neighbors], n_prototypes].min # Predict values for the given samples. distance_matrix = @params[:metric] == 'precomputed' ? x : ::Rumale::PairwiseMetric.euclidean_distance(x, @prototypes) predicted_values = Array.new(n_samples) do |n| neighbor_ids = distance_matrix[n, true].to_a.each_with_index.sort.map(&:last)[0...n_neighbors] n_outputs.nil? ? @values[neighbor_ids].mean : @values[neighbor_ids, true].mean(0).to_a end Numo::DFloat[*predicted_values] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fit_predict(x)\n x = Rumale::Validation.check_convert_sample_array(x)\n\n fit(x).predict(x)\n end", "def predict(x)\n x = Rumale::Validation.check_convert_sample_array(x)\n\n x.dot(@weight_vec.transpose) + @bias_term\n end", "def predict(x)\n x = Rumale::Validat...
[ "0.7085236", "0.68530625", "0.68530625", "0.6833668", "0.6825067", "0.67064106", "0.6664679", "0.6646439", "0.65966344", "0.6561365", "0.65065193", "0.65016085", "0.6473644", "0.64537907", "0.64441603", "0.6422712", "0.64150935", "0.6346463", "0.6328539", "0.6298465", "0.6297...
0.699106
1
checks if the user is logged in
def logged_in? !!current_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end", "def logged_in\n\t \t!current_user.nil?\n\t end", "def logged_in?\n if current_user\n true\n else\n false\n end\n end", "def logged_in?\n\t\tif not current_user.presen...
[ "0.8659265", "0.847562", "0.8446004", "0.8417891", "0.83897", "0.83877367", "0.83840245", "0.83662474", "0.836489", "0.8336469", "0.8331984", "0.83291185", "0.8316263", "0.8314633", "0.8314633", "0.8314633", "0.8314633", "0.8302558", "0.830088", "0.82988566", "0.8294957", "...
0.0
-1
does the recipe belong to the current user
def authorized_to_edit?(recipe) current_user == recipe.user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recipe_belongs_to_user(user)\n if user.recipes.select {|s| s.users == users}.count > 0\n return true\n else\n return false\n end\n end", "def set_recipe\n @recipe = Recipe.find(params[:id])\n if @recipe.user.email == current_user.email\n @owner = true\n end\n end"...
[ "0.7673227", "0.73304236", "0.72261494", "0.71684664", "0.7081602", "0.70197314", "0.7019336", "0.6911972", "0.69018006", "0.68853885", "0.68686146", "0.68665195", "0.68136656", "0.6787963", "0.67832786", "0.677646", "0.6773776", "0.67698187", "0.6761393", "0.6751923", "0.675...
0.79980093
0
set flash key/value and redirect to route
def redirect_to(route, type, message) flash[type] = message redirect route end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_flash_and_redirect(status, message, redirect_url)\n flash[status] = message\n redirect_to redirect_url\n end", "def redirect\n store_location!\n if is_flashing_format?\n if flash[:timedout] && flash[:alert]\n flash.keep(:timedout)\n flash.keep(:alert)\n else\n ...
[ "0.75254077", "0.720464", "0.71843547", "0.7045445", "0.69176894", "0.6847689", "0.6833397", "0.6833397", "0.6753088", "0.67430145", "0.67145777", "0.6701595", "0.6700805", "0.66944736", "0.6686157", "0.66483885", "0.66314566", "0.6628035", "0.6619099", "0.66141725", "0.66113...
0.7003813
5
before_action :get_caso, only: %i[ new ] GET /alumnos or /alumnos.json
def index @alumnos = Alumno.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n rol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"DN\" or rol.nombre == \"ACRM\"\n @colegiaturas = Colegiatura.all\n else\n @colegiaturas = Colegiatura.where(:sede_id=>current_user.sede)\n end \n\n respond_to do |format|\n format.html # index.html.e...
[ "0.61310893", "0.6059849", "0.5978006", "0.5825089", "0.5824023", "0.5780584", "0.57703096", "0.5667133", "0.5585455", "0.55830383", "0.55747473", "0.55440223", "0.5542834", "0.5539166", "0.5534724", "0.5533142", "0.5529963", "0.55067444", "0.54925865", "0.54754233", "0.54738...
0.0
-1
GET /alumnos/1 or /alumnos/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @alumnos = Alumno.all\n respond_with @alumnos\n end", "def show\n @alumno = Alumno.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @alumno }\n end\n end", "def index\n @alumnos = Alumno.paginate(:page => params[:p...
[ "0.6911973", "0.6792353", "0.6753438", "0.67163724", "0.64931935", "0.64931935", "0.64461213", "0.63791287", "0.63627005", "0.6290968", "0.61907464", "0.6164888", "0.6158064", "0.60821104", "0.60567355", "0.59076226", "0.59015125", "0.58985966", "0.588992", "0.58452374", "0.5...
0.0
-1
POST /alumnos or /alumnos.json
def create @alumno = Alumno.new(alumno_params) respond_to do |format| if @alumno.save format.html { redirect_to new_caso_involucrado_path(@alumno.caso__id), notice: "Alumno creado." } format.json { render :show, status: :created, location: @alumno } else format.html { render :new, status: :unprocessable_entity } #format.html { redirect_to new_caso_alumno_path(caso__id), notice: "Error" } format.json { render json: @alumno.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @alumno = Alumno.new(params[:alumno])\n\n respond_to do |format|\n if @alumno.save\n render json: @alumno.as_json(include: :persona), status: :created, location: @alumno\n else\n render json: @alumno.errors, status: :unprocessable_entity\n end\n end\n end", "de...
[ "0.69057894", "0.656125", "0.62785053", "0.6201214", "0.604235", "0.59320515", "0.5899079", "0.5878506", "0.5861651", "0.58595407", "0.5792497", "0.57564545", "0.5753392", "0.5718686", "0.5672813", "0.5654759", "0.5654759", "0.56540006", "0.5646651", "0.5643793", "0.56186175"...
0.5663967
15
PATCH/PUT /alumnos/1 or /alumnos/1.json
def update respond_to do |format| if @alumno.update(alumno_params) format.html { redirect_to @alumno, notice: "Alumno modificado." } format.json { render :show, status: :ok, location: @alumno } else format.html { render :edit, status: :unprocessable_entity } format.json { render json: @alumno.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @alumno = Alumno.find(params[:id])\n\n respond_to do |format|\n if @alumno.update_attributes(params[:alumno])\n head :no_content\n else\n render json: @alumno.errors, status: :unprocessable_entity\n end\n end\n end", "def update\n @alumno = Alumno.find(param...
[ "0.728867", "0.66787326", "0.65363777", "0.6517126", "0.6311699", "0.61860025", "0.6130032", "0.60973907", "0.60009146", "0.5959939", "0.59510225", "0.5916185", "0.58430976", "0.57511324", "0.5703977", "0.5691516", "0.5655905", "0.56317943", "0.5623826", "0.5620274", "0.56194...
0.6269401
5
DELETE /alumnos/1 or /alumnos/1.json
def destroy begin @alumno.destroy rescue ActiveRecord::InvalidForeignKey => e respond_to do |format| format.html { redirect_to alumnos_url, notice: "No puede borrar el alumno hasta no haber borrado sus casos." } format.json { head :no_content } end return end respond_to do |format| format.html { redirect_to alumnos_url, notice: "Alumno borrado." } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @alumno = Alumno.find(params[:id])\n @alumno.destroy\n\n respond_to do |format|\n format.html { redirect_to alumnos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @alumno = Alumno.find(params[:id])\n @alumno.destroy\n\n respond_to do |format|\n...
[ "0.7131531", "0.7089748", "0.7026498", "0.69709396", "0.6951724", "0.6782101", "0.66506183", "0.66234297", "0.65180916", "0.6452118", "0.64516413", "0.6404161", "0.6370882", "0.63632804", "0.63282686", "0.63254094", "0.6322393", "0.63217264", "0.63065547", "0.62855405", "0.62...
0.643474
11
Use callbacks to share common setup or constraints between actions.
def set_alumno @alumno = Alumno.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.61642385", "0.60448", "0.5945487", "0.5915654", "0.58890367", "0.58330417", "0.5776098", "0.5703048", "0.5703048", "0.5654613", "0.5620029", "0.5423114", "0.540998", "0.540998", "0.540998", "0.5393666", "0.53783023", "0.53568405", "0.53391176", "0.5339061", "0.53310865", ...
0.0
-1
Only allow a list of trusted parameters through.
def alumno_params params.require(:alumno).permit(:nombre, :rude, :ci, :caso__id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.69485277", "0.6813547", "0.6799911", "0.6796169", "0.6745757", "0.6741778", "0.6527065", "0.65204644", "0.64925444", "0.64314413", "0.64314413", "0.64314413", "0.6398711", "0.6355623", "0.6355327", "0.6345812", "0.6343951", "0.6338371", "0.6327366", "0.6327366", "0.6327366...
0.0
-1
key, [storage], [seed_data], [opts]
def initialize(key, *args) @key = key if args.last.is_a?(Hash) @options = args.pop end if args.first.is_a?(ROC::Store::ROCStore) @storage = args.shift end if !self.storage raise ArgumentError, 'no class-level storage set, so must initialize with a Store' end if args.size > 1 raise ArgumentError, 'new(key, [storage], [seed_data], [opts])' end if !(seed_data = args.pop).nil? seed(seed_data) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_seed; end", "def load_seed; end", "def key_generator; end", "def key_generator; end", "def persist(key); end", "def persist(key); end", "def reserve_key(key); end", "def zinterstore(destination, *keys, **options); end", "def key_for(params, id, length = 32)\n pset = {\n :it...
[ "0.6364045", "0.6364045", "0.61699903", "0.61699903", "0.5911001", "0.5911001", "0.59062445", "0.58653945", "0.5853775", "0.5851964", "0.5851964", "0.5819807", "0.57823306", "0.57823306", "0.57491934", "0.5728238", "0.5700021", "0.5686366", "0.5686366", "0.5685091", "0.566281...
0.60971665
4
============================eercicio============== ========================================eercicios==================== crear un arreglo de 20 numeros random / 1..100. 1)numero de pares 2)numero de impares 3)si un numero PAR tiene correspondencia con un indice par 4)luego buscar numero 1..100, si existe, en que posicion esta..
def eercicio a = Array.new(20) for i in 0..20 a[i] = rand(1..100) end puts "#{a}" b= a.select{|k| k%2 == 0} puts "Pares #{b} " c= a.select{|k| k%2 == 1} puts "Impares #{c}" d = a.select{|k| k%2 == 0 && a.find_index(k)%2 == 0 && a.find_index(k)>0} puts "Numeros PAR que corresponde con el indice #{d}" op ="s" while op == "s" do puts "Array #{a}" puts "Introduzca numero a buscar" num = gets.chomp.to_i var = a.select{|k| k==num} puts "#{var}" # puts "El numero existe" #else # puts "El numero no existe" #end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gera_posicao\n r = 0\n i = nil\n while 1\n r = rand(2**30 - 1)\n next if r.zero?\n break unless Eleitor.exists?(r)\n end\n self.numero = r\n end", "def generisi\n @mreza = [0] * 81\n \n 0.upto 8 do |red|\n 0.upto 8 do |kolona|\n @mreza[red*9 + kolon...
[ "0.73429763", "0.6531753", "0.6470404", "0.63776624", "0.6353985", "0.6222512", "0.6148749", "0.61434406", "0.6140379", "0.6129793", "0.6103609", "0.6098149", "0.6056043", "0.6039112", "0.6029581", "0.6027855", "0.6024585", "0.6017756", "0.59855974", "0.59782803", "0.59782803...
0.6492545
2
Increment manager or employee count after creating an Employee
def inc_count role = self.role == 'Manager' ? :manager_count : :employee_count self.company.count.update_attribute(role, self.company.count.read_attribute(role)+1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dec_count\n role = self.role == 'Manager' ? :manager_count : :employee_count\n self.company.count.update_attribute(role, self.company.count.read_attribute(role)-1)\n end", "def create_employee\n user = User.new(first_name: \"Nelson\", last_name: \"Muntz\", username: \"nmuntz\", email: \"chris+nmunt...
[ "0.63046354", "0.6178028", "0.61046445", "0.6023205", "0.5969594", "0.5954873", "0.59431106", "0.5862854", "0.5779806", "0.57794595", "0.5775871", "0.57327753", "0.57128805", "0.5698353", "0.569199", "0.56894416", "0.56738627", "0.5646994", "0.56459594", "0.5633807", "0.56271...
0.7275344
0
Decrement manager or employee count before destroying an Employee
def dec_count role = self.role == 'Manager' ? :manager_count : :employee_count self.company.count.update_attribute(role, self.company.count.read_attribute(role)-1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @employee_user.destroy\n end", "def destroy\n @manager.destroy\n end", "def remove_employee\n @leave_group = LeaveGroup.find(params[:id], :include => :leave_group_employees)\n employee = @leave_group.leave_group_employees.detect{|l| l.employee_id == params[:employee_id].to_i}\n r...
[ "0.67384195", "0.6569682", "0.6448045", "0.6430987", "0.6332236", "0.6313291", "0.62943417", "0.6194609", "0.6194391", "0.61413866", "0.61343867", "0.6075633", "0.6075633", "0.6029723", "0.6008059", "0.59529227", "0.5945068", "0.5926879", "0.5924234", "0.5920316", "0.59181076...
0.68068486
0
Instance method edit a project, only can edit the description for now
def edit_project(description, status) update!(description: description, status: status) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit\n\t\t@project = Project.find(params[:id])\n have_no_rights('project.no_rights') if cannot? :update, @project\n\t\tself.bread\n\t\tadd_crumb(@project.name, project_path(@project))\n\t\tadd_crumb(I18n.t('projects.edit'), edit_project_path(@project))\n\tend", "def edit\n\t\t@project = Project.find(param...
[ "0.8161352", "0.8105758", "0.8082512", "0.7897408", "0.7897408", "0.7897408", "0.7876456", "0.7872463", "0.76259357", "0.7600876", "0.7494817", "0.7494483", "0.74521023", "0.74312717", "0.7431137", "0.7428933", "0.7428111", "0.7423819", "0.73587847", "0.7340664", "0.7325835",...
0.8307454
0