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
Set the headers for HttpClient
def headers=(headers) @headers = headers.merge({"User-Agent" => user_agent}) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_header(auth_headers)\n header 'access-token', auth_headers['access-token']\n header 'token-type', auth_headers['token-type']\n header 'client', auth_headers['client']\n header 'expiry', auth_headers['expiry']\n header 'uid', auth_headers['uid']\nend", "def setHeaders(headers)\n @headers = he...
[ "0.75865567", "0.7334449", "0.72294927", "0.7218453", "0.7147003", "0.70689005", "0.7018355", "0.6965115", "0.6958192", "0.6953768", "0.69357526", "0.69284195", "0.6884861", "0.686171", "0.68590105", "0.68501484", "0.6840429", "0.6838375", "0.6838244", "0.6821156", "0.681721"...
0.7058182
6
Set the user agent for HttpClient
def user_agent=(name) @user_agent = USER_AGENT[name] || USER_AGENT['bot'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def useragent=(value)\n Curl.set_option(:useragent, value_for(value, :string), handle)\n end", "def user_agent= user_agent\n @agent.user_agent = user_agent\n end", "def user_agent=(user_agent); end", "def setUserAgent(agent)\n @helper.setUserAgent(agent)\n self\n ...
[ "0.79014856", "0.7727958", "0.76766497", "0.7676473", "0.7676473", "0.7676473", "0.7676473", "0.7676473", "0.7676473", "0.7676473", "0.7675428", "0.7675428", "0.7675428", "0.7675428", "0.7675428", "0.7588549", "0.75546414", "0.7493754", "0.71817666", "0.71817666", "0.7096832"...
0.7180948
20
The Faraday connection object
def connection @connection ||= begin conn = Faraday.new(url: url) conn.build do |b| conn_build.call(b) end if conn_build conn end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connection\n @connection ||= faraday(config, logger)\n end", "def connection\n @connection ||= Faraday.new(self.api_url, { ssl: { verify: false } })\n end", "def connection\n @connection ||= Faraday.new(endpoint, connection_options)\n end", "def connection\n @connection |...
[ "0.8418042", "0.83763164", "0.8350241", "0.83189946", "0.8287058", "0.82806814", "0.8241433", "0.8208422", "0.81615955", "0.8116815", "0.8100564", "0.8051944", "0.8051944", "0.8051944", "0.8051944", "0.8037387", "0.80084753", "0.7988721", "0.79849297", "0.79710174", "0.796480...
0.8172128
8
Make request with HttpClient
def request(verb, uri, query={}) verb == :get ? query_get = query : query_post = query uri = connection.build_url(uri, query_get) response = connection.run_request(verb, uri, query_post, headers) do |request| yield request if block_given? end response = Response.new(response) case response.status when 301, 302, 303, 307 request(verb, response.headers['location'], query) when 200..299, 300..399 response end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_request(url,headers,query)\n c = HTTPClient.new\n c.get_content(url,query,headers)\nend", "def make_request\n response = @http.request(@request)\n end", "def request(http_method, path, body = '', headers = {})\n puts \"#{http_method}: #{path} - [#{body}]\" if @http_debug\n @request...
[ "0.74466443", "0.7210795", "0.7050768", "0.68496317", "0.6782678", "0.6767084", "0.6720374", "0.6706801", "0.6697897", "0.6683894", "0.6659776", "0.6582446", "0.65686387", "0.6556935", "0.65283686", "0.6527966", "0.6519749", "0.65143996", "0.6511265", "0.650684", "0.65031326"...
0.0
-1
Handle get request with HttpClient
def get(uri, query = {}, &block) request(:get, uri, query, &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get\n execute_request('GET') do |uri, headers|\n HTTP.http_client.get(\n uri,\n follow_redirect: true,\n header: headers\n )\n end\n end", "def get(path)\n req = Net::HTTP::Get.new(@base_url + path)\n response = handle_request(re...
[ "0.7129386", "0.7060946", "0.7054542", "0.69961625", "0.6991852", "0.6991513", "0.6872981", "0.6823162", "0.6823162", "0.6808633", "0.67996955", "0.6793002", "0.67554367", "0.6736796", "0.6735243", "0.66812557", "0.66812557", "0.6665988", "0.6665538", "0.6647717", "0.66462505...
0.0
-1
Handle post request with HttpClient
def post(uri, query = {}, &block) request(:post, uri, query, &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post()\n return @http.request(@req)\n end", "def http_post_request\n begin\n return http_client.post(http_path_query, compressed_request, http_headers)\n rescue APIKeyError\n log 'error - you must set your api_key.'\n rescue TimeoutError\n log 'fail -...
[ "0.68115985", "0.6741828", "0.6574264", "0.65465164", "0.64903414", "0.6484743", "0.6469328", "0.644033", "0.6276431", "0.62587106", "0.62454903", "0.6234165", "0.6233841", "0.6229893", "0.6209215", "0.62036735", "0.6184107", "0.61654276", "0.61644727", "0.61491376", "0.61471...
0.0
-1
PUT /locks/ or /locks/serial/ This endpoint is used in both lock commissioning and lock status sync
def update return if params_missing([ :id, :lock_serial ], params, true) lock = Lock.get_active_else_not(params) return render_error_modelname(404, :MISSING_RECORD, Lock) if !lock # Only the owner can update the lock record return render_error(403, :NOT_BELONGING, Lock) if lock.user_id != @current_user_device.user_id return render_error(404, :LOCK_DECOMMISSIONED) if lock.decommissioned? lock.assign_attributes(params_app_allowed) new_lock = false if !lock.commissioned? # New lock, set it all up new_lock = true lock.commission_date = DateTime.now end return check_save_failure(lock) if !lock.save # Owner's key not created until commissioning is completed (saved) successfully. # TODO Transaction around this and the commissioning? if new_lock key = create_user_key(lock.id, lock.user, lock.user) # Validation errors may fail in interesting ways here. end render_lock_reply(lock) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lock!(resource, uuid, *lock_names)\n build_locks(resource, lock_names, uuid).each(&:save!)\n end", "def update\n @lock = Lock.find(params[:id])\n\n respond_to do |format|\n if @lock.update_attributes(params[:lock])\n format.html { redirect_to(@lock, :notice => 'Lock was successf...
[ "0.6438926", "0.638817", "0.6372884", "0.6192568", "0.6182837", "0.61411536", "0.6133996", "0.6118145", "0.60949516", "0.6094413", "0.60875386", "0.59839696", "0.5950648", "0.5851559", "0.5809771", "0.5778173", "0.5745517", "0.57191896", "0.5697143", "0.5671702", "0.5633515",...
0.6523756
0
GET /locks/credentials/:id or /locks/credentials/serial/:lock_serial Fetches the signed account/user_device id and key id data for the lock's keys.
def get_credentials return if params_missing([ :id, :lock_serial ], params, true) return if !get_lock_id(params) lock = @lock || Lock.find(params[:lock_id]) if !lock render_error_modelname(404, :MISSING_RECORD, Lock) return end json = { users_devices: {}, # All users_devices user+public_key over all key owners. keys: [], # all keys for lock. } # Don't care if lock is decommissioned? keys = Key.active_keys.where(lock_id: params[:lock_id]).order(:id) keys.each do |key| json[:keys] << key.id UserDevice.where(user_id: key.user_id).order(:id).each do |ud| next if json[:users_devices][ud.id] rsa = CryptoRSA.new(ud.private_key) json[:users_devices][ud.id] = { user_id: ud.user_id, public_key: rsa.get_public_key_pem } end end json[:server_time] = Time.now.utc.iso8601(9) json[:expire] = ApplicationController.CREDENTIAL_MAX_TRANSIT_TIME json[:lock] = params[:lock_id].to_i # Generate a signature of the json-encoded secure data. json_string = render_to_string :json => json json = { credentials: json, signature: GojiMasterKeysGen.sign(json_string), } lock.new_credentials = false if lock.save # Don't need OTA values here, done on immediately following sync. render :json => json else check_save_failure(lock) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_credentials\n# send_auth(@user_device)\n get(:get_credentials, id: @lock.id)\n end", "def walletlock\n @api.request 'walletlock'\n end", "def get_locks\n HTTParty.get(\"#{$base_url}/partners/#{$partner_id}/locks\", {headers: $headers}).parsed_response['locks']\nend", "def lo...
[ "0.6995523", "0.5909355", "0.5744872", "0.55626684", "0.55594015", "0.5401579", "0.53726274", "0.5347928", "0.5343468", "0.5321471", "0.5265953", "0.5177778", "0.5132749", "0.510948", "0.5108607", "0.50841296", "0.50753945", "0.50723815", "0.50701135", "0.5069112", "0.5059473...
0.7722878
0
Decommission and send notifications. Returns false on error.
def do_decommission(lock, revoker = nil) if !lock.do_decommission(revoker, request.uuid) check_save_failure(lock) return false end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def notify_delete_package\n @requests = Requests.get_requests_delete_package(cookies[:user_id])\n @packages = Packages.get_all_packages\n flag = true\n if( @requests != nil && @packages != nil )\n @packages.each do |t|\n @requests.each do |s|\n if( ( s.senders_id == cookies[:user_...
[ "0.5755877", "0.55715036", "0.55484104", "0.55355686", "0.5498741", "0.54483086", "0.53579867", "0.5280377", "0.52636576", "0.5240284", "0.52268386", "0.51789796", "0.51755357", "0.5158131", "0.51303345", "0.51301324", "0.51266146", "0.51001096", "0.5098089", "0.50893545", "0...
0.58220977
0
Defines condition of product 1 visible 2 visible but not available for order 0 invisible
def status if active == 1 return 1 elsif active == 2 and locked_to > Time.now.to_s(:db) return 2 elsif active == 2 and locked_to < Time.now.to_s(:db) return 1 else return 0 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_visible?\n visibility && ( visibility > 0 )\n end", "def check_if_can_be_set_to_visible_against_price\n return true if visibility_changed? && !visible\n unless self.price && self.price > 0\n errors.add(\"Can't update the product visibility because the price is not set\") \n false\n ...
[ "0.6182087", "0.610464", "0.58872426", "0.5865868", "0.56992733", "0.5688257", "0.56822467", "0.5606659", "0.55530816", "0.55356973", "0.55283356", "0.5510458", "0.55010617", "0.5441592", "0.5427365", "0.5404859", "0.53924185", "0.53924185", "0.537805", "0.53731847", "0.53699...
0.0
-1
GET /workphases GET /workphases.json
def view @workphases = Workphase.search_by_phase(params[:search]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @project_phases = ProjectPhase.all\n end", "def index\n @phases = Phase.where(project_id: params[:project_id])\n end", "def index\n @phases = Phase.all\n end", "def get_work_json\n client.make_request('/get-work-json', 'post', params: {})\n end", "def phases(wod)\n op...
[ "0.6677245", "0.65292525", "0.6423285", "0.63378274", "0.62039244", "0.61108154", "0.61048543", "0.6091999", "0.6053289", "0.60315424", "0.60214865", "0.60214", "0.58047926", "0.5759363", "0.5732642", "0.5666867", "0.56643647", "0.5657214", "0.56477696", "0.5609534", "0.55594...
0.68513757
0
GET /workphases/1 GET /workphases/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @project_phase = ProjectPhase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @project_phase }\n end\n end", "def view\n @workphases = Workphase.search_by_phase(params[:search])\n end", "def index\n @phases = Phase...
[ "0.6614175", "0.65888065", "0.6518956", "0.64683324", "0.63986117", "0.62596124", "0.6255913", "0.62369096", "0.6169411", "0.6079554", "0.6026385", "0.5986162", "0.59676266", "0.59071904", "0.5886285", "0.5866729", "0.58643335", "0.5861447", "0.584496", "0.58416605", "0.58416...
0.0
-1
POST /workphases POST /workphases.json
def create @workphase = Workphase.new(workphase_params) respond_to do |format| if @workphase.save format.html { redirect_to @workphase, notice: 'Workphase was successfully created.' } format.json { render :show, status: :created, location: @workphase } else format.html { render :new } format.json { render json: @workphase.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def workphase_params\n params.require(:workphase).permit(:worknote, :dateChanged, \n :product_id, :phase_id, :employee_id,\n :adminNote, :totalMade, :totalToMake,\n :dateComplete)\n end", "def create\n @work_plan = WorkPlan.find(params[:work...
[ "0.6466669", "0.6334753", "0.6290922", "0.6250835", "0.61476487", "0.61150706", "0.6030995", "0.60242885", "0.6008771", "0.5931299", "0.5915848", "0.5899364", "0.5852997", "0.58372986", "0.5802952", "0.57927865", "0.5780055", "0.57152224", "0.5694496", "0.5674357", "0.5668656...
0.71624374
0
PATCH/PUT /workphases/1 PATCH/PUT /workphases/1.json
def update respond_to do |format| if @workphase.update(workphase_params) format.json { respond_with_bip(@workphase) } #this is added as best_in_place update wasn't holding format.html { redirect_to @workphase, notice: 'Workphase was successfully updated.' } #format.json { render :show, status: :ok, location: @workphase } else format.html { render :edit } format.json { render json: @workphase.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @work_step.update(work_step_params)\n format.html { redirect_to @work_plan, notice: 'Work step was successfully updated.' }\n format.json { render :show, status: :ok, location: @work_plan }\n else\n format.html { render :edit }\n for...
[ "0.6750996", "0.6471228", "0.6376904", "0.6364787", "0.6357176", "0.6345471", "0.633668", "0.63190407", "0.62776226", "0.6256711", "0.6248621", "0.6243154", "0.6240256", "0.6227785", "0.61877036", "0.61834425", "0.6164427", "0.6164427", "0.6164427", "0.6164427", "0.61388904",...
0.6745728
1
DELETE /workphases/1 DELETE /workphases/1.json
def destroy Workphase.find(params[:id]).destroy #@workphase.destroy respond_to do |format| format.html { redirect_to workphases_url, notice: 'Workphase was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @project_phase = ProjectPhase.find(params[:id])\n @project_phase.destroy\n\n respond_to do |format|\n format.html { redirect_to project_phases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise_execution.destroy\n respond_to do |format|\n ...
[ "0.7165512", "0.69539744", "0.69392157", "0.6895234", "0.684572", "0.6843697", "0.6832605", "0.6788403", "0.67702824", "0.67443514", "0.67420965", "0.6740847", "0.6736868", "0.67111576", "0.67104536", "0.6676311", "0.66761434", "0.66761434", "0.66761434", "0.66761434", "0.667...
0.7459516
0
Use callbacks to share common setup or constraints between actions.
def set_workphase @workphase = Workphase.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 workphase_params params.require(:workphase).permit(:worknote, :dateChanged, :product_id, :phase_id, :employee_id, :adminNote, :totalMade, :totalToMake, :dateComplete) 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.6981269", "0.6783559", "0.6746007", "0.67423046", "0.6735905", "0.6593568", "0.6504213", "0.649792", "0.6482664", "0.6478558", "0.64566684", "0.64392304", "0.6380194", "0.6376366", "0.636562", "0.63208145", "0.63006365", "0.63001287", "0.6292953", "0.62927175", "0.62911004...
0.0
-1
GET /people/1/contributions GET .people/1/contributions.json
def index @contributions = @person.contributions end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n user = User.find_by(id: params[:user_id])\n return respond_with contributions: [], status: :not_found if user.nil?\n contributions = user.contributions\n respond_with contributions: contributions, status: :ok\n end", "def index\n @contributions = Contribution.all\n\n respond_to do ...
[ "0.75771564", "0.7078139", "0.66454154", "0.65114063", "0.6270358", "0.62547076", "0.6238534", "0.6173667", "0.61654156", "0.61460084", "0.61370933", "0.6009422", "0.5957173", "0.5831093", "0.5772077", "0.5753856", "0.57238215", "0.56874496", "0.5684164", "0.56696355", "0.566...
0.7270595
1
GET /people/1/contributions/new GET /people/1/contributions/new.json
def new @contribution = Contribution.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @contribution = Contribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contribution }\n end\n end", "def create\n @contribution = Contribution.new(params[:contribution])\n\n respond_to do |format|\n if @contribution.save\n ...
[ "0.7782866", "0.707465", "0.700802", "0.700802", "0.70038974", "0.6954761", "0.69374967", "0.6936159", "0.6926906", "0.6901303", "0.68514496", "0.68061703", "0.68017876", "0.6753267", "0.6745752", "0.6737256", "0.67210066", "0.67018056", "0.6673876", "0.66659665", "0.6661428"...
0.68882805
10
POST people/1/contributions POST people/1/contributions.json
def create @contribution = Contribution.new(contribution_params) @contribution.contributable_type = "Book" @contribution.person = @person respond_to do |format| if @contribution.save format.html { redirect_to person_contributions_path(@person), notice: 'Contribution was successfully created.' } format.json { render action: 'show', status: :created, location: person_contributions_path(@contribution) } else format.html { render action: 'new' } format.json { render json: @contribution.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @contribution = Contribution.new(params[:contribution])\n\n respond_to do |format|\n if @contribution.save\n format.html { redirect_to @contribution, notice: 'Contribution was successfully created.' }\n format.json { render json: @contribution, status: :created, location: @con...
[ "0.6558725", "0.6516483", "0.651311", "0.62787557", "0.62748885", "0.6204882", "0.6200626", "0.61977834", "0.61608875", "0.61483693", "0.61468655", "0.6089625", "0.6071447", "0.60704553", "0.6063227", "0.6063227", "0.60567325", "0.6051911", "0.604626", "0.6031415", "0.5992902...
0.667459
0
reader/getter method. return instance name.
def name @name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def instance_name\n info.name\n end", "def get_name\r\n self.name\r\n end", "def name() return @name end", "def name() return @name end", "def getName()\n return @obj_name\n end", "def name # getter method (or reader method)\n @name\n end", "def name\n @_name\n...
[ "0.79619074", "0.7604622", "0.75723404", "0.75723404", "0.74505293", "0.74408555", "0.7440808", "0.7360143", "0.73555773", "0.7349878", "0.7335689", "0.7259398", "0.724203", "0.72333205", "0.72333205", "0.722334", "0.7218985", "0.7217622", "0.7217622", "0.7217622", "0.7217622...
0.70541126
86
puts 'woof!' when called on an instance of dog.
def bark puts "woof!" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run #instance method, you chain it to an instance of a Dog\n # binding.pry\n puts \"#{@name} the #{@breed} is running fast as the wind\"\n end", "def meow # Define a method that allows any instance of Cat to meow\n puts \"meow!\"\n end", "def dog(name)\r\n puts \"The d...
[ "0.7585412", "0.7316708", "0.7278801", "0.69613475", "0.6840562", "0.6833192", "0.6809764", "0.67994535", "0.67931664", "0.67910105", "0.67778456", "0.6777531", "0.6777531", "0.67716014", "0.6759001", "0.67255664", "0.67255664", "0.6725324", "0.6715189", "0.6700212", "0.66997...
0.67454237
15
This method populates the board with pieces after a new game is created. Args : none Returns : chess pieces assigned to starting locations on the board
def populate_board! # Populate Pawns (0..7).each do |x| Pawn.create(x_coordinates: x, y_coordinates: 1, game_id: self.id, color: 'white', image: 'white-pawn.png', status: 'active') # White Pawn.create(x_coordinates: x, y_coordinates: 6, game_id: self.id, color: 'black', image: 'blk-pawn.png', status: 'active') # Black end # Populate Rook Rook.create(x_coordinates: 0, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-rook.png', status: 'active') # White Rook.create(x_coordinates: 7, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-rook.png', status: 'active') # White Rook.create(x_coordinates: 0, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-rook.png', status: 'active') # Black Rook.create(x_coordinates: 7, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-rook.png', status: 'active') # Black # Populate Knight Knight.create(x_coordinates: 1, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-knight.png', status: 'active' ) # White Knight.create(x_coordinates: 6, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-knight.png', status: 'active' ) # White Knight.create(x_coordinates: 1, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-knight.png', status: 'active' ) # Black Knight.create(x_coordinates: 6, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-knight.png', status: 'active' ) # Black # Populate Bishop Bishop.create(x_coordinates: 2, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-bishop.png', status: 'active') # White Bishop.create(x_coordinates: 5, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-bishop.png', status: 'active') # White Bishop.create(x_coordinates: 2, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-bishop.png', status: 'active') # Black Bishop.create(x_coordinates: 5, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-bishop.png', status: 'active') # Black # Populate Queen Queen.create(x_coordinates: 3, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-queen.png', status: 'active') # White Queen.create(x_coordinates: 3, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-queen.png', status: 'active') # Black # Populate King King.create(x_coordinates: 4, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-king.png', status: 'active') # White King.create(x_coordinates: 4, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-king.png', status: 'active') # Black end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def populate_board!\n # white pieces\n # creates the 8 pawn pieces across the board\n 8.times do |i|\n # sets game_id in Piece model to current id in Game\n # color is boolean - true for white, false for black\n Pawn.create(game_id: id, x_coord: i, y_coord: 1, color: true, captured: false)\...
[ "0.79640114", "0.7943438", "0.7877075", "0.7848217", "0.7834404", "0.781956", "0.7795295", "0.7762303", "0.76904154", "0.7671021", "0.7611875", "0.7572343", "0.75351405", "0.74465734", "0.7424019", "0.7398058", "0.7330775", "0.7299266", "0.72951263", "0.72780603", "0.7269734"...
0.73059267
17
This method determines whether player of a given color is in a state of check. Args : +current_color+ > string indicating the color of the player in question Returns : True if current_color player is in check False otherwise
def in_check?(current_color) check = [] king = pieces.find_by(type: 'King', color: current_color) opponent_pieces = pieces.where.not(color: current_color) opponent_pieces.each do |opponent_piece| if opponent_piece.type != "King" && opponent_piece.status == 'active' if opponent_piece.valid_move?(king.x_coordinates, king.y_coordinates) check << opponent_piece end # A new valid_move method for king (king_valid_move_for_in_check?) is used in this iteration # in order to prevent executing can_castle?, which would lead # to executing obstructed?, which would throw a runtime error # when checking the path between two opposite kings elsif opponent_piece.type == "King" if opponent_piece.king_valid_move_for_in_check?(king.x_coordinates, king.y_coordinates) check << opponent_piece end end # End opponent_piece valid_move! check end # End opponent_pieces block for determining if game is in_check # If check variable has more than 0 items the game is in check otherwise is not in check if check.count > 0 true else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def in_check?(color)\n color(self.opponent_color(color)).any? do |piece| \n piece.moves.include?(find_king(color).pos)\n end\n end", "def check?(color)\n king(color).in_check?\n end", "def in_check?(color)\n if color == :w\n players_pieces, opposing_pieces = white_pieces, black_pieces\n...
[ "0.78071433", "0.7595267", "0.7531067", "0.7488223", "0.74630094", "0.7402951", "0.7336767", "0.7268708", "0.7123894", "0.7112445", "0.70601845", "0.70539224", "0.698104", "0.6957988", "0.6953882", "0.6938994", "0.69024575", "0.6875966", "0.6817531", "0.67552805", "0.6702741"...
0.7350124
6
checks if player has won
def move_result(cell, colour) if scanner.found_connected_four?(cell, colour) ConnectFour::Settings::RESULT[:GAME_OVER] else ConnectFour::Settings::RESULT[:CONTINUE] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def won?\n\t\twon = false\n\t\twon = true if (ended? && @guesses > 0)\n\t\twon\n\tend", "def did_player_win\n (@purses[@current_player] != 6)\n end", "def player_won\n\t\tputs \"\\nCongratulations! your have won!\"\n\t\tself.player_record[\"Wins\"] += 1\n\tend", "def won?\n @game.started? && !detectiv...
[ "0.8228703", "0.8102511", "0.8080715", "0.80255324", "0.79851055", "0.7921449", "0.79142725", "0.78820395", "0.7870085", "0.7856672", "0.78104895", "0.77048695", "0.7691547", "0.76798934", "0.7658237", "0.76573634", "0.7622795", "0.76185095", "0.76185095", "0.7614985", "0.761...
0.0
-1
Set the stream state so that subsequent objects returned by read will be instances of a custom class +cl+. Does not affect consume. Class +cl+ should define cl.from_serialized, plus to_json, to_msgpack, etc. as needed by the underlying serialization library.
def expect cl @expected_class = cl end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def readObject\n raise NotImplementedError, <<-STR\n\n \\e[91m\n I'm afraid this might not work.\n > you need access to the original class definitions (and a)\n > Java runtime to load them into) to turn the stream data back\n > something approaching the original objects.\n ...
[ "0.5640836", "0.5602324", "0.53613764", "0.5308163", "0.52085227", "0.5202204", "0.51267093", "0.512041", "0.5087234", "0.5081586", "0.50710696", "0.5051462", "0.5051462", "0.50441986", "0.50165546", "0.5009137", "0.5006297", "0.5002696", "0.5002657", "0.49850994", "0.4969434...
0.0
-1
Turn off the custom class instantiation of expect.
def unexpect; expect nil; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expect_not_to_run(klass, opts = {})\n alias_new_method(klass)\n with = service_parse_with_option(opts)\n\n expect(klass).to_not receive(:new).with(*with)\n end", "def stop_intercepting!\n @original_methods.each do |m|\n class_eval do\n alias_method m, \"intercepted_#{m}\"\n ...
[ "0.6818073", "0.5891079", "0.56467915", "0.5586717", "0.55387676", "0.5531847", "0.55314183", "0.550299", "0.5476142", "0.54648376", "0.5442587", "0.54334366", "0.5420293", "0.5341416", "0.5319934", "0.53072584", "0.5306787", "0.5270262", "0.5268583", "0.52645606", "0.52533",...
0.51828474
22
The block is appended to a queue of procs that are called for the subsequently read objects, instead of iterating over or returning them. Helps with handshake protocols. Not affected by expect.
def consume &bl @consumers << bl end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def blocks() end", "def blocks; end", "def blocks; end", "def blocks; end", "def read\n while msg = consumer.pop\n begin\n data = JSON.parse msg.body\n yield data[0], data[1]\n rescue => error\n Lux::Error.split_backtrace error\n end\n\n ...
[ "0.66375494", "0.6361939", "0.6361939", "0.6361939", "0.62731177", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61227", "0.61...
0.57603
36
A user cannot leave more than one review per product.
def must_not_be_a_duplicate_review dup_reviews = Review.where(user: user, product: product) if new_record? if dup_reviews.length > 0 errors.add(:product, "already has a review from this user.") end elsif dup_reviews.length > 0 && !dup_reviews.include?(self) errors.add(:product, "already has a review from this user.") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prevent_multiple_feedback_reviews\n @feedback_review = @review.feedback_reviews.find_by(user_id: @current_api_user)\n if @feedback_review.present?\n invalid_resource!(@feedback_review)\n end\n end", "def user_already_reviewed(movie)\n \t@user_already_reviewed = -1\n \tif ...
[ "0.6972179", "0.62275386", "0.6121825", "0.61167115", "0.6060643", "0.59608644", "0.5849173", "0.58219284", "0.5819048", "0.58135027", "0.5694305", "0.5658769", "0.5636665", "0.56277484", "0.5624664", "0.56120497", "0.55964833", "0.5588114", "0.55828565", "0.55782783", "0.556...
0.7584058
0
Complete each step below according to the challenge directions and include it in this file. Also make sure everything that isn't code is commented in the file. I worked on this challenge [by myself, with: ]. 0. total Pseudocode make sure all pseudocode is commented out! set variable equal to 0 iterate over numbers and add to variable return total Input: total([10, 5, 2, 1]) Output: 18 Steps to solve the problem. 1. total initial solution
def total(arr) x = 0 sum = 0 while x < arr.length sum += arr[x] x += 1 end return sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum(x)\n solution = 0\n x.each do |num|\n solution += num\n end\n solution\nend", "def total(numbers)\n result = 0\n numbers.each { |x| result += x }\n return result\nend", "def total (number)\n sum = 0\n number.each do | x |\n sum += x\n end\n return sum\nend", "def total_sum(list_of_numbers)...
[ "0.69526976", "0.68984205", "0.6871195", "0.68647265", "0.68495536", "0.6835354", "0.6804543", "0.6792845", "0.67795366", "0.6766706", "0.67595476", "0.6751375", "0.6739806", "0.67381424", "0.67381424", "0.67244136", "0.67237", "0.67001647", "0.67000043", "0.66947263", "0.669...
0.0
-1
3. total refactored solution
def total(arr) sum = 0 arr.each do |i| sum = sum + i end return sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def anchored; end", "def solution4(input)\n end", "def suivre; end", "def private; end", "def probers; end", "def algorithms; end", "def algorithms; end", "def algorithms; end", "def algorithms; end", "def algorithms; end", "def stderrs; end", "def schubert; end", "def transformations; end...
[ "0.614783", "0.59552205", "0.58631617", "0.5817628", "0.5803303", "0.5688251", "0.5688251", "0.5688251", "0.5688251", "0.5688251", "0.5668896", "0.5657474", "0.56524754", "0.562926", "0.5584554", "0.5583142", "0.55335104", "0.55295557", "0.55000037", "0.549499", "0.5478271", ...
0.0
-1
4. sentence_maker pseudocode make sure all pseudocode is commented out! define sentence_maker(arr) create empty string iterate over elements in array convert all elements to string add elements to string except first and last objects make new string with first object, first string, and last object return new string make sure all pseudocode is commented out! Input: Output: Steps to solve the problem. 5. sentence_maker initial solution
def sentence_maker(arr) string = "" i = 1 while i < arr.length-1 string += arr[i].to_s + ' ' i+=1 end sentence = arr[0].capitalize! + " " + string + arr[-1] + "." return sentence end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sentence_maker(string_array)\nnew_string = \"\"\nnew_array = []\n\nstring_array.each do |string|\n if string != string_array[-1]\n new_string += string.to_s + \" \"\n else\n new_string += string.to_s\n end\n \n new_array.push(new_string)\nend\nreturn new_array[-1].capitalize + \".\"\nend", "def se...
[ "0.7606199", "0.7527665", "0.7460629", "0.732658", "0.72713274", "0.72192645", "0.7176786", "0.7175262", "0.7151471", "0.71381116", "0.7120202", "0.7114391", "0.71115905", "0.7086555", "0.7071118", "0.7068294", "0.7064089", "0.7047962", "0.7047962", "0.7047962", "0.7032588", ...
0.7441793
3
6. sentence_maker refactored solution
def sentence_maker(arr) string = "" arr.each do |i| string += i.to_s + ' ' end string[-1] = "." return string = string.capitalize end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def\n \nend\n\n\n# 6. sentence_maker refactored solution", "def generate_sentence\n\n if @array_words.length < 3\n return \"Length of the input_file is too small to produce trigrams\"\n\n # This function results in an error message if there are no capital\n # words or no end of s...
[ "0.8855691", "0.70719296", "0.70076495", "0.7005185", "0.6995376", "0.69695127", "0.68714696", "0.6835763", "0.68160456", "0.6799819", "0.6795405", "0.67920643", "0.6792004", "0.67893285", "0.6781017", "0.6771953", "0.6764923", "0.6727412", "0.6697308", "0.66861355", "0.66604...
0.0
-1
Gets the page title.
def get_title @doc.css('title').text end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def page_title\n page.title\n end", "def title\n @title_pages.each { |tp| tp.title and return tp.title }\n nil\n end", "def page_title\n @page_title ||= format_string(page[\"title\"]) || site_title\n end", "def title\n return @title if @title\n if matches = clas...
[ "0.8760101", "0.874269", "0.85930514", "0.83034664", "0.8273144", "0.8159025", "0.81513894", "0.81211287", "0.80738115", "0.8036475", "0.8028478", "0.8000366", "0.79160887", "0.7885949", "0.7882007", "0.78620744", "0.7858696", "0.78178066", "0.78006154", "0.77807015", "0.7773...
0.7920321
12
Gets the post points.
def get_points @doc.css('.score').text end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def points\n @obj['points']\n end", "def points()\n\t\t\tfilter()\n\t\t\treturn @points_floor + @points_ceil.reverse\n\t\tend", "def points #:nodoc:\n [self]\n end", "def points #:nodoc:\n [self]\n end", "def points\n db[:points]\n end", "def points\n []\n end", ...
[ "0.7306577", "0.69104683", "0.6677666", "0.6677666", "0.6671629", "0.66334087", "0.65488994", "0.64727044", "0.6442042", "0.63989353", "0.6338974", "0.6338974", "0.62635434", "0.624877", "0.6214281", "0.6214281", "0.6210413", "0.6129807", "0.604901", "0.604901", "0.6037846", ...
0.56769407
40
Gets the post item ID.
def get_item_id @doc.css('.subtext > .age > a:first-child').map{|ele| ele['href']}.map {|x| x[/\d+/]}.join end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def item_id\n return @item_id\n end", "def item_id\n return @item_id\n end", "def item_id\n return @item_id\n end", "def item_entry_id\n return @item_entry_id\n end", "def item_entry_id\n return @item_entry_id\n end", "...
[ "0.74506044", "0.74506044", "0.74506044", "0.7161136", "0.7161136", "0.7051369", "0.68124604", "0.67881656", "0.67881656", "0.67212206", "0.6565051", "0.6565051", "0.6565051", "0.6548729", "0.6470138", "0.639543", "0.63820714", "0.62657505", "0.6227111", "0.62014073", "0.6129...
0.5436884
87
Return an alignment which match columns. The originating sequences should have methods 'empty_copy' and '<<'
def columns_where &block seqs = [] rows.each do | seq | new_seq = seq.empty_copy seq.each_with_index do | e,i | new_seq << e if block.call(columns[i]) end seqs << new_seq end Alignment.new(seqs) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def align\n [:owner, :group, :size].each do |field|\n current = @alignment[field]\n @buffer.each do |line|\n new = line[field].length\n current = new if current < new\n end\n @alignment[field] = current\n end\n end", "def aligned_sequence \n ...
[ "0.62100065", "0.6182961", "0.605207", "0.6010754", "0.59405696", "0.58625257", "0.5855632", "0.5836319", "0.58100814", "0.58100814", "0.58078563", "0.5795865", "0.57522017", "0.5722302", "0.5717905", "0.5706427", "0.5706427", "0.5607617", "0.5606497", "0.54501295", "0.539733...
0.6533839
0
update all elements in the column def update! new_column each_with_index do |e,i|
def each @aln.each do | seq | yield seq[@col] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n $all_columns.each do |col|\n col[0] = col[1].call unless col[1].nil?\n end\nend", "def update!(columns)\n update(nil, columns)\n end", "def update!(**args)\n @column_items = args[:column_items] if args.key?(:column_items)\n end", "def update!(**args)\n @...
[ "0.68217504", "0.6674451", "0.663382", "0.6479402", "0.6311979", "0.63091266", "0.63091266", "0.62969023", "0.62700415", "0.62667555", "0.62667555", "0.62667555", "0.6266312", "0.62300855", "0.6189491", "0.6120177", "0.60762954", "0.60250795", "0.59968764", "0.59918237", "0.5...
0.0
-1
make a hash add a new key to the hash if that key doesn't exist if a key does exist...stop/break/exit/ return true return false when...after the loop is done
def duplicates?(input_numbers) collection_of_numbers = {} input_numbers.each do |number| if collection_of_numbers[number] return true else collection_of_numbers[number] = true end end return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_or_create_for!(hash, key)\n hash[key] = \"\" unless hash.include?(key)\n end", "def duplicate(arr)\n hsh = {}\n\n arr.each do |ele|\n return ele if hsh[ele]\n hsh[ele] = true\n end\n\n false\nend", "def add_key_value?(key, val)\n hash = load_hash\n return false if hash.key...
[ "0.65478647", "0.6016107", "0.5882747", "0.5801963", "0.57729423", "0.57014585", "0.56792736", "0.5655869", "0.56421655", "0.5639002", "0.5619762", "0.5615099", "0.5605554", "0.55721843", "0.55349267", "0.5508785", "0.5497522", "0.5486017", "0.54846454", "0.5484425", "0.54843...
0.5395393
29
POST start new game Takes a body with comma separated string of names /new_game
def new_game params_check(params[:player_names]) { @game = Game.create params[:player_names].split(",").each do |player_name| player = Player.create(name: player_name, game: @game) 10.times do |i| i == 10 ? Frame.create!(game: @game, player: player, position: i, final_frame: true) : Frame.create!(game: @game, player: player, position: i + 1) end end players = @game.players.map{ |player| { "#{player.name}": player.id } } process_response(@game.present?, "Congratulations, you started a new game. Here's your game id: #{@game.id} and player data: #{players}", @game.id) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n positions = JSON.parse(params['positions'])\n\n # Fill in body to initialize the game and return a 200 response\n\n render plain: \"OK\"\n end", "def new_game\n\tresponse\n\tif params[\"difficulty\"]\n\t\tdifficulty = params[\"difficulty\"]\n\t\tsettings.game_data = Ben::Game.new( Integer ...
[ "0.7047248", "0.67517865", "0.66579497", "0.66527337", "0.66527337", "0.66527337", "0.66527337", "0.66527337", "0.66468465", "0.6646828", "0.66052276", "0.6605084", "0.656704", "0.65412307", "0.65325063", "0.6528704", "0.6519139", "0.6519139", "0.6519139", "0.6519139", "0.651...
0.6784502
1
GET game data /game_data?game_id=xxx
def game_data frame_data = [] params_check(params[:game_id]) { @game = Game.find(params[:game_id]) @game.players.each do |player| player_frame_data = { player.name => [] } player.frames.order(:position).each do |frame| current_frame = [[frame.first_roll, frame.second_roll], [frame.score]] current_frame.append(frame.third_roll) if frame.final_frame && current_frame.flatten.sum >= 10 player_frame_data["#{player.name}"] += current_frame end player_frame_data[:total] = player.frames.map(&:score).compact.sum frame_data << player_frame_data end process_response(!frame_data.empty?, frame_data) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n # puts \"PARAMSSSSS CONTROLLER #{params[:id]}\"\n url = \"https://api-2445582011268.apicast.io/games/#{params[:id]}\"\n response = HTTParty.get(url, headers: {\"user-key\" => Figaro.env.igdb_api_key, \"Accept\": \"application/json\"})\n @game_response = response.parsed_response\n end", "d...
[ "0.7449157", "0.70001364", "0.6972407", "0.6972407", "0.69490165", "0.6894466", "0.6772907", "0.6688555", "0.66429186", "0.6632609", "0.6632609", "0.6632609", "0.6632609", "0.6632609", "0.6632609", "0.6632609", "0.66273814", "0.66224706", "0.6617202", "0.6593056", "0.6591032"...
0.6276856
53
GET /clubs/1 GET /clubs/1.json
def show @club = Club.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @club } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @club = Club.find(params[:id])\n\n render json: @club\n end", "def index\n @clubs = Club.all\n render json: @clubs\n end", "def show\n @club = Club.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @club }\n en...
[ "0.83942306", "0.81019014", "0.8078959", "0.7889925", "0.7877483", "0.786315", "0.78516775", "0.75047773", "0.74475837", "0.74475837", "0.74475837", "0.7375221", "0.72653127", "0.7220348", "0.72018844", "0.71983624", "0.7168892", "0.7067452", "0.70564526", "0.7014342", "0.691...
0.82158464
1
PUT /clubs/1 PUT /clubs/1.json
def update @club = Club.find(params[:id]) respond_to do |format| if @club.update_attributes(params[:club]) format.html { redirect_to @club, notice: 'Club was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @club.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @club = Club.find(params[:id])\n\n if @club.update_attributes(params[:club])\n head :no_content\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end", "def update\n @club = Club.find(params[:id])\n @club.update_attributes(club_params)\n respond_w...
[ "0.7922199", "0.7636222", "0.7607505", "0.74574715", "0.7454791", "0.7451092", "0.7451092", "0.7451092", "0.7451092", "0.7451092", "0.7314734", "0.7314734", "0.7270194", "0.72480816", "0.7220248", "0.72081", "0.7191481", "0.7191481", "0.7191481", "0.7191481", "0.7191481", "...
0.7666208
1
Query yahoofinance information about quotes
def get_quote_info(quotes = '') ret = Hash.new YahooFinance::get_quotes(YahooFinance::StandardQuote, quotes) do |qt| ret[qt.symbol] = qt end return ret end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_historical_quotes(from, to)\n \tstocks = Stock.find(:all)\n \tfor stock in stocks\n \t\t\n market = (sec.market == 'sh' ? 'ss' : sec.market) \n sid = (sec.market == 'hk' ? sec.sid.slice(1,4) : sec.sid)\n \t\t\t\n \t\tYahooFinance::get_HistoricalQuotes( \"#{sid}.#{market}\", \n ...
[ "0.7222867", "0.72192204", "0.7176436", "0.71342504", "0.70563275", "0.70356554", "0.67459595", "0.66809464", "0.6655099", "0.65678495", "0.65178174", "0.6507909", "0.63884366", "0.63884366", "0.6333054", "0.63318944", "0.63249636", "0.6310393", "0.6304328", "0.63012224", "0....
0.7063795
4
construct the quote list for querying the stock information
def get_quote_list(portfolio = Array.new) quote_list = Array.new portfolio.each do |p| quote_list << p['stock'] end return quote_list.join(',') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stock_details_for_list(symbol_list)\n\t\t\tsymbol_list = symbol_list.collect { |symbol| sanitize_symbol(symbol) }\n\n return [] if symbol_list.blank?\n\n\t\t\tfield_mappings = {\n\t\t\t\tname: 'n',\n\t\t\t\tsymbol: 's',\n\t\t\t\task: 'a',\n\t\t\t\task_realtime: 'b2',\n\t\t\t\tbid: 'b',\n\t\t\t\tbid_realti...
[ "0.72118294", "0.67459303", "0.6700682", "0.6614101", "0.64037806", "0.6401939", "0.6378696", "0.6295769", "0.62820554", "0.6278724", "0.62717307", "0.61913687", "0.61412877", "0.61094344", "0.60995346", "0.6049173", "0.6044426", "0.6010329", "0.5967269", "0.59656614", "0.594...
0.6761247
1
calculates profit for the given portfolio
def calculate_portfolio(portfolio = Array.new) qs = get_quote_info(get_quote_list(portfolio)) portfolio.each do |p| p['info'] = qs[p['stock']] value_orderd = p['amount']*p['price'] value_now = p['amount']*p['info'].lastTrade p['profit_amount'] = value_now - value_orderd end return portfolio end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def profit\n revenue - total_costs\n end", "def profit\n profit = 0\n if self.is_open?\n if market_value != position_cost\n return (self.is_buy? ? 1 : -1) * (market_value - position_cost)\n else\n return 0\n end\n else\n self.open_trade_records.each do |open_tra...
[ "0.7213182", "0.7061496", "0.701109", "0.6988421", "0.6951452", "0.69466364", "0.69259554", "0.6866281", "0.6866281", "0.6836347", "0.68163925", "0.6774613", "0.6749828", "0.6741579", "0.6726193", "0.67137694", "0.670878", "0.67030215", "0.667781", "0.6673643", "0.66636664", ...
0.731144
0
printing the actual portfolio
def print_portfolio(portfolio = Array.new) template=<<EOT STOCK:\tLASTTRADE € \tAMOUNT @ PRICE € -> PROFIT € EOT money = portfolio.reduce(0) do |memo, p| t = template.dup t.sub!('STOCK', p['stock']) t.sub!('LASTTRADE', "#{p['info'].lastTrade}") t.sub!('AMOUNT', p['amount'].to_s) t.sub!('PRICE', p['price'].to_s) t.sub!('PROFIT', p['profit_amount'].to_s) puts t memo += p['profit_amount'] end puts "-> #{money} €" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def portfolios_listing\n portfolios.each_index do |index|\n puts \"Portfolio (#{index}) : #{portfolios.to_s}\"\n end\n end", "def report\n @portfolios = Portfolio.where(user_id: session[:user_id]).decorate\n Portfolio.transaction do\n Portfolio.refresh_costs(@portfolios, current_user)\n ...
[ "0.7330122", "0.6453931", "0.6446693", "0.6423939", "0.6417934", "0.63664246", "0.6340547", "0.6330982", "0.62902427", "0.62661624", "0.6234746", "0.61986446", "0.61781317", "0.61781317", "0.61764026", "0.6153178", "0.6116161", "0.60833263", "0.60818964", "0.60787785", "0.601...
0.7698567
0
def encrypt(order) crypt = ActiveSupport::MessageEncryptor.new(Rails.application.secrets.secret_key_base)
def check_luxire_inventory order = Spree::Order.find(params[:order_id]) line_items = order.line_items line_items.each do |line_item| variant = Spree::Variant.find(line_item.variant_id) product = variant.product unless Spree::Product.non_depletable_product.include? product.name.downcase length_required_per_product = product.luxire_product.length_required quantity = line_item.quantity stock = product.luxire_stock unless stock.backorderable total_length_required = length_required_per_product * quantity if(stock.virtual_count_on_hands - total_length_required < 0) response = {msg: "#{product.name} is out of stock"} render json: response.to_json, status: 422 and return end end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cryptor\n key = Rails.application.secrets.secret_key_base.bytes[0..31].pack( \"c\" * 32 )\n ActiveSupport::MessageEncryptor.new(key)\n end", "def encryptor\n ActiveSupport::MessageEncryptor.new(ActiveSupport::KeyGenerator.new(\n ENV.fetch(\"SECRET_KEY_BASE\")\n ...
[ "0.8049623", "0.7962808", "0.73545146", "0.73542374", "0.7090968", "0.6988849", "0.69872534", "0.68929464", "0.68464196", "0.68464196", "0.6833625", "0.6831857", "0.6796339", "0.67851853", "0.67801064", "0.6719976", "0.6719976", "0.6678443", "0.6659526", "0.66423213", "0.6627...
0.0
-1
ensure user account is active
def active_for_authentication? super && !deleted_at end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def require_active_user\n unless current_user && current_user.status == UserStatus::ACTIVE\n flash[:alert]= I18n.t 'auth.msg.lock_account'\n redirect_to new_user_sessions_url\n return false\n end\n end", "def activate\n @user.activate! if @user.pending?\n redirect_to root_url\n end",...
[ "0.7820145", "0.73031145", "0.7296796", "0.72714067", "0.72605324", "0.7186465", "0.7184313", "0.7182273", "0.7140091", "0.70876205", "0.7038106", "0.7035326", "0.7020518", "0.699827", "0.69793344", "0.6973365", "0.6956432", "0.69559634", "0.69512725", "0.6950539", "0.6938509...
0.0
-1
provide a custom message for a deleted account
def inactive_message !deleted_at ? super : :deleted_account end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inactive_message\n \t!delete_flag ? super : :deleted_account\n end", "def inactive_message\n\t\t\t!delete_flag ? super : :deleted_account\n\t\tend", "def inactive_message\n \t!deleted_at ? super : :deleted_account\n end", "def inactive_message\n \t!deleted_at ? super : :deleted_account\n end", "d...
[ "0.7748454", "0.76111054", "0.7340721", "0.7340721", "0.7335309", "0.7303815", "0.72608256", "0.7252251", "0.72503877", "0.72373444", "0.72357714", "0.72048134", "0.69019526", "0.67021453", "0.6642065", "0.66013336", "0.6535773", "0.6467926", "0.6448776", "0.6448776", "0.6367...
0.73679733
14
GET /seasons GET /seasons.json
def index render json: {seasons: @serial.seasons, series: @serial} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def seasons(season = nil)\n @server.make_json_request('show.seasons', tvdbid: @tvdbid, season: season)['data']\n end", "def season(year, **options) = get(\"/seasons/#{year}\", **{ sportId: 1 }.merge(options))", "def index\n @seasons = Season.all\n\n respond_to do |format|\n format.html # ind...
[ "0.8541434", "0.83396643", "0.7999041", "0.78044635", "0.7687866", "0.7687866", "0.7687866", "0.76114804", "0.75829875", "0.7446354", "0.7364968", "0.7205307", "0.71122336", "0.70955163", "0.6942995", "0.6942592", "0.69423854", "0.6874281", "0.6874281", "0.6874281", "0.687428...
0.73479855
11
GET /seasons/1 GET /seasons/1.json
def show render json: {season: @season, series: @serial} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def season(year, **options) = get(\"/seasons/#{year}\", **{ sportId: 1 }.merge(options))", "def show\n @runway_season = Runway::Season.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @runway_season }\n end\n end", "def seasons(season =...
[ "0.83198774", "0.8067729", "0.79634094", "0.7904455", "0.7782969", "0.76482874", "0.7560294", "0.75439924", "0.75439924", "0.75439924", "0.75148576", "0.7256124", "0.7221905", "0.7195488", "0.7195488", "0.7195488", "0.7195488", "0.71601826", "0.70462865", "0.70281816", "0.700...
0.73392946
11
POST /seasons POST /seasons.json
def create @serial = Serial.find(params[:serial_id]) @season = Season.create(season_params) @season.serial_id = @serial.id @serial.seasons << @season if @season.id render json: {success: "true", message: "Season has been created", season: @season, series: @serial} else render json: {success: "false", message: "Season was not created"} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @season = Season.new(season_params)\n\n if @season.save\n render :show, status: :created\n else\n render json: @season.errors, status: :unprocessable_entity\n end\n end", "def create\n @season = Season.new(season_params)\n\n respond_to do |format|\n if @season.save\...
[ "0.78587097", "0.7680651", "0.7648404", "0.7357849", "0.7304112", "0.7230402", "0.72032005", "0.70242685", "0.69525826", "0.6861392", "0.6844209", "0.6836399", "0.6831166", "0.682942", "0.68144256", "0.67909384", "0.6712306", "0.6693715", "0.6685788", "0.66826665", "0.6662538...
0.7496587
3
PATCH/PUT /seasons/1 PATCH/PUT /seasons/1.json
def update respond_with @season.update(season_params) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @season.update(season_params)\n render :show, status: :ok\n else\n render json: @season.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @season.update(season_params)\n format.html { redirect_to @season, notice: 'Seas...
[ "0.7574825", "0.7466397", "0.73731536", "0.7247074", "0.72115296", "0.7066464", "0.6906128", "0.67000747", "0.6453101", "0.6453101", "0.6453101", "0.6453101", "0.63932765", "0.6279933", "0.6277337", "0.6263373", "0.625206", "0.62090826", "0.62006545", "0.6170269", "0.61466616...
0.753143
1
DELETE /seasons/1 DELETE /seasons/1.json
def destroy if @season @season.destroy render json: {success: "true", message:"Season was successfully deleted", series: @serial} else render json: {success: "false", message:"Season doesn't exists", series: @serial} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @season = Season.find(params[:id])\n @season.destroy\n\n respond_to do |format|\n format.html { redirect_to seasons_url }\n format.json { head :ok }\n end\n end", "def destroy\n # @season = Season.find(params[:id])\n # @season.destroy\n\n respond_to do |format|\n ...
[ "0.8161093", "0.81420696", "0.8104751", "0.79520655", "0.79472625", "0.7888057", "0.7822919", "0.78088355", "0.7733747", "0.75669867", "0.73643905", "0.72225726", "0.71602285", "0.71379143", "0.7083086", "0.7067304", "0.7053561", "0.69905496", "0.6983579", "0.6983485", "0.697...
0.7468185
10
Use callbacks to share common setup or constraints between actions.
def set_season @season = @serial.seasons.find_by(number: 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 season_params params.require(:season).permit(:description, :date, :number, :serial_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.6981269", "0.6783559", "0.6746007", "0.67423046", "0.6735905", "0.6593568", "0.6504213", "0.649792", "0.6482664", "0.6478558", "0.64566684", "0.64392304", "0.6380194", "0.6376366", "0.636562", "0.63208145", "0.63006365", "0.63001287", "0.6292953", "0.62927175", "0.62911004...
0.0
-1
GET /user_logins GET /user_logins.json
def index @user_logins = UserLogin.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login\n @users = User.all\n render json: User.all\n end", "def index\n @log_ins = LogIn.all\n end", "def index\n @logins = Login.all\n end", "def auto_login\n render json: logged_in_user\n end", "def index\n # @logins = Login.all\n end", "def index\n @users = ...
[ "0.6986181", "0.67032623", "0.6487264", "0.64824224", "0.64675814", "0.6439693", "0.6426158", "0.64258075", "0.6420787", "0.6420787", "0.63225", "0.6283208", "0.6228691", "0.616576", "0.615551", "0.6132131", "0.6101082", "0.60807973", "0.60769", "0.6069716", "0.6058729", "0...
0.69305927
1
GET /user_logins/1 GET /user_logins/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login\n @users = User.all\n render json: User.all\n end", "def index\n @user_logins = UserLogin.all\n end", "def auto_login\n render json: @user\n end", "def auto_login\n render json: @user\n end", "def auto_login\n render json: @user\n end", "def auto_l...
[ "0.6867485", "0.67673355", "0.6716744", "0.66988355", "0.66878766", "0.66878766", "0.666011", "0.647998", "0.6437776", "0.643684", "0.64342386", "0.6410321", "0.6401466", "0.63548857", "0.6339591", "0.6323323", "0.6316888", "0.6316888", "0.6296454", "0.6255197", "0.6249281", ...
0.0
-1
POST /user_logins POST /user_logins.json
def create @user_login = UserLogin.new(user_login_params) respond_to do |format| if @user_login.save format.html { redirect_to @user_login, notice: 'User login was successfully created.' } format.json { render :show, status: :created, location: @user_login } else format.html { render :new } format.json { render json: @user_login.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @user = User.new(user_params)\n\n if @user.save\n #If successful, login as new registered user\n log_in @user\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def login\n @users = User.all\n render js...
[ "0.65117955", "0.63206667", "0.6253498", "0.6233153", "0.6233153", "0.6209189", "0.61464363", "0.6140639", "0.6138607", "0.61351067", "0.598204", "0.5976892", "0.5970828", "0.5919757", "0.5904961", "0.59008706", "0.58969796", "0.58714414", "0.58533", "0.5851868", "0.584327", ...
0.5899419
16
PATCH/PUT /user_logins/1 PATCH/PUT /user_logins/1.json
def update respond_to do |format| if @user_login.update(user_login_params) format.html { redirect_to @user_login, notice: 'User login was successfully updated.' } format.json { render :show, status: :ok, location: @user_login } else format.html { render :edit } format.json { render json: @user_login.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend", "def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend", "def update\n # @user = User.find(params[:id])\n @user = current_user # makes our views \"cleaner\" and m...
[ "0.70472056", "0.67074186", "0.6451869", "0.6396069", "0.6355226", "0.62967", "0.62967", "0.62227327", "0.6195104", "0.6102748", "0.60949606", "0.6081385", "0.60531896", "0.6014166", "0.5966181", "0.5965591", "0.59617895", "0.5949332", "0.59406674", "0.5915215", "0.5904972", ...
0.60081524
14
DELETE /user_logins/1 DELETE /user_logins/1.json
def destroy @user_login.destroy respond_to do |format| format.html { redirect_to user_logins_url, notice: 'User login was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deleteLogin( login_id)\n params = Hash.new\n params['login_id'] = login_id\n return doCurl(\"delete\",\"/login\",params)\n end", "def destroy\n @user_log = UserLog.find(params[:id])\n @user_log.destroy\n\n respond_to do |format|\n format.html { redirect_to user_logs_url }\n forma...
[ "0.6999632", "0.69250566", "0.6878558", "0.6854509", "0.6829974", "0.67081314", "0.6701252", "0.66864187", "0.6664197", "0.66506034", "0.6647517", "0.66420484", "0.66255945", "0.6601341", "0.65587085", "0.64986545", "0.64662224", "0.6465173", "0.64557976", "0.64553356", "0.64...
0.66821927
8
Use callbacks to share common setup or constraints between actions.
def set_user_login @user_login = UserLogin.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 user_login_params params.require(:user_login).permit(:timestamp, :user_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.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
Use callbacks to share common setup or constraints between actions.
def set_entry @entry = params[:id] ? Entry.includes(legislators: :elections).find(params[:id]) : Entry.new(entry_params) 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 entry_params if user_signed_in? and current_user.admin? if @entry.blank? or @entry.new_record? params.require(:entry).permit(:title, :content, {:legislator_ids => []}, {:keyword_ids => []}, :user_id, :date, :source_name, :source_url, :published) else params.require(:entry).permit(:title, :content, {:legislator_ids => []}, {:keyword_ids => []}, :date, :source_name, :source_url, :published) end else params.require(:entry).permit(:title, :content, {:legislator_ids => []}, {:keyword_ids => []}, :user_id, :date, :source_name, :source_url) end 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
GET /sign_ups GET /sign_ups.json
def index @sign_ups = SignUp.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @signups = Signup.all\n end", "def index\n @signups = Signup.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def index\n @sign_ups = SignUp.all\n\t@referer = request.env['HTTP_REFERER']\n end", "def index\n @pushups = current_user.push...
[ "0.7269794", "0.66862106", "0.66491365", "0.65528953", "0.64501303", "0.64501303", "0.6369708", "0.6369708", "0.6357562", "0.6316043", "0.62663263", "0.6149291", "0.6113419", "0.60685915", "0.60685915", "0.60259974", "0.5973351", "0.5962522", "0.5952868", "0.592961", "0.58843...
0.73521084
0
GET /sign_ups/1 GET /sign_ups/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @sign_ups = SignUp.all\n end", "def index\n @sign_ups = SignUp.all\n end", "def index\n @signups = Signup.all\n end", "def show\n @signup = Signup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @signup }\n end...
[ "0.69810617", "0.69810617", "0.69421405", "0.6882965", "0.6882965", "0.6611339", "0.6611339", "0.6487169", "0.64816374", "0.62820333", "0.6174569", "0.60812324", "0.6080178", "0.60731083", "0.60451823", "0.6044911", "0.6018202", "0.59914106", "0.59914106", "0.5987988", "0.593...
0.0
-1
POST /sign_ups POST /sign_ups.json
def create @sign_up = SignUp.new(sign_up_params) respond_to do |format| if @sign_up.save # format.html { redirect_to @sign_up, notice: 'Sign up was successfully created.' } format.html { redirect_to panel_path(1)} else format.html { render :new } format.json { render json: @sign_up.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def signup\n client.signup(\n params[:user],\n params[:password]\n )\n end", "def signup(params={})\n begin\n JSON.parse(RestClient.put construct_url(\"user\"), params)\n rescue RestClient::BadRequest => e\n @last_error = e.http_body\n @last_error_code = e.http_code\n f...
[ "0.6931392", "0.68494356", "0.68124014", "0.6787426", "0.6749384", "0.6749384", "0.6720914", "0.67167884", "0.67003345", "0.6620111", "0.661046", "0.6606147", "0.6598769", "0.6569537", "0.6512339", "0.6498201", "0.6472596", "0.6464664", "0.6425708", "0.63870496", "0.63757044"...
0.68171585
2
PATCH/PUT /sign_ups/1 PATCH/PUT /sign_ups/1.json
def update respond_to do |format| if @sign_up.update(sign_up_params) format.html { redirect_to @sign_up, notice: 'Sign up was successfully updated.' } format.json { render :show, status: :ok, location: @sign_up } else format.html { render :edit } format.json { render json: @sign_up.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @signup = Signup.find(params[:id])\n\n respond_to do |format|\n if @signup.update_attributes(params[:signup])\n format.html { redirect_to @signup, notice: 'Signup was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\"...
[ "0.6717594", "0.6712098", "0.6578821", "0.6571195", "0.6253229", "0.6137943", "0.6118633", "0.6080012", "0.5967603", "0.59138864", "0.5900262", "0.5900262", "0.58991283", "0.58550197", "0.5825879", "0.5817204", "0.5772862", "0.57609135", "0.5756075", "0.575318", "0.575318", ...
0.66088855
3
DELETE /sign_ups/1 DELETE /sign_ups/1.json
def destroy @sign_up.destroy respond_to do |format| format.html { redirect_to sign_ups_url, notice: 'Sign up was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @signup = Signup.find(params[:id])\n @signup.destroy\n\n respond_to do |format|\n format.html { redirect_to signups_url }\n format.json { head :ok }\n end\n end", "def destroy\n @signup = Signup.find(params[:id])\n @signup.destroy\n\n respond_to do |format|\n fo...
[ "0.7684268", "0.76483166", "0.743182", "0.74019444", "0.73246545", "0.726921", "0.7264645", "0.7101625", "0.70832616", "0.7027095", "0.69707465", "0.68272233", "0.6644239", "0.66427404", "0.66323274", "0.6629361", "0.6619113", "0.6605127", "0.650977", "0.649681", "0.6481382",...
0.74351937
2
Use callbacks to share common setup or constraints between actions.
def set_sign_up @sign_up = SignUp.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a list of trusted parameters through.
def sign_up_params params.require(:sign_up).permit(:fullname, :store_location) 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.69497335", "0.6812623", "0.6803639", "0.6795365", "0.67448795", "0.67399913", "0.6526815", "0.6518771", "0.64931697", "0.6430388", "0.6430388", "0.6430388", "0.63983387", "0.6356042", "0.63535863", "0.63464934", "0.63444513", "0.6337208", "0.6326454", "0.6326454", "0.63264...
0.0
-1
Check for a collection method defined on the resource
def method_missing symbol, *args if @klass.collection_methods[symbol] instance_exec *args, &@klass.collection_methods[symbol] else super end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collection_resource?\n @resource_arity.to_s == 'collection'\n end", "def collection?\n @resource.collection?\n end", "def ar_collection?(instance, method)\n defined?(ActiveRecord) &&\n instance.respond_to?(method) &&\n instance.send(method).is_a?(ActiveRecord::Relation)\n ...
[ "0.76937175", "0.72691405", "0.69958586", "0.69706374", "0.6855924", "0.6787132", "0.67831594", "0.6669297", "0.6522809", "0.6514251", "0.6514251", "0.6481664", "0.6465054", "0.6465054", "0.6430237", "0.63833594", "0.6330788", "0.6306696", "0.6284662", "0.6283709", "0.6283390...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_room @room = Room.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 room_params params.require(:room).permit(:title, :location, :description, :user_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.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
so I can have require_remote 'require' a javascript filename over the internet, asynchronously, so you'll have to delay before using. Should be fine if typed by hand but if scripted add delay
def require_js(*urls, &block) # used to use this, but don't want to depend on opal-jquery # Element.find("head").append("<script src='#{js_filename}' type='text/javascript'></script>") promises = [] opts = urls.last.is_a?(Hash) ? urls.pop : {} clear_promises = lambda do promises.each do |promise| promise.resolve(false) unless promise.resolved? end end `setTimeout(#{clear_promises}, #{opts[:timeout]} * 1000)` if opts[:timeout] urls.each do |url| promise = Promise.new promises << promise loaded = lambda do promise.resolve(true) end %x| var script = document.createElement( 'script' ); script.type = 'text/javascript'; script.src = url; script.onload = #{loaded}; document.body.appendChild(script); | end Promise.new.tap do |promise| Promise.when(*promises).then do |results| block.call results if block promise.resolve results end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def require_js_sync(url)\n %x|\n var r = new XMLHttpRequest();\n r.open(\"GET\", url, false);\n r.send('');\n window.eval(r.responseText)\n |\n nil\nend", "def script_load(script); end", "def eval_into(module_scope, &block)\n $RUBYJS__MODULE_SCOPE = module_scope\n $RUBYJS__LOADED ||= [] # ...
[ "0.74813884", "0.6236208", "0.61593425", "0.6039022", "0.59898525", "0.57902706", "0.57902706", "0.5725385", "0.5614496", "0.56113774", "0.54029435", "0.5354368", "0.5261745", "0.52484024", "0.5235225", "0.5234575", "0.52263355", "0.522507", "0.52242696", "0.522086", "0.52176...
0.6757367
1
'require' a javascrit filename over the internet, synchronously. Chrome complains that this is deprecated, so it might go away
def require_js_sync(url) %x| var r = new XMLHttpRequest(); r.open("GET", url, false); r.send(''); window.eval(r.responseText) | nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _require_for(filename,line)\n new_file = line.scan(/require\\s*\\(\\s*['\"](.*)(\\.(js|css|sass))?['\"]\\s*\\)/)\n ret = (new_file.size > 0) ? new_file.first.first : nil\n ret.nil? ? nil : filename_for_require(ret)\n end", "def r(filename)\n require \"./#{filename}\"\nend", "def require(...
[ "0.61703676", "0.60895896", "0.5824056", "0.56339586", "0.56339586", "0.55925214", "0.55809796", "0.5579531", "0.5576307", "0.55456537", "0.5535075", "0.5535075", "0.55282277", "0.5519425", "0.5512353", "0.55082273", "0.54815274", "0.54674643", "0.5462867", "0.5446484", "0.54...
0.5516417
14
The lead owner mapping is a userconfigurable setup that maps new leads (people who just signed up on the website) to an owner a staff member who is responsible for contacting that person and guiding them through any next steps. It is used on Salesforce and could also be used for other customer relationship management tasks
def lead_owner_mapping respond_to do |format| format.csv { render text: csv_lead_owner_export } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_LeadOwner(value)\n set_input(\"LeadOwner\", value)\n end", "def owner\n if object.owner && (current_user.lead? || object.owner.id == current_user.id)\n object.owner.id\n else\n nil\n end\n end", "def set_owner_member\n self.organizations << self.owner\n end", "...
[ "0.6134338", "0.5997356", "0.5696609", "0.5584969", "0.5559259", "0.5542059", "0.54082096", "0.54006445", "0.53867006", "0.5369577", "0.5353551", "0.53197855", "0.5317396", "0.5300307", "0.5300307", "0.5299867", "0.52597755", "0.525934", "0.5223042", "0.5215863", "0.5210069",...
0.5289317
16
It should change to Lead_owner, applicant_type, university_name, bz_region and allow blanks on them.
def csv_lead_owner_export CSV.generate do |csv| header = [] header << 'Lead_owner' header << 'Applicant type' header << 'University Name' header << 'Braven Region' csv << header LeadOwnerMapping.all.each do |m| exportable = [] exportable << m.lead_owner exportable << m.applicant_type exportable << m.university_name exportable << m.bz_region csv << exportable end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleanup\n self.city = capwords(city) if (attribute_present?('city') && (self.city != nil))\n self.state = state.upcase if (attribute_present?('state') && (self.state != nil))\n self.street = street.split(\" \").map{|x| x.capitalize}.join(\" \") if (attribute_present?('street') && (street != nil))\n ...
[ "0.60276127", "0.59083176", "0.5824052", "0.5728588", "0.5707643", "0.56918484", "0.5637235", "0.55982757", "0.55612475", "0.5551075", "0.5536769", "0.5499743", "0.5495096", "0.5483904", "0.5439449", "0.5433899", "0.5399516", "0.53979033", "0.5383222", "0.5338831", "0.5338678...
0.0
-1
this little spreadsheet has user_id, exclude_from_reporting, relationship_manager, program only rows present in the spreadsheet are modified when imported
def do_user_status_csv_import if params[:import].nil? flash[:message] = 'Please upload a csv file' redirect_to admin_user_status_csv_import_path return end file = CSV.parse(params[:import][:csv].read) @failures = [] file.each do |row| user_id = row[0] # If the user id isn't actually a number, skip this row # because that means it is probably a header or a blank line # http://stackoverflow.com/questions/10577783/ruby-checking-if-a-string-can-be-converted-to-an-integer begin user_id = Integer user_id rescue next end begin user = User.find(user_id) user.exclude_from_reporting = row[1] user.relationship_manager = row[2] user.associated_program = row[3] user.active_status = row[4] user.save! rescue @failures << user_id end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loadstudentsUpdates\n @flagDbUpdateRun = false\n if params.has_key?('flagDbUpdate')\n if params['flagDbUpdate'] == 'run'\n @flagDbUpdateRun = true\n end\n end\n logger.debug \"@flagDbUpdateRun: \" + @flagDbUpdateRun.inspect\n #service = googleauthorisation(request)\n returne...
[ "0.5597566", "0.5593641", "0.55589575", "0.55178523", "0.5492531", "0.54744333", "0.54587615", "0.54255986", "0.53958", "0.537108", "0.53357905", "0.531206", "0.53115684", "0.5288103", "0.528585", "0.5273617", "0.5265873", "0.52461386", "0.52422166", "0.52294445", "0.5214217"...
0.50291497
42
=begin Checking if the response has been copied from the review questions or from other responses submitted. =end
def compare_reviews_with_questions_responses(reviews, questions) review_text_arr = reviews #response = Response.find(:first, :conditions => ["map_id = ?", map_id]) #scores = Score.find(:all, :conditions => ["response_id = ?", response.id]) #questions = Array.new #fetching the questions for the responses # for i in 0..scores.length - 1 # questions << Question.find_by_sql(["Select * from questions where id = ?", scores[i].question_id])[0].txt # end count_copies = 0 #count of the number of responses that are copies either of questions of other responses rev_array = Array.new #holds the non-plagiairised responses #comparing questions with text for i in 0..questions.length - 1 if(!questions[i].nil? and !review_text_arr[i].nil? and questions[i].downcase == review_text_arr[i].downcase) count_copies+=1 next #skip comparing with other responses end #comparing response with other responses flag = 0 for j in 0..review_text_arr.length - 1 if(i != j and !review_text_arr[i].nil? and !review_text_arr[j].nil? and review_text_arr[i].downcase == review_text_arr[j].downcase) count_copies+=1 flag = 1 break end end if(flag == 0) #ensuring no match with any of the review array's responses rev_array << review_text_arr[i] end end #setting @review_array as rev_array if(count_copies > 0) #resetting review_array only when plagiarism was found auto_metareview.review_array = rev_array end if(count_copies > 0 and count_copies == scores.length) return ALL_RESPONSES_PLAGIARISED #plagiarism, with all other metrics 0 elsif(count_copies > 0) return SOME_RESPONSES_PLAGIARISED #plagiarism, while evaluating other metrics end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compare_reviews_with_questions(auto_metareview)\n\n review_text_arr = auto_metareview.review_array\n\n scores = Score.find(:all, :conditions => [\"response_id = ?\", response.id])\n\n questions = Array.new\n\n #fetching the questions for the responses\n for i in 0..scores.length - 1\n quest...
[ "0.6991628", "0.6959786", "0.63981116", "0.62761766", "0.62358683", "0.617883", "0.6098505", "0.60631853", "0.6058364", "0.59978896", "0.5968574", "0.596645", "0.5947535", "0.58729345", "0.5858099", "0.58392376", "0.58310413", "0.5798336", "0.5785766", "0.5722757", "0.5722582...
0.67376494
2
=begin Checking if the response was copied from google =end
def google_search_response(auto_metareview) review_text_arr = auto_metareview.review_array # require 'ruby-web-search' count = 0 temp_array = Array.new review_text_arr.each{ |rev_text| if(!rev_text.nil?) #placing the search text within quotes to search exact match for the complete text response = RubyWebSearch::Google.search(:query => "\""+ rev_text +"\"") #if the results are greater than 0, then the text has been copied if(response.results.length > 0) count+=1 else temp_array << rev_text #copying the non-plagiarised text for evaluation end end } #setting temp_array as the @review_array auto_metareview.review_array = temp_array if(count > 0) return true else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_response(url)\n\t\t\t\t\t\tres_flag = false\n\t\t\t\t\t\t\t\tresponse = RestClient.get(url){|response, request, result| response \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif response.code != 200\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tputs response.code\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\...
[ "0.6006878", "0.59554756", "0.5771941", "0.5752945", "0.57092756", "0.56864", "0.56709874", "0.5630728", "0.5581401", "0.5562084", "0.55540913", "0.55192167", "0.5493734", "0.54890597", "0.5487719", "0.5469847", "0.54348123", "0.54304343", "0.54186386", "0.5417814", "0.541777...
0.58493525
2
Find the sum of all the primes below two million.
def is_prime?(i) return false if i <= 1 return true if i == 2 (2...i).each {|n| if i % n == 0 return false end } true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ten\n acc = 0\n (find_primes_below 2000000).each do |i|\n acc = acc + i\n end\n return acc \nend", "def run\n puts sum_of_primes_below(10)\n #=> 17\n\n puts sum_of_primes_below(2_000_000)\n #=> ??\nend", "def consecutive_prime_below_one_million\n @max_limit = 1000_000\n generate_prime_...
[ "0.821614", "0.78911686", "0.755588", "0.7523196", "0.7480213", "0.7476215", "0.74590516", "0.74414307", "0.7431382", "0.7333121", "0.732661", "0.73118657", "0.72957844", "0.72825474", "0.7205344", "0.71875244", "0.7183439", "0.71288306", "0.71193737", "0.7119278", "0.7085497...
0.0
-1
Push a value onto the stack
def push(value) @data = LinkedListNode.new(value, @data) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push(value)\n return \"Stack is full\" if is_full\n\n @stack.push(value)\n @current_size += 1\n end", "def add(value)\n @stack.push(value)\n end", "def push(x)\n @stack << x \n end", "def push(x)\n @stack << x\n end", "def push(x)\n @stack.push(x)\n end", "def push(val...
[ "0.8563555", "0.8531257", "0.8298897", "0.82781947", "0.8205244", "0.81969625", "0.8174969", "0.8150769", "0.81474", "0.81396604", "0.80902964", "0.80648404", "0.795523", "0.79373324", "0.79243076", "0.79227865", "0.79042894", "0.78440315", "0.78257644", "0.7730317", "0.77155...
0.7047238
60
Pop an item off the stack. Remove the last item that was pushed onto the stack and return the value to the user
def pop if @data top_value = @data.value @data = @data.next_node else top_value = nil end return top_value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pop()\n return \"Stack is empty\" if is_empty\n\n temp = @stack[-1]\n @stack.delete_at(-1)\n @current_size -= 1\n\n return temp\n end", "def pop()\n @stack.pop\n end", "def pop()\n\t\t@stack.pop\n\tend", "def pop()\n # if the stack is empty, return nil\n # (it would also b...
[ "0.8281756", "0.82716006", "0.82564", "0.8236544", "0.8228041", "0.82207924", "0.82079315", "0.818714", "0.8170738", "0.8168916", "0.816014", "0.816014", "0.8148781", "0.81294084", "0.8104261", "0.8102216", "0.8102216", "0.8091204", "0.8083773", "0.80678487", "0.8059671", "...
0.0
-1
Generate and update the remember digest
def remember # store virtually the new token self.remember_token = User.new_token # save the hash digest of the token on the database self.update_attribute(:remember_digest, User.digest(self.remember_token)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_remember_digest\n self.remember_token = User.new_token\n update_attribute(:remember_digest, User.digest(remember_token))\n end", "def remember_token_digest\n self.remember_token = User.new_token\n # Updates remember_digest in database from nil to digest of remember_token\n update_attri...
[ "0.7748438", "0.7440697", "0.7431944", "0.7431944", "0.7413818", "0.73257464", "0.7127094", "0.71126854", "0.70892566", "0.70697385", "0.70513576", "0.70513576", "0.7017328", "0.70145386", "0.6999056", "0.6987499", "0.697524", "0.69712365", "0.696727", "0.6953357", "0.6940077...
0.0
-1
Check if the remember_token passed is the same of the stored on the database
def authenticated?(remember_token) return false if self.remember_digest.nil? BCrypt::Password.new(self.remember_digest) == remember_token end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remember_token?\n remember_token_expires_at && Time.now < remember_token_expires_at\n end", "def remember_token?\n remember_token_expires_at && Time.now.utc < remember_token_expires_at \n end", "def remember_token?\n remember_token_expires_at && Time.now.utc < remember_token_expires_at \n end",...
[ "0.79494613", "0.79044074", "0.79044074", "0.79044074", "0.7852432", "0.7775121", "0.7773094", "0.7575631", "0.7534368", "0.7410829", "0.73785126", "0.73740906", "0.7368886", "0.7328937", "0.73191595", "0.73175794", "0.7315333", "0.73139375", "0.7308871", "0.72832704", "0.725...
0.74103385
10
Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers (or sad numbers) (Wikipedia). For example number 7 is happy because after a number of steps the computed sequence ends up with a 1: 7, 49, 97, 130, 10, 1 while 3 is not, and would give us an infinite sequence: 3, 9, 81, 65, 61, 37, 58, 89, 145, 42, 20, 4, 16,3 7, 58, 89, 145, 42, 20, 4, 16, 37, ... Write a function that takes n as parameter and return true if and only if n is an happy number. Happy coding!
def is_happy(n) i = 0 r = false destination = [] while r == false n.to_s.split("").each do |x| destination << ((x.to_i * x.to_i)) end i = i + 1 n = destination.inject(&:+) r = true if n == 1 destination = [] break if i == 1000 end if r == true p r else p false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def happy_number(n)\n\tresult = square(n)\n\th = {result => true}\n\twhile true do\n\t\tputs \"result = #{result}\"\n\t\tresult = square(result)\t\t\n\t\tif result == 1\n\t\t\treturn true\n\t\telsif h[result]\n\t\t\treturn false\n\t\telse\n\t\t\th[result] = true\n\t\tend\n\tend\nend", "def is_happy(n)\n\treturn ...
[ "0.8162589", "0.81556606", "0.8077448", "0.77234554", "0.76529074", "0.7349204", "0.72184724", "0.7118219", "0.669254", "0.65510374", "0.6503217", "0.6483044", "0.64699423", "0.6446987", "0.6402002", "0.6375336", "0.63509446", "0.63175166", "0.6305271", "0.6287781", "0.626004...
0.77671945
3
add getter and setter methods
def initialize(year, bed_type) # add add bed_type param super(year) # add @bed_type = bed_type # add end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getters; end", "def setter_methods\n return @setter_methods if @setter_methods\n @setter_methods = get_setter_methods\n end", "def setter_methods\n return @setter_methods if @setter_methods\n @setter_methods = get_setter_methods\n end", "def name\n return @name\nend...
[ "0.77670574", "0.70840245", "0.70840245", "0.6843785", "0.67145234", "0.6654084", "0.6647551", "0.6643148", "0.662397", "0.65693176", "0.65496945", "0.653281", "0.6525444", "0.65035874", "0.64805615", "0.64593333", "0.64262307", "0.64222443", "0.6397445", "0.6364543", "0.6339...
0.0
-1
piece parsers bottom to top
def interval0(i) rex(:interval0, i, /(year|month|week|day|hour|min(ute)?|sec(ond)?)(?![a-z])/i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(board, color, move_str)\n str = move_str.gsub(/[+\\#!]/, '')\n capture = str.delete!('x')\n\n # the promotion piece setting, e.g. h8=Q\n if str =~ /^.*(=.).*$/\n Pawn.set_promotion_piece(color, \n Board::PieceLetterMap.detect{|k,v| v.include?($1[1,1])}[0])\n str...
[ "0.59307706", "0.55753374", "0.54888755", "0.54888755", "0.54780024", "0.5434287", "0.5431834", "0.5427049", "0.5393576", "0.5360147", "0.5359534", "0.53467345", "0.5328731", "0.531367", "0.5278399", "0.52768815", "0.52280354", "0.5218161", "0.52081245", "0.5207465", "0.52074...
0.0
-1
Fetches the complete octodex
def completeOctodex cURL($baseURL) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def oct2_hex()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Oct2Hex::Oct2HexRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def set_ox\n @ox = Ox.find(params[:id])\n end", "def hex2_oct()\n ...
[ "0.5476673", "0.5442733", "0.541492", "0.5413605", "0.534361", "0.52974963", "0.52036357", "0.51653326", "0.50661594", "0.504089", "0.50351775", "0.502217", "0.4955309", "0.49524063", "0.493911", "0.49295998", "0.48251978", "0.4809872", "0.48084632", "0.47958818", "0.4783845"...
0.6259944
0
Fetches a random octocat
def randomOctocat cURL($baseURL+"?random") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def random\n random_card = self.class.get('/cards/random')\n end", "def pick\n @gommis_count = Gommi.count\n @gommis = Gommi.offset(rand(Gommi.count)).first\nend", "def random\n Client.get(\"/patterns/random\")\n end", "def random\n Client.get(\"/colors/random\")\n end", "def ...
[ "0.6274286", "0.6140578", "0.6108216", "0.609113", "0.6041395", "0.60179037", "0.5908919", "0.58842474", "0.58652323", "0.58652323", "0.58604074", "0.58505964", "0.57990134", "0.5766338", "0.5766338", "0.57383543", "0.5732337", "0.5732314", "0.572656", "0.569993", "0.5697186"...
0.8122879
0
Fetches an octocat by its number
def numberedOctocat (number) cURL($baseURL+"?number=#{number}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_octal_char(c)\n r = c.ord - '0'.ord\n if !nextoct?\n return r\n end\n\n r = (r << 3) | (readc.ord - '0'.ord)\n if !nextoct?\n return r\n end\n\n (r << 3) | (readc.ord - '0'.ord)\n end", "def set_oct\n @oct = Oct.find(params[:id...
[ "0.6242975", "0.6045589", "0.6024554", "0.6020457", "0.5884812", "0.587131", "0.5823518", "0.5818513", "0.5387058", "0.5349889", "0.53414613", "0.53032297", "0.52596337", "0.51465577", "0.5131537", "0.5122498", "0.5090959", "0.5068637", "0.5067946", "0.50619936", "0.505893", ...
0.65900767
0
Performs all cURLs that are initated in each function, protected function
def cURL (endpoint) # use open-uri to perform a GET request and then use JSON to parse it JSON.parse(open(endpoint).read) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_urls\n acts_as_url_configuration.adapter.initialize_urls! self\n end", "def initialize_urls\n find_each(:conditions => {acts_as_url_configuration.url_attribute => nil}) do |instance|\n instance.send :ensure_unique_url\n instance.save\n end\n end", ...
[ "0.6193404", "0.61805123", "0.6105821", "0.60987103", "0.60198647", "0.5988707", "0.5934363", "0.5920136", "0.5849872", "0.5791638", "0.5720417", "0.56314385", "0.55895114", "0.5571384", "0.5549146", "0.553084", "0.5498351", "0.5478351", "0.5478351", "0.5475335", "0.54059106"...
0.0
-1
GET /rests GET /rests.json
def index @rests = Rest.all if user_signed_in? @star = current_user.id end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rest_endpoint; end", "def index\n @node = Fedora.rest('rest/')\n end", "def rest_get(url)\n JSON.parse(RestClient.get(url))\n end", "def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end", "def index\n @rest_apis = RestApi.all\n end", "def set_rest\n @rest...
[ "0.6700357", "0.66761476", "0.6669396", "0.652457", "0.64282805", "0.63892686", "0.63892686", "0.63254553", "0.63159686", "0.63079304", "0.6286257", "0.6269529", "0.6262006", "0.62530184", "0.62445724", "0.6216004", "0.62032175", "0.6188354", "0.6179477", "0.6142708", "0.6108...
0.57400334
76
GET /rests/1 GET /rests/1.json
def show map_link @num_stars = @rest.stars.count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rest_endpoint; end", "def rest_get(url)\n JSON.parse(RestClient.get(url))\n end", "def index\n @node = Fedora.rest('rest/')\n end", "def set_rest\n @rest = Rest.find(params[:id])\n end", "def set_rest\n @rest = Rest.find(params[:id])\n end", "def url\n \"/#{self.class...
[ "0.6952998", "0.68672687", "0.6795025", "0.66832966", "0.66832966", "0.649095", "0.64744085", "0.64592946", "0.63871074", "0.6356063", "0.6348608", "0.6340867", "0.63260907", "0.6292809", "0.629224", "0.62778544", "0.62577116", "0.62445396", "0.62295973", "0.62291014", "0.621...
0.0
-1
POST /rests POST /rests.json
def create @rest = Rest.new(rest_params) @rest.owners << current_owner respond_to do |format| if @rest.save format.html { redirect_to @rest, notice: 'Rest was successfully created.' } format.json { render :show, status: :created, location: @rest } else format.html { render :new } format.json { render json: @rest.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(url, data)\n RestClient.post ENV['APIBASE']+url, data, :content_type => :json\nend", "def add_weather_by_rest(auth,weather_json)\n rest_agent=RestClient::Resource.new(\"http://#{auth[:host]}:#{auth[:port]}/#{auth[:reststr]}/ry/weather\")\n rest_agent.post(weather_json, :content_type=>\"applicat...
[ "0.61397886", "0.6026522", "0.6021422", "0.6014175", "0.59473485", "0.59293044", "0.5900913", "0.58330417", "0.5823481", "0.5804615", "0.5804615", "0.58033496", "0.57480234", "0.57329416", "0.566821", "0.5667403", "0.56503373", "0.5609959", "0.56051517", "0.55629534", "0.5562...
0.6640577
0
PATCH/PUT /rests/1 PATCH/PUT /rests/1.json
def update respond_to do |format| if @rest.update(rest_params) format.html { redirect_to @rest, notice: 'Rest was successfully updated.' } format.json { render :show, status: :ok, location: @rest } else format.html { render :edit } format.json { render json: @rest.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rest_patch(base_uri,json_payload,params)\n begin\n @response = RestClient.patch(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch options\n...
[ "0.6803028", "0.67416245", "0.67416245", "0.6635341", "0.6599856", "0.6599856", "0.6581939", "0.6520609", "0.6495032", "0.6442611", "0.63919777", "0.63912296", "0.6261466", "0.6203461", "0.61574394", "0.61506456", "0.6123332", "0.609927", "0.60703343", "0.60681707", "0.599675...
0.687671
0
DELETE /rests/1 DELETE /rests/1.json
def destroy @rest.destroy respond_to do |format| format.html { redirect_to rests_url, notice: 'Rest was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @rest_api.destroy\n respond_to do |format|\n format.html { redirect_to rest_apis_url }\n format.json { head :no_content }\n end\n end", "def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def delete(path)\n...
[ "0.7464244", "0.74373174", "0.73622584", "0.73408127", "0.7227154", "0.7200991", "0.7155777", "0.710573", "0.710573", "0.70631737", "0.70460635", "0.70373535", "0.6969877", "0.6969877", "0.6969877", "0.6969877", "0.69666564", "0.6963404", "0.6944766", "0.6933575", "0.6933575"...
0.7719696
0