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
REF_A = 10pF REF_B = 56pF
def readReferences @refA = readRawChannelLevel(REF_A) @refB = readRawChannelLevel(REF_B) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ref_xy(); @ref_xy; end", "def full_ref # rubocop:disable Metrics/AbcSize\n @full_ref ||= begin\n ref = \"#{refparts[:perfix]}#{refparts[:series]} #{refparts[:code]}\"\n ref += \"pt#{refparts[:prt]}\" if refparts[:prt] # long_to_short(refparts, \"prt\").to_s\n ref += \"ver#{refparts[...
[ "0.56888145", "0.5620184", "0.5342926", "0.5342926", "0.5250166", "0.52040523", "0.5176728", "0.5139128", "0.5113715", "0.5110821", "0.51065826", "0.5041224", "0.50389254", "0.50250906", "0.4976163", "0.49603662", "0.49588585", "0.49502245", "0.49425298", "0.49225518", "0.489...
0.5166628
7
channels: array of channel numbers scale: global scale factor to multiply by offsets: array of offsets to be subtracted before scaling
def readChannels(scale, offsets) return channels_collect { |cn| readRawChannelLevel(cn) }.zip(offsets).collect { |a| (a[0] - a[1]) * scale } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scales\n \n end", "def scale(*args, &block); end", "def scale(factor_x, factor_y=factor_x, &rendering_code); end", "def scale_mixes(mix_list, scl)\n as_one_edit_rb(get_func_name) do\n mix_list.each do |m|\n set_mix_amp(m, scl * mix_amp(m))\n end\n end\n end", "def scale(...
[ "0.608543", "0.5769861", "0.5751357", "0.5574123", "0.55465776", "0.55179185", "0.5439834", "0.5407834", "0.53989154", "0.53838366", "0.5382499", "0.5371986", "0.53586715", "0.5330766", "0.5267122", "0.52386886", "0.5177725", "0.51776254", "0.5172271", "0.5164977", "0.5160771...
0.68901503
0
Calling the validation chain should only happen once. If you make changes that may alter the result of valid?, consider instanciating another service instead of running the same service again. You should never be able to call valid? on a service that has been executed by skipping validations. That means that whenever the service has been executed: It has been validated when calling run You can't call valid? on it because you called run! and didn't get the instance back
def valid? return @_valid unless @_valid.nil? @_valid = super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate\n\t\t\tif !(valid?)\n\t\t\t\treturn Core::ServiceError.new(\"Validation failed.\")\n\t\t\tend\n\n\t\t\treturn Core::ServiceSuccess.new\t\t\n\t\tend", "def validate\n\t\t\tif !(valid?)\n\t\t\t\treturn Core::ServiceError.new(\"Validation failed.\")\n\t\t\tend\n\n\t\t\treturn Core::ServiceSuccess.new\t...
[ "0.71012247", "0.71012247", "0.6915862", "0.6857475", "0.6821005", "0.6714581", "0.66524214", "0.66137856", "0.65866315", "0.65866315", "0.6582796", "0.65666926", "0.6566087", "0.6566087", "0.6566087", "0.64854294", "0.64663076", "0.6425699", "0.6415018", "0.64129716", "0.633...
0.0
-1
Transaction Interface Starts a database transaction.
def begin_db_transaction log('BEGIN', 'TRANSACTION') { @connection.begin } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def begin_db_transaction\n execute(\"BEGIN\")\n end", "def begin_db_transaction\n execute(\"BEGIN\")\n end", "def start_transaction!\n fail DbMod::Exceptions::AlreadyInTransaction if @in_transaction\n @in_transaction = true\n\n query 'BEGIN'\n end", "def begi...
[ "0.82547086", "0.82547086", "0.82272166", "0.8130013", "0.7938806", "0.78634214", "0.76985353", "0.76985353", "0.7680118", "0.7668149", "0.7607679", "0.75491047", "0.73921615", "0.7342174", "0.72824055", "0.72412956", "0.723066", "0.7190104", "0.7186791", "0.7186791", "0.7126...
0.8211707
3
Starts a database transaction.
def begin_isolated_db_transaction(isolation) log("BEGIN ISOLATED - #{isolation}", 'TRANSACTION') { @connection.begin(isolation) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_transaction!\n fail DbMod::Exceptions::AlreadyInTransaction if @in_transaction\n @in_transaction = true\n\n query 'BEGIN'\n end", "def begin_db_transaction\n execute(\"BEGIN\")\n end", "def begin_db_transaction\n execute(\"BEGIN\")\n end", "def begi...
[ "0.8382846", "0.826889", "0.826889", "0.8138087", "0.807101", "0.80169153", "0.7758959", "0.7638615", "0.7618878", "0.7618878", "0.73823154", "0.72951317", "0.71919847", "0.7191075", "0.71797717", "0.7141438", "0.70849895", "0.7055831", "0.7027031", "0.7020137", "0.7020137", ...
0.67385566
28
Commits the current database transaction.
def commit_db_transaction log('COMMIT', 'TRANSACTION') { @connection.commit } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commit_db_transaction\n execute(\"COMMIT\")\n end", "def commit_db_transaction\n execute(\"COMMIT\")\n end", "def commit\n @db.commit\n end", "def commit_db_transaction\n @transaction = @connection.commit\n end", "def commit\n db_interface.commit...
[ "0.84105986", "0.84105986", "0.8224817", "0.80955887", "0.7943903", "0.7921335", "0.79157156", "0.78948647", "0.7854213", "0.7649062", "0.7574977", "0.7574977", "0.75528127", "0.736996", "0.7368336", "0.73125714", "0.7255587", "0.7255008", "0.7255008", "0.7248397", "0.7125889...
0.8247636
2
Rolls back the current database transaction. Called from 'rollback_db_transaction' in the AbstractAdapter
def exec_rollback_db_transaction log('ROLLBACK', 'TRANSACTION') { @connection.rollback } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rollback_db_transaction\n execute(\"ROLLBACK\")\n end", "def rollback_db_transaction\n execute(\"ROLLBACK\")\n end", "def rollback_db_transaction() end", "def rollback_db_transaction() end", "def rollback\n @db.rollback\n end", "def rollback_db_transaction\n ...
[ "0.84933585", "0.84933585", "0.8283671", "0.8283671", "0.8127145", "0.80999076", "0.78685427", "0.78685427", "0.7858752", "0.7838174", "0.77186024", "0.76602536", "0.7622137", "0.7608282", "0.7582207", "0.75779754", "0.75752103", "0.75327504", "0.7505258", "0.74692154", "0.74...
0.7780022
10
Savepoint Interface Creates a (transactional) savepoint one can rollback to. Unlike 'plain' `ActiveRecord` it is allowed to pass a savepoint name.
def create_savepoint(name = current_savepoint_name) log("SAVEPOINT #{name}", 'TRANSACTION') { @connection.create_savepoint(name) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exec_rollback_to_savepoint(name = current_savepoint_name)\n log(\"ROLLBACK TO SAVEPOINT #{name}\", 'TRANSACTION') { @connection.rollback_savepoint(name) }\n end", "def create_savepoint(name = current_savepoint_name(true))\n release_savepoint(name) if existing_savepoint_name?(name)\n sup...
[ "0.7694426", "0.7623737", "0.75443494", "0.7108175", "0.5923058", "0.5874266", "0.5781033", "0.56733924", "0.56556267", "0.54954034", "0.54954034", "0.54954034", "0.54954034", "0.54954034", "0.5428379", "0.53508276", "0.53107053", "0.52920604", "0.5226993", "0.52247345", "0.5...
0.8096261
0
Transaction rollback to a given (previously created) savepoint. If no savepoint name given rollback to the last created one. Called from 'rollback_to_savepoint' in AbstractAdapter
def exec_rollback_to_savepoint(name = current_savepoint_name) log("ROLLBACK TO SAVEPOINT #{name}", 'TRANSACTION') { @connection.rollback_savepoint(name) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rollback_transaction(conn, opts=OPTS)\n if in_savepoint?(conn)\n log_connection_yield('Transaction.rollback_savepoint', conn){conn.rollback(savepoint_obj(conn))}\n else\n log_connection_yield('Transaction.rollback', conn){conn.rollback}\n end\n end", "def rollback_...
[ "0.71942616", "0.6826054", "0.6451056", "0.63729036", "0.63729036", "0.63484573", "0.6269715", "0.6269715", "0.6269715", "0.6269715", "0.6269715", "0.6227035", "0.6194844", "0.6194844", "0.61876184", "0.61573255", "0.6147801", "0.6147801", "0.6131383", "0.61112034", "0.607593...
0.8339665
0
Release a previously created savepoint.
def release_savepoint(name = current_savepoint_name) log("RELEASE SAVEPOINT #{name}", 'TRANSACTION') { @connection.release_savepoint(name) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def release(point)\n\t\t\n\tend", "def release(point)\n\t\t\n\tend", "def release(point)\n\t\t\n\tend", "def release(point)\n\t\t\n\tend", "def release(point)\n\t\t\t\t\n\t\t\tend", "def release(point)\n\t\tsuper(point)\n\tend", "def create_savepoint(name = current_savepoint_name(true))\n release_...
[ "0.722674", "0.722674", "0.722674", "0.722674", "0.70163953", "0.6775867", "0.65793693", "0.6033079", "0.59665394", "0.59233636", "0.591036", "0.591036", "0.5820695", "0.5711869", "0.56387585", "0.55901396", "0.55707484", "0.55658317", "0.5532543", "0.5532046", "0.55225295", ...
0.7597761
0
Gets services dynamically from module for rails admin selection
def kind_enum # Only classes and base class can't be selected Services.constants.select do |c| Services.const_get(c).is_a?(Class) && c != :Base end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main_services\n main_co.services\n end", "def services\n @services_manager\n end", "def services\n end", "def services\n ServiceLocator.service_names.map{|name| \"#{name}_service\".to_sym}\n end", "def list_services\n @services\n end", "def services\n unless @service...
[ "0.70924354", "0.70653266", "0.69642097", "0.69019437", "0.68727845", "0.68675977", "0.6852942", "0.6831881", "0.67676234", "0.6750557", "0.6740998", "0.67178506", "0.67056084", "0.6668765", "0.6636987", "0.65873873", "0.65507483", "0.6444492", "0.64258474", "0.63748944", "0....
0.0
-1
START Browse Action Tests
def test_get_index get :index assert_response :success end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test1Action\n executeTest(\n 'DummyUser',\n {\n 'DummyTool' => {\n 'DummyAction' => [\n []\n ]\n }\n }\n )\n end", "def test_003\n\n # login\n login\n @@pu = 1\n @@p...
[ "0.66013664", "0.64105886", "0.638466", "0.62344986", "0.6178465", "0.61123097", "0.6051982", "0.60236186", "0.59732795", "0.59589386", "0.5955443", "0.5937518", "0.5927585", "0.5920483", "0.5917375", "0.59161735", "0.59154874", "0.5907668", "0.5901746", "0.58961457", "0.5885...
0.0
-1
END Browse Action Tests START Browse Defect Tests
def test_get_nonexistent_continent assert_raise(ActiveRecord::RecordNotFound) { get :continent, :continent_code => 'GL', :continent_name => 'Gondwanaland' } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_002\n\n # login\n login\n @@pu = 1\n @@pj = 1\n open\"/devgroup/pj_index/#{@@pu}/#{@@pj}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu}/#{@@pj}\")\n #The contents of a display of a \"master\" tab become\n # a thing...
[ "0.68578845", "0.67133355", "0.66575646", "0.66213465", "0.66213465", "0.6412068", "0.6401228", "0.6366158", "0.63639957", "0.63636154", "0.6344919", "0.63262576", "0.6308626", "0.6292936", "0.6285739", "0.62802273", "0.6272148", "0.6265529", "0.62622845", "0.62597656", "0.62...
0.0
-1
opts can have keys" :hash_form
def components(opts = {}) opts[:hash_form] ? hash_form_array(:component) : object_form(:component) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sanitize_options(opts)\n opts = opts.to_hsh rescue opts.to_h\n \n HashWithIndifferentAccess.new(opts)\n end", "def relevant_options_digest(options); end", "def load(hash)\n @opts = hash\n end", "def params=(hash); end", "def params=(hash); end", "def key; @opts['key'] en...
[ "0.64559245", "0.6423782", "0.64234257", "0.64152306", "0.64152306", "0.6312778", "0.62213886", "0.61425644", "0.609628", "0.60873413", "0.607029", "0.606209", "0.59922534", "0.5964718", "0.5943323", "0.5943323", "0.5943323", "0.5943323", "0.5943323", "0.5943323", "0.5943323"...
0.0
-1
opts can have keys: :cols
def children_objects(type, opts = {}) self.clone_copy_output.children_objects(level(type), type, opts) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def colnum; @options.fetch(:colnum, 0); end", "def columns(cols, options = {})\n if cols.is_a? Array\n cols.each.map{|c| columns(c.first, c.count >= 2 ? c.second : {}) if c.is_a? Array }\n return\n end\n cols.split(/,\\s/).each do |col|\n n = col.split(':')\n id = n.fir...
[ "0.6659095", "0.6503524", "0.64285696", "0.62890756", "0.6174786", "0.6151229", "0.60430926", "0.60385543", "0.6008436", "0.5889924", "0.58576703", "0.57490665", "0.57094514", "0.5705763", "0.57038283", "0.5686613", "0.56641334", "0.56387085", "0.56217223", "0.5578129", "0.55...
0.0
-1
request is leaf node
def approver_group_notified return unless request.group_name send_event(EVENT_APPROVER_GROUP_NOTIFIED, :request_id => request.root.id, :group_name => request.group_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_leaf\n true\n end", "def is_leaf\n true\n end", "def leaf?\n !node?\n end", "def leaf?\n true\n end", "def leaf?; false end", "def leaf(node, tag)\r\n end", "def leaf?; @leaf; end", "def leaf_node?(node_id)\n @leaf_count < node_id\n end", "def leaf?(r)\n r.chi...
[ "0.66414416", "0.66414416", "0.6619851", "0.6516141", "0.6511789", "0.64122164", "0.6410618", "0.63338476", "0.62276137", "0.62275434", "0.6212207", "0.6189261", "0.61245453", "0.61234343", "0.6119546", "0.60960525", "0.60889244", "0.606563", "0.6029906", "0.60223407", "0.597...
0.0
-1
request is leaf node
def approver_group_finished return unless request.group_name send_event(EVENT_APPROVER_GROUP_FINISHED, :request_id => request.root.id, :group_name => request.group_name, :decision => request.decision, :reason => request.reason || '') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_leaf\n true\n end", "def is_leaf\n true\n end", "def leaf?\n !node?\n end", "def leaf?\n true\n end", "def leaf?; false end", "def leaf(node, tag)\r\n end", "def leaf?; @leaf; end", "def leaf_node?(node_id)\n @leaf_count < node_id\n end", "def leaf?(r)\n r.chi...
[ "0.66414416", "0.66414416", "0.6619851", "0.6516141", "0.6511789", "0.64122164", "0.6410618", "0.63338476", "0.62276137", "0.62275434", "0.6212207", "0.6189261", "0.61245453", "0.61234343", "0.6119546", "0.60960525", "0.60889244", "0.606563", "0.6029906", "0.60223407", "0.597...
0.0
-1
MongoMapper.database.collections.each do |c| puts c c.drop end MongoMapper.database $DATABASE_DEV note: programming by intention, this is the smallest goal I want to achieve
def find_people_around_football_pitch_around_jindigeling find_shops end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def teardown\n Mongoid::Clients.default.database.collection_names.each do |c|\n Mongoid::Clients.default[c].drop\n end\n end", "def clean_db\n Mongoid::Sessions.default.collections.select {|c| c.name !~ /system/}.each {|c| c.find.remove_all}\n end", "def teardown\n # Mongoid::Sessions.de...
[ "0.80612063", "0.72668755", "0.7017725", "0.697472", "0.6843106", "0.6713452", "0.6703108", "0.668582", "0.6681324", "0.6669801", "0.6657881", "0.657797", "0.6571152", "0.64720213", "0.64647424", "0.6410979", "0.64088976", "0.62796193", "0.61837983", "0.6173104", "0.6158883",...
0.0
-1
Returns an array of shops via a Dianping.com's search TODO: handling no record scenario, TODO: make sure the geo context is correct. play: more search via geo location play: watch out for updated information, redo the search or history bookkeeping.
def dianping_search_shops(keywords,limit_query_pages) shops = [] query_link = "#{$DIANPING_SHOP_SEARCH_PATH_START_PAGE}#{URI.escape(keywords)}" pages = DianpingPageParser.number_of_pages(query_link) puts pages max_page_to_crawl = (limit_query_pages.to_int < pages) ? limit_query_pages.to_int : pages (1..max_page_to_crawl).each { | page | shops << DianpingPageParser.shops_in_page(File.join(query_link, "p#{page}")) } return shops end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_by_location\n \tlat = params[:lat]\n \tlng = params[:lng]\n \tnext_start = params[:next_start]\n \tshops = Hotpepper.search_location(lat, lng, next_start);\n \tset_to_results(shops);\n end", "def index\n\n # search query\n if params[:q].nil?\n @shops = Shop.all\n else\n ...
[ "0.6720328", "0.6622495", "0.636436", "0.632069", "0.6091188", "0.6009157", "0.60049474", "0.5987633", "0.59522676", "0.59036195", "0.5845148", "0.5815751", "0.5814982", "0.57974005", "0.5791948", "0.5790009", "0.57899183", "0.5783678", "0.5783495", "0.5770429", "0.57684416",...
0.638052
2
Returns an array of users whose checkins were recorded in a specific shop.
def dianping_shop_checkins(shop) if shop is_a? Shop users = Shop.find_people_via_checkins end return users || [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def users\n #book_a.users\n #returns all the users that checked out this book\n\n checkout_array = Checkout.all.select {|checkout| checkout.book == self}\n checkout_array.map {|checkout| checkout.user}\n end", "def checkout\n @checkouts = Array.new\n User.all.each do |user|\n url = untapp...
[ "0.60277617", "0.5741701", "0.5729292", "0.572716", "0.5719351", "0.571868", "0.57101995", "0.56574583", "0.556235", "0.5557169", "0.54946303", "0.5398625", "0.53967273", "0.53673154", "0.5335916", "0.53343534", "0.53147274", "0.5304935", "0.5276906", "0.5271251", "0.52616566...
0.7747347
0
GET /profiles/1 GET /profiles/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_default_profile \n get(\"/profiles.json/default\")\nend", "def my_profiles\n @user = User.find(params[:user_id])\n @profiles = @user.profiles\n end", "def show\n profile = Profile.find(params[:id])\n render status: 200, json: profile\n end", "def index\n authorize Profile\n @profi...
[ "0.7775192", "0.749174", "0.7487005", "0.7365681", "0.73053837", "0.730274", "0.7301948", "0.72442514", "0.72312385", "0.72312385", "0.72312385", "0.7217105", "0.7217105", "0.71651936", "0.71406406", "0.71140933", "0.707894", "0.7045284", "0.701664", "0.69901544", "0.6978521"...
0.0
-1
PATCH/PUT /profiles/1 PATCH/PUT /profiles/1.json
def update respond_to do |format| if @profile.update(profile_params) format.html { redirect_to [@stakeholder, @profile], notice: 'Profile was successfully updated.' } format.json { render :show, status: :ok, location: [@stakeholder, @profile] } else format.html { render :edit } format.json { render json: @profile.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @profiles = current_user.profiles.find(params[:id])\n\n respond_to do |format|\n if @profiles.update(profile_params)\n format.html { redirect_to profiles_path, notice: 'Profile was successfully updated.' }\n format.json { render :show, status: :ok, location: @profiles }\n ...
[ "0.7385554", "0.7121749", "0.7113102", "0.7096679", "0.7091465", "0.7091465", "0.7091465", "0.7076842", "0.707045", "0.7063198", "0.70600575", "0.7022012", "0.70120174", "0.699651", "0.6985236", "0.6985236", "0.6985236", "0.6985236", "0.6979028", "0.697453", "0.6968044", "0...
0.6652365
73
Use callbacks to share common setup or constraints between actions.
def set_profile @stakeholder = Stakeholder.find(params[:stakeholder_id]) @profile = @stakeholder.profile 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 profile_params params.require(:profile).permit(:logo, :banner, :website_url, :facebook_url, :youtube_url, :twitter_url, :instagram_url, :name, :email, :phone, :street, :city, :state, :zip, :about_us) 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.6979893", "0.6781746", "0.6746611", "0.6742344", "0.6735229", "0.6592651", "0.65027124", "0.6498011", "0.648163", "0.647716", "0.64556813", "0.64386255", "0.63784456", "0.63756156", "0.636574", "0.6319542", "0.63004524", "0.6299559", "0.62925464", "0.62923217", "0.6289894"...
0.0
-1
belongs_to :dependent => :destroy does not work yet. Rails ticket 1079. Workaround method for now.
def after_destroy # Check to see if other notes still reference the article. If not, the destroy the article, too. if self.article.nil? return end if !Note.find(:first, :conditions => {:article_id => self.article_id}) art = Article.find(self.article_id) if !art.nil? art.destroy end end SyncLog.note_destroy(self.graph.id, self.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_from(associated_model)\n self.send(associated_model.class.to_s.foreign_key + '=', nil)\n save(false)\n end", "def save_belongs_to_association(reflection)\n association = association_instance_get(reflection.name)\n record = association && association.load_target\n if record &...
[ "0.5809686", "0.5802263", "0.5767624", "0.57599175", "0.57586217", "0.57054025", "0.5661682", "0.5620454", "0.55914825", "0.55906016", "0.55398196", "0.5537824", "0.5488921", "0.54496455", "0.54417133", "0.54247713", "0.54247713", "0.5417846", "0.5413322", "0.5402081", "0.537...
0.0
-1
why two levels? because for now commandobjects don't point to anything but primitives
def dup_two_levels self.class.new @klass, self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def command(type)\n end", "def subcommands(cmd); end", "def subcommands(cmd); end", "def subcommands() __subcommands__ end", "def commands; end", "def set_commands; end", "def command; end", "def command; end", "def command; end", "def command; end", "def command; end", "def command; end",...
[ "0.6768826", "0.6708912", "0.6708912", "0.6667368", "0.66593695", "0.6626346", "0.6579591", "0.6579591", "0.6579591", "0.6579591", "0.6579591", "0.6579591", "0.65385306", "0.65354", "0.6531205", "0.65148884", "0.6487029", "0.64765877", "0.6465257", "0.6436495", "0.64042646", ...
0.0
-1
We determine if we are equal to another command only by if we have equal values for all of our strict setter getters
def == o return false unless o.kind_of? self.class self.class.defined_accessors.each do |pair| name, attrib = *pair return false unless send(name) == o.send(name) end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eql?(other)\n self.class.equal?(other.class) &&\n @command == other.command &&\n @options == other.options\n end", "def ==(other)\n return false unless other.is_a? CommandArgs\n @args == other.args && @kwargs == other.kwargs\n end", "def equals(other)\n ret...
[ "0.693559", "0.65374565", "0.6099364", "0.5918105", "0.58485764", "0.5826577", "0.58264095", "0.5817626", "0.5803594", "0.5798009", "0.57391334", "0.57391334", "0.572498", "0.57180285", "0.562436", "0.5605937", "0.55946475", "0.55626386", "0.5556086", "0.5549214", "0.55379796...
0.5305994
87
eclipse_iu (installable unit) is eclipsespeak for the fully qualified name of the plugin
def eclipse_iu @resource[:install_options][0]['plugin_name'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate_plugin_name(name); end", "def translate_plugin_names; end", "def unoconv_pname\n 'LibreOffi'\n end", "def plugin(name); end", "def plugin_name\n 'imip'\n end", "def plugin_name\n 'browser'\n end", "def load_plugin(name); end", "def plugin_name\n ...
[ "0.6125613", "0.5993675", "0.57985467", "0.5708009", "0.5597193", "0.55517554", "0.54875267", "0.54254454", "0.5411678", "0.53928643", "0.5374364", "0.53740096", "0.53325003", "0.5275204", "0.5268606", "0.5260224", "0.52281547", "0.52163553", "0.5210662", "0.5203994", "0.5160...
0.7475672
0
validates :solution_description, presence: true
def assigned_user User.find_by_id(assigned_id).full_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solution_params\n params.require(:solution).permit(:issue_id, :description)\n end", "def description_present\n if description.blank?\n errors.add(:description, \"Can't be empty\")\n end\n end", "def solution_params\n params.require(:solution).permit(:description, :status, :ref)\n en...
[ "0.70381117", "0.6889956", "0.6611981", "0.65406346", "0.6515827", "0.63699317", "0.6369792", "0.6284803", "0.6272712", "0.6241582", "0.6195921", "0.6152266", "0.6119486", "0.6103676", "0.6086614", "0.6074591", "0.6045454", "0.6024478", "0.60225934", "0.59844095", "0.5983743"...
0.0
-1
Complete the maxXor function below.
def maxXor(arr, queries) # solve here # build a trie with each element of arr as leaf # binary tree left = "0", right = "1" # 30 levels trie_root = TrieNode.new arr.each do |x| p = trie_root xb = '%030b' % x xb.each_char do |bit| if bit == "0" # go left if p.left p = p.left else nn = TrieNode.new p.left = nn p = p.left end else # go right if p.right p = p.right else nn = TrieNode.new p.right = nn p = p.right end end end end ans_seq = [] queries.each do |q| # walk down the trie to leaf leaf = "" p = trie_root qb = '%030b' % q qb.each_char do |bit| # prefer opposite of bit if bit == "0" # try go right ("1") if p.right p = p.right leaf << "1" else p = p.left leaf << "0" end else # try to go left ("0") if p.left p = p.left leaf << "0" else p = p.right leaf << "1" end end end a = leaf.to_i(2) ans_seq << (a^q) end return ans_seq end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def maxXor(l, r)\n return 2**((l^r).to_s(2).size) - 1\nend", "def maximizingXor(l, r)\n range = (l..r).to_a\n range.product(range).map{ |a, b| a ^ b }.max \nend", "def max_opac\n unless states.empty?\n return states.collect do |state|\n state.max_opac\n end.min\n end\n return 2...
[ "0.80217206", "0.76717645", "0.6227789", "0.59065086", "0.5899728", "0.5899728", "0.5819309", "0.58088714", "0.57880455", "0.577485", "0.5754974", "0.5733791", "0.56739765", "0.5667797", "0.56393474", "0.56393474", "0.5636227", "0.5629259", "0.5609958", "0.5605941", "0.557961...
0.59604686
3
If byebug (ruby >= 2.0) or debugger (ruby < 2.0) are installed, start the debugger now.
def start_debugger # First try the more modern 'byebug' begin require "byebug" byebug rescue LoadError # If that fails, try the older debugger begin require 'debugger' debugger rescue LoadError self.log.info "No debugger found, can't break on failures." end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dbg\nbegin\n require 'rubygems'\n require 'ruby-debug'\n debugger\nrescue LoadError\nend\nend", "def _dbg\r\n require 'rubygems'\r\n require 'pp' # who would want debug without pp? not I\r\n begin\r\n require 'ruby-debug'\r\n debugger\r\n rescue LoadError => e\r\n throw \"unable...
[ "0.7490139", "0.68619466", "0.6566678", "0.6399796", "0.63815385", "0.6379341", "0.6299939", "0.60801005", "0.59769017", "0.5965962", "0.5965962", "0.58396", "0.58355117", "0.5805803", "0.57630837", "0.56930465", "0.562789", "0.56140256", "0.54856664", "0.5480241", "0.5462881...
0.8706907
0
GET /song_likes/1 GET /song_likes/1.json
def show @song_like = SongLike.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @song_like } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_likes media_id\n url = API + \"media/#{media_id}/likes?access_token=\" + @access_token\n get(url)['data'].map {|data| data}\n end", "def user_likes\n user = User.find(params[:user_id])\n likes = user.likes\n render json: likes\n\nend", "def index\n @likes = Like.all\n render jso...
[ "0.74144506", "0.7113796", "0.69737786", "0.6957806", "0.68721765", "0.677707", "0.67316383", "0.67182994", "0.66611516", "0.6635103", "0.6554324", "0.6549576", "0.65431774", "0.65418196", "0.65213966", "0.6510953", "0.64888287", "0.6461324", "0.6431884", "0.6431884", "0.6405...
0.72974855
1
GET /song_likes/new GET /song_likes/new.json
def new @song_like = SongLike.new respond_to do |format| format.html # new.html.erb format.json { render json: @song_like } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @like = Like.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @like }\n end\n end", "def create\n @song_like = SongLike.new(params[:song_like])\n\n respond_to do |format|\n if @song_like.save\n format.html { redirect_to @song...
[ "0.7450175", "0.73725474", "0.72309136", "0.69829315", "0.69789696", "0.69555914", "0.69555914", "0.69555914", "0.69555914", "0.69380575", "0.6891648", "0.6863503", "0.6863503", "0.67949307", "0.6739666", "0.67055506", "0.667649", "0.66280884", "0.6565905", "0.6563619", "0.65...
0.78610885
0
POST /song_likes POST /song_likes.json
def create @song_like = SongLike.new(params[:song_like]) respond_to do |format| if @song_like.save format.html { redirect_to @song_like, notice: 'Song like was successfully created.' } format.json { render json: @song_like, status: :created, location: @song_like } else format.html { render action: "new" } format.json { render json: @song_like.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def postlikes\n render json: @likes.length, status: 200\n end", "def create_likes\n end", "def create_likes\n end", "def create_likes\n end", "def like!\n self.like_count = self.like_count + 1\n self.save\n logger.debug \"Song :: #{self.title} liked.\"\n end", "def like!\n con...
[ "0.70101535", "0.67654824", "0.67654824", "0.67654824", "0.6746579", "0.67283636", "0.66585207", "0.66585207", "0.660296", "0.65758544", "0.6545449", "0.65244824", "0.65118456", "0.64997584", "0.6426476", "0.64153594", "0.6369961", "0.63651836", "0.63579744", "0.63438296", "0...
0.70278025
0
PUT /song_likes/1 PUT /song_likes/1.json
def update @song_like = SongLike.find(params[:id]) respond_to do |format| if @song_like.update_attributes(params[:song_like]) format.html { redirect_to @song_like, notice: 'Song like was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @song_like.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n render json: Like.update(params[\"id\"], params[\"like\"])\n end", "def increment_likes\n sneaker = find_sneaker\n sneaker.update(likes: sneaker.likes + 1)\n render json: sneaker\n end", "def update\n if params.has_key? :like\n @client.put(\"/me/favorites/#{para...
[ "0.6959894", "0.6898369", "0.6873039", "0.68421626", "0.6819684", "0.6679967", "0.66037256", "0.6493382", "0.64887947", "0.6461779", "0.63956606", "0.635596", "0.63480604", "0.6314305", "0.6271089", "0.62648445", "0.6236434", "0.6209488", "0.6203045", "0.6203045", "0.61980945...
0.7112842
0
DELETE /song_likes/1 DELETE /song_likes/1.json
def destroy @song_like = SongLike.find(params[:id]) @song_like.destroy respond_to do |format| format.html { redirect_to song_likes_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n render json: Like.delete(params[\"id\"])\n end", "def destroy\n @music_like = MusicLike.find(params[:id])\n @music_like.destroy\n\n respond_to do |format|\n format.html { redirect_to music_likes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @li...
[ "0.75393754", "0.7517691", "0.72948146", "0.7235361", "0.7235361", "0.7235361", "0.70959437", "0.7031776", "0.70234346", "0.70234346", "0.69898784", "0.69769585", "0.6947355", "0.6947355", "0.6947355", "0.6947355", "0.6947355", "0.6947355", "0.69064605", "0.69032913", "0.6902...
0.78860813
0
Loading queue object from yaml files results in not properly initialized queue and a type error when using it. Skip queue when converting to yaml. Will be nil after loading from yaml and must be recreated.
def to_yaml_properties super - [:@queue] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_queues\n if queue_file? && File.exists?(queue_file)\n @entries = YAML.load(File.new(queue_file).read)\n\n File.unlink(queue_file)\n end\n end", "def initialize\n @queue_options = {}\n @queue_configs = []\n end", "def load_config\n @config = ...
[ "0.6867127", "0.61315984", "0.5848391", "0.58303875", "0.57183", "0.56485367", "0.5638957", "0.5626257", "0.56181365", "0.5597159", "0.5571965", "0.55402446", "0.5504034", "0.5495787", "0.5386772", "0.538522", "0.5379094", "0.5354643", "0.533328", "0.53209543", "0.5298629", ...
0.52762556
23
notify the waiting thread that a command_set has finished it's run
def notify_done @notify_mutex.synchronize do queue.push(1) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finish\n @threads.each { |t| t.join }\n call_events(:finish, @command)\n @threads.clear\n end", "def wait\n @running.reset\n @waiting.set\n @running.wait\n end", "def wait_until_finished\n @active_requests.dup.each do |n|\n n.join\n e...
[ "0.65986747", "0.659157", "0.6320004", "0.6196379", "0.61831474", "0.61127913", "0.6080663", "0.6080663", "0.6080663", "0.607778", "0.6066604", "0.6042039", "0.60404724", "0.5970059", "0.59479135", "0.59479135", "0.593933", "0.5890548", "0.5884047", "0.5883875", "0.5862201", ...
0.6025436
13
This method returns the next command_set which is ready to run. If no node is ready because of constrains it will block the thread until notify_done was called from a finishing thread. If no command_set is in the state ready it will return nil.
def next_command_set(command_sets_to_run) @next_mutex.synchronize do ready_command_sets = command_sets_to_run.select{|n| n.state == :ready} return nil if ready_command_sets.empty? loop do return nil if state_failed? or signals[:stop] @notify_mutex.synchronize do queue.clear next_command_set = ready_command_sets.find{|cs| is_runnable?(cs.node)} unless next_command_set.nil? next_command_set.state_start return next_command_set end end queue.pop # wait until a thread notifies it has finished end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ready_task\n find do |task|\n task.ready?\n end\n end", "def ready (synchable)\n\n synchable.ldebug do\n \"ready() called by #{synchable.fei.to_debug_s} \" +\n \"#{@unready_queue.length} wi waiting\"\n end\n\n queue = @unready_queue\n @unready_queue = n...
[ "0.58282214", "0.5764436", "0.56254214", "0.56079185", "0.54422027", "0.54138726", "0.5402031", "0.53995013", "0.53593653", "0.53116345", "0.5255581", "0.52510333", "0.52152413", "0.51235104", "0.51164097", "0.5114175", "0.5095715", "0.50788647", "0.5068217", "0.5062522", "0....
0.781967
0
check if a node is runnable or if there are constrains which prevent it from running
def is_runnable?(node) if max_per_role > 0 running_groups[node.role] < max_per_role else true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_vacancy(node)\n !(node.left && node.right)\n end", "def can_accept?(task)\n # logger.info(\n # puts \"can_accept : task = #{task.inspect}, name = #{self.name}\"\n return false if task.nil?\n return false if (self.name.eql?('localhost'))\n # status may change, so need to check\n # lo...
[ "0.62046695", "0.61511564", "0.60998374", "0.6094818", "0.6094818", "0.596317", "0.595908", "0.5947867", "0.59345216", "0.58940107", "0.58813125", "0.5845774", "0.5845774", "0.5845774", "0.57739735", "0.5763119", "0.57498026", "0.5709097", "0.5709097", "0.5705307", "0.5679522...
0.6961505
0
return a hash with the group names as keys and the amount of running nodes as value
def running_groups role_counter = Hash.new(0) command_sets.each do |command_set| if [:running, :starting].include? command_set.state role_counter[command_set.node.role] += 1 end end role_counter end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_of_new_nodes\n \t{'New Nodes Added' => aw.node_added_count }\n \tend", "def number_of_new_nodes\n \t{'New Nodes Added' => aw.node_added_count }\n \tend", "def groups_in(node_name)\n @groups.data_for(node_name)['groups'] || {}\n end", "def aggregate\n counts = {}\n gro...
[ "0.6236876", "0.6236876", "0.61504346", "0.61041445", "0.609233", "0.6012491", "0.59191734", "0.58675", "0.5833526", "0.57822907", "0.5715408", "0.5688855", "0.5686854", "0.5667679", "0.5667679", "0.5662057", "0.56484985", "0.5625404", "0.5625226", "0.5592638", "0.55853355", ...
0.69258225
0
Will be skipped when dumping yaml, therefore nil after loading from yaml.
def queue @queue ||= Queue.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_yaml_object\n nil\n end", "def to_yaml_object\n nil\n end", "def yaml_file?; end", "def yaml_object_type\n nil\n end", "def read_yaml(throw_missing: T.unsafe(nil), **kwd); end", "def from_yaml\n results = YAML.load(self)\n \n # Replace bad values\n if re...
[ "0.70946413", "0.70946413", "0.6672679", "0.6570946", "0.644726", "0.6264", "0.6096333", "0.6096333", "0.6000598", "0.5930887", "0.5895997", "0.5894088", "0.58782274", "0.5864676", "0.5845689", "0.5831905", "0.5820957", "0.5820957", "0.5775356", "0.5741918", "0.57129604", "...
0.0
-1
GET /proyectominero2s GET /proyectominero2s.json
def index @proyectominero2s = Proyectominero2.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_proyectominero2\n @proyectominero2 = Proyectominero2.find(params[:id])\n end", "def index\n @bicepstriceps2s = Bicepstriceps2.all\n end", "def index\n if params[:propietario]\n @usuario = Usuario.find(params[:usuario_id])\n authorize! :show, @usuario\n @negocios_propios = ...
[ "0.6182335", "0.5837226", "0.58189654", "0.5715098", "0.5710772", "0.5578785", "0.54372406", "0.5424648", "0.538353", "0.5379659", "0.5349621", "0.53452927", "0.5335853", "0.5324027", "0.5229179", "0.5229179", "0.5222237", "0.522137", "0.521966", "0.5218293", "0.52150816", ...
0.7297018
0
GET /proyectominero2s/1 GET /proyectominero2s/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @proyectominero2s = Proyectominero2.all\n end", "def set_proyectominero2\n @proyectominero2 = Proyectominero2.find(params[:id])\n end", "def show\n @product2 = Product2.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json...
[ "0.70163065", "0.64495873", "0.59255457", "0.59112656", "0.5757934", "0.57215905", "0.57202154", "0.571031", "0.56956255", "0.56920964", "0.568806", "0.5672757", "0.5658837", "0.5658837", "0.5652408", "0.563381", "0.56083584", "0.5566164", "0.55629784", "0.5561067", "0.552403...
0.0
-1
POST /proyectominero2s POST /proyectominero2s.json
def create @proyectominero2 = Proyectominero2.new(proyectominero2_params) @proyectominero2[:user_id] = @user_id puts @proyectominero2[:user_id] respond_to do |format| if @proyectominero2.save format.html { redirect_to @proyectominero2, notice: 'Proyectominero2 was successfully created.' } format.json { render :show, status: :created, location: @proyectominero2 } else format.html { render :new } format.json { render json: @proyectominero2.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def proyectominero2_params\n params.require(:proyectominero2).permit(:code, :name, :user_id)\n end", "def create\n @bicepstriceps2 = Bicepstriceps2.new(bicepstriceps2_params)\n\n respond_to do |format|\n if @bicepstriceps2.save\n format.html { redirect_to @bicepstriceps2, notice: 'Bicep...
[ "0.6424797", "0.61014795", "0.59394616", "0.58475316", "0.5747115", "0.5692867", "0.5637399", "0.5531607", "0.54350954", "0.54121846", "0.53946453", "0.5390338", "0.5381138", "0.53646827", "0.5340217", "0.53147244", "0.52734876", "0.5262098", "0.5231716", "0.52271336", "0.522...
0.547164
8
PATCH/PUT /proyectominero2s/1 PATCH/PUT /proyectominero2s/1.json
def update respond_to do |format| if @proyectominero2.update(proyectominero2_params) format.html { redirect_to @proyectominero2, notice: 'Proyectominero2 was successfully updated.' } format.json { render :show, status: :ok, location: @proyectominero2 } else format.html { render :edit } format.json { render json: @proyectominero2.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_proyectominero2\n @proyectominero2 = Proyectominero2.find(params[:id])\n end", "def update\n @promocion = Promocion.find(params[:id])\n logger.debug \"-------------------------------------------------------\"\n logger.debug params[:promocion][:formadepago_ids]\n logger.debug \"---...
[ "0.6090932", "0.6007985", "0.5998861", "0.5983099", "0.59798175", "0.59776366", "0.59641343", "0.59578866", "0.5955673", "0.59382", "0.59373164", "0.5936199", "0.5915847", "0.5909665", "0.58937526", "0.58917654", "0.58903193", "0.58865935", "0.588383", "0.5879216", "0.5875565...
0.7085922
0
DELETE /proyectominero2s/1 DELETE /proyectominero2s/1.json
def destroy @proyectominero2.destroy respond_to do |format| format.html { redirect_to proyectominero2s_url, notice: 'Proyectominero2 was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @server1 = Server1.find(params[:id])\n @server1.destroy\n\n respond_to do |format|\n format.html { redirect_to server1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @odontologia1 = Odontologia1.find(params[:id])\n @odontologia1.destroy\n\n re...
[ "0.68049335", "0.67074704", "0.66802436", "0.66765225", "0.66579705", "0.66567826", "0.6610583", "0.6585789", "0.65806866", "0.6578983", "0.6578791", "0.6541785", "0.652494", "0.65248084", "0.65207726", "0.6515599", "0.64962053", "0.64959675", "0.64946645", "0.64871144", "0.6...
0.73682797
0
Use callbacks to share common setup or constraints between actions.
def set_proyectominero2 @proyectominero2 = Proyectominero2.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.6164095", "0.6046031", "0.5945298", "0.59179014", "0.58890367", "0.58341795", "0.5776118", "0.5700777", "0.5700777", "0.5656277", "0.56218207", "0.5423995", "0.5411516", "0.5411516", "0.5411516", "0.5395004", "0.53783494", "0.53593004", "0.53412604", "0.534078", "0.5332865...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def proyectominero2_params params.require(:proyectominero2).permit(:code, :name, :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.6979893", "0.6781746", "0.6746611", "0.6742344", "0.6735229", "0.6592651", "0.65027124", "0.6498011", "0.648163", "0.647716", "0.64556813", "0.64386255", "0.63784456", "0.63756156", "0.636574", "0.6319542", "0.63004524", "0.6299559", "0.62925464", "0.62923217", "0.6289894"...
0.0
-1
only when no has_ancestry
def stop_delete if self.id && self.id < 11 raise ActiveRecord::Rollback end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sane_ancestry?\n ancestry.nil? || (ancestry.to_s =~ Ancestry::ANCESTRY_PATTERN && !ancestor_ids.include?(self.id)) \n end", "def check_if_has_children\n self.lookups.count == 0\n end", "def ignore_parent_exclusion?; end", "def depthfirst?\n false\n end", "def ignore_parent_exclusio...
[ "0.72967345", "0.6931421", "0.6699044", "0.66153926", "0.65838563", "0.65785754", "0.64663476", "0.63657194", "0.63316566", "0.63075984", "0.63063943", "0.62869793", "0.6229176", "0.62248117", "0.6205661", "0.61984026", "0.6147501", "0.6141672", "0.6138268", "0.6112276", "0.6...
0.0
-1
Returns the current Redis connection. If none has been created, will create a new one.
def redis return @redis if @redis self.redis = 'localhost:6379' self.redis end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def redis\n parms =\n {\n :host => @host,\n :port => @port,\n :db => @database\n }\n\n $_redis_connection ||= Redis.new(parms)\n end", "def connect\n @redis ||= create\n end", "def connection\n RedisModel::Base.connection\n end", ...
[ "0.79104745", "0.76783204", "0.7637821", "0.754402", "0.75320333", "0.73548406", "0.73410505", "0.7291144", "0.7287146", "0.7287146", "0.7287146", "0.7246972", "0.7246972", "0.7246972", "0.71933687", "0.7147105", "0.7142247", "0.70780224", "0.70723706", "0.7068234", "0.703821...
0.69234115
25
O(n^2) which is quadratic time!
def okay_two_sum?(arr, target_sum) sorted = arr.sort sorted.each_with_index do |num, idx| target = target_sum - num return true if binary_search(sorted, target, num) end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\...
[ "0.71262777", "0.68800735", "0.6508513", "0.6507173", "0.6491702", "0.64238715", "0.638691", "0.636333", "0.6323467", "0.6307346", "0.6297802", "0.6280894", "0.62475246", "0.6247299", "0.6232608", "0.6221362", "0.6216807", "0.62084085", "0.61740553", "0.61623377", "0.61540717...
0.0
-1
Places the robot on the board in position X,Y and facing NORTH, SOUTH, EAST or WEST
def place(x, y, direction) raise TypeError, 'Invalid coordinates' unless x.is_a? Integer and y.is_a? Integer raise TypeError, 'Invalid direction' unless DIRECTIONS.include?(direction) return false unless valid_position?(x, y) @position = { x: x, y: y } @direction = direction true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def place(robot, x:0, y:0)\n raise PlacementError.new \"Coordinates (#{x},#{y}) are not on this board\" if \n !width_range.include?(x) || !height_range.include?(y)\n # @playing_field[x][y] = robot\n @robots[robot] = {x: x, y: y}\n robot.place(self)\n end", "def move\n case @toy_direction\n ...
[ "0.7014113", "0.6885764", "0.6792347", "0.66941637", "0.66223013", "0.65164053", "0.64042723", "0.6393004", "0.63708675", "0.63499534", "0.6347441", "0.6291623", "0.6255879", "0.6247514", "0.6232943", "0.6209512", "0.62019527", "0.6184982", "0.616402", "0.61450106", "0.614210...
0.0
-1
Moves the robot one unit forward in the direction it is currently facing
def move return false if @position.nil? movements = { north: { x: 0, y: 1 }, east: { x: 1, y: 0 }, south: { x: 0, y: -1 }, west: { x: -1, y: 0 } } position, movement = @position, movements[@direction] return false unless valid_position?(position[:x] + movement[:x], position[:y] + movement[:y]) @position = { x: position[:x] + movement[:x], y: position[:y] + movement[:y] } true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_forward\n new_location = @location + facing_direction.coordinate_component\n \n if !surface.within_bounds?(new_location)\n raise OutOfBoundaryError, \"The movement has put the robot out of boundaries\"\n end\n \n @location = new_location\n self\n end", "def f...
[ "0.8134495", "0.78324604", "0.7665074", "0.7433086", "0.7414301", "0.73746246", "0.73363715", "0.69001186", "0.6851061", "0.68235445", "0.6796847", "0.6786047", "0.6763337", "0.67607224", "0.6692402", "0.66691494", "0.6644748", "0.66328764", "0.6612352", "0.6538308", "0.65302...
0.0
-1
Returns the X,Y and Direction of the robot
def report return "Not on board" if @position.nil? or @direction.nil? "#{@position[:x]},#{@position[:y]},#{@direction.to_s.upcase}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def position\n puts \"X: #{@x_coord}\"\n puts \"Y: #{@y_coord}\"\n puts \"Direction: #{@direction}\"\n end", "def near_xy direction\n nx = @x\n ny = @y\n delta = [\"ny -= 1\", \"nx += 1\", \"ny += 1\", \"nx -= 1\"]\n @angle.times{delta.push delta.shift}\n direction_index = ['f','r','b','...
[ "0.6960154", "0.66306275", "0.65223086", "0.65220875", "0.6433028", "0.6346873", "0.63243526", "0.6262036", "0.62360185", "0.6227738", "0.6204321", "0.6193288", "0.6170154", "0.6150194", "0.6134255", "0.61071503", "0.6086386", "0.6074544", "0.60576725", "0.60527176", "0.60456...
0.5568673
68
Evals and executes a string command.
def eval(input) return if input.strip.empty? args = input.split(/\s+/) command = args.first.to_s.downcase.to_sym arguments = args.last raise ArgumentError, 'Invalid command' unless COMMANDS.include?(command) case command when :place raise ArgumentError, 'Invalid command' if arguments.nil? tokens = arguments.split(/,/) raise ArgumentError, 'Invalid command' unless tokens.count > 2 x = tokens[0].to_i y = tokens[1].to_i direction = tokens[2].downcase.to_sym place(x, y, direction) when :move move when :left rotate_left when :right rotate_right when :report report else raise ArgumentError, 'Invalid command' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_command(str)\n Shellissimo.with_error_handling do\n command = @input_parser.parse_command(str)\n puts format instance_eval(&command.block)\n end\n end", "def execute(command_string)\n Runner.instance.cross_call command_string\n end", "def execute(input_string)\n in...
[ "0.7226228", "0.6979381", "0.6978896", "0.6842509", "0.6841425", "0.6824786", "0.67988217", "0.67216617", "0.6682211", "0.6627952", "0.66056275", "0.65997386", "0.65315396", "0.65315396", "0.65315324", "0.6523913", "0.6523123", "0.6520865", "0.64750385", "0.6471476", "0.64564...
0.0
-1
Compare if two strings have less then 3 chars equals
def test_less_than_3_equal_chars assert_equal(false,compare('1234','1325')) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def third_ana(str1, str2)\n sorted1 = str1.chars.sort\n sorted2 = str2.chars.sort\n sorted1 == sorted2\nend", "def string_scramble(str1, str2)\r\n str2.chars.all? { |x| str1.count(x) >= str2.count(x) }\r\nend", "def third_anagram?(string1, string2)\n chars1 = string1.chars.sort\n chars2 = string2.chars.s...
[ "0.75032854", "0.7042264", "0.6976425", "0.6952992", "0.69413394", "0.6905814", "0.68864846", "0.6810362", "0.6801974", "0.6771305", "0.674886", "0.6744827", "0.6743547", "0.6738902", "0.6719764", "0.67191803", "0.6717567", "0.6717567", "0.6717567", "0.6717567", "0.6717567", ...
0.7623301
0
Instance Methods Grabs all contacts associated with this account and the rest of the contacts in the scope. Logic: If +portal_case_scope__c+ is +SCOPE[:this_account]+, grab just the contacts associated with this account. If +portal_case_scope__c+ is +SCOPE[:children_accounts]+, grab this this account's contacts plus the contacts of its child accounts. If +portal_case_scope__c+ is empty and there is a parent, defer to the parent of this account. If +portal_case_scope__c+ is empty and there is NOT a parent, then grab just its associated contacts. If +portal_case_scope__c+ is empty and the root account's +portal_case_scope__c+ is also empty, then grab just those contacts directly associated with this account (and NOT those with the ancestor accounts).
def associated_contacts(accounts_path = []) if portal_case_scope__c == SCOPES[:this_account] contacts elsif portal_case_scope__c == SCOPES[:children_accounts] self.contacts + sibling_contacts elsif portal_case_scope__c.nil? and parent parent.associated_contacts(accounts_path << self) else # portal_case_scope__c is nil and this is root if accounts_path.empty? contacts else accounts_path.first.contacts end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contacts\n Contact.where(account_ids: self._id)\n end", "def contacts(params = {})\n # contacts in this group\n @contacts ||= get_contacts({\"group\" => self.id}.merge(params))\n end", "def case\n @account = @case.account\n # find the account we are grabing contacts from. this is use...
[ "0.5875162", "0.55810314", "0.55255574", "0.54758084", "0.5382904", "0.5361437", "0.52924657", "0.52800417", "0.52296174", "0.5164685", "0.5159281", "0.5060566", "0.5020907", "0.5003781", "0.49790698", "0.49642307", "0.4950846", "0.49462676", "0.48950413", "0.48916897", "0.48...
0.7968411
0
Query doesn't work in ASF for siblings.
def sibling_accounts Sfaccount.find(:all, :conditions => ["parent_id = ?",id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def siblings\n teachable.media.where(sort: sort)\n end", "def left_sibling\n siblings.where(arel_table[snumv_column_name].eq(numv)).\n where(arel_table[sdenv_column_name].eq(denv)).first\n end", "def self_and_siblings\n dataset.nested.filter(self.class.qualified_pare...
[ "0.6565665", "0.6427067", "0.6412354", "0.63855445", "0.634301", "0.6324875", "0.63032067", "0.62764543", "0.62691164", "0.62453485", "0.62339234", "0.6167544", "0.6129583", "0.61256933", "0.61033237", "0.60631585", "0.6047185", "0.6043797", "0.6027462", "0.59774053", "0.5977...
0.5521122
54
Returns ancestors, siblings, children, and this account.
def all_in_tree accounts = Array.new accounts += ancestors accounts += sibling_accounts accounts += children accounts << self return accounts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_children_accounts\n if(current_user.role == \"Parent\")\n current_user.find_children.map{ |c| [c.get_accounts(c)[0], c.get_accounts(c)[1]]}.flatten\n end\n end", "def self_and_ancestors\n \t\tres = [self] + self.ancestors\n \t\treturn res.uniq\n \tend", "def account_list\...
[ "0.7272906", "0.6777231", "0.66082484", "0.66066164", "0.6581132", "0.65596396", "0.6503975", "0.64935976", "0.64854294", "0.64854294", "0.64854294", "0.64854294", "0.64535314", "0.64439255", "0.64401037", "0.64401037", "0.64294475", "0.64294475", "0.64206636", "0.64200544", ...
0.7909146
0
Initialize a model and build via a block
def initialize(*) super yield self if block_given? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(model, &block)\n @model = model\n @associations = {}\n @fields = []\n @attributes = []\n @conditions = []\n @groupings = []\n @options = {}\n @delta_object = nil\n \n initialize_from_builder(&block) if block_given?\n end",...
[ "0.75944704", "0.7004971", "0.6791078", "0.673156", "0.64625245", "0.6453866", "0.64320344", "0.63829386", "0.63524806", "0.6288333", "0.6277883", "0.62624705", "0.62624705", "0.62624705", "0.620875", "0.6204275", "0.62000376", "0.6172755", "0.61627465", "0.6159772", "0.60658...
0.0
-1
i = 1 every_other = [] 50.times do every_other << i i = i + 2 end p every_other end every_other
def every_other i = 1 numbers = [] 50.times do numbers << i i+= 2 end return numbers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_next_statement\n i = 0\n result = []\n while i < 10\n i += 1\n next if (i % 2) == 0\n result << i\n end\n assert_equal (1..10).step(2).to_a, result\n end", "def multiples(i)\n ms = []\n (1..10).each do |j|\n ms << i * j\n end\n ms\nend", "def sequence(integer1, in...
[ "0.67374325", "0.6702775", "0.6588957", "0.6558962", "0.6543391", "0.6467349", "0.64239895", "0.6417174", "0.6416611", "0.6413696", "0.6406066", "0.64041847", "0.63754714", "0.6359367", "0.63562423", "0.6316399", "0.631339", "0.6302425", "0.6301963", "0.6291431", "0.6280266",...
0.8751656
0
Process HAML file. Deals with layout.
def process_haml(domain_path, base_path, static_path) layout = nil # Layout layout_path = domain_path << "/__layout__" if File.exists? settings.dir.dup << "/pages/" << layout_path << ".haml" layout = layout_path.to_sym end # Page code = haml base_path[0..-6].to_sym, :layout => layout File.open(static_path, "w") do |io| io.write(code) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process(haml, base_path, &block)\n helper = Helper.new(base_path, self)\n\n Haml::Engine.new(haml).render(helper, {}, &block)\n end", "def load_haml(modelname, filename)\n @modelname = modelname\n @filename = filename\n $filename = filename\n $is_private = false\n ...
[ "0.68395865", "0.6383707", "0.62451565", "0.59050316", "0.5784923", "0.5753657", "0.5742401", "0.57275337", "0.55585235", "0.5528374", "0.55230266", "0.55230266", "0.55151683", "0.54675233", "0.538593", "0.537291", "0.5361597", "0.5353956", "0.5309387", "0.53045905", "0.52539...
0.6069634
3
Converts domain name to path in filesystem
def domain_to_path(host) path = host.split(".") path.reverse! if path.length > 1 path.join("/") # returns end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def canonicalize\n FilePath.new(File.expand_path(to_s))\n end", "def path\n name.split(\"::\").join(\"/\").downcase\n end", "def cleanse_domain(domain)\n domain.downcase!\n domain = domain.sub(/^https?\\:\\/\\//, '').sub(/^www./,'')\n domain = domain.split(\"/\").first\n dom...
[ "0.6311151", "0.6309107", "0.62557983", "0.6147273", "0.6133952", "0.6111725", "0.60539377", "0.5971529", "0.59590876", "0.5959062", "0.59480137", "0.5938237", "0.59320295", "0.5918619", "0.59135175", "0.59135175", "0.5901354", "0.58748674", "0.58710957", "0.58677906", "0.585...
0.71987534
0
Use callbacks to share common setup or constraints between actions.
def set_task @task = Task.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.6164095", "0.6046031", "0.5945298", "0.59179014", "0.58890367", "0.58341795", "0.5776118", "0.5700777", "0.5700777", "0.5656277", "0.56218207", "0.5423995", "0.5411516", "0.5411516", "0.5411516", "0.5395004", "0.53783494", "0.53593004", "0.53412604", "0.534078", "0.5332865...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def task_params if params[:task].present? params.require(:task).permit(:id, :name, :description, :due_date, :task_type, :done) else params.permit(:id, :name, :description) 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
$db_hostname = 'localhost' $db_user = 'root' $db_pass = 'root' $db_name = 'inventory' $db_table_name = 'inventory' This function opens a connection to the database
def open_connection begin db = Mysql.new($db_hostname, $db_user, $db_pass) rescue Mysql::Error abort "Oops! Couldn't connect to database! Make sure you entered the correct information." end return db end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def open_connection\n\tbegin\n\t\tdb = Mysql.new $db_hostname, $db_user, $db_pass\n\trescue Mysql::Error\n\t\tabort \"Oops! Couldn't connect to database! Make sure you entered the correct information.\"\n\tend\n\treturn db\nend", "def _connect_database\n _send_command(\"db_connect #{@options[:db_user]}:...
[ "0.69481665", "0.6849301", "0.6827265", "0.6797318", "0.67589647", "0.67538077", "0.6753482", "0.6731647", "0.6726412", "0.6726412", "0.66784143", "0.6668217", "0.6658907", "0.66548544", "0.6631353", "0.6602661", "0.6557693", "0.65363544", "0.65360683", "0.65206105", "0.64968...
0.6884676
1
This function displays the contents of the database
def display_contents # Open connection db = open_connection begin # Set results equal to the result of the MySQL query results = db.query "SELECT * FROM #{$db_name}.#{$db_table_name}" puts "Number of items: #{results.num_rows}" puts "+----------------+---------------------------------+-----------------+----------+---------+-----------------------------+" puts "| Barcode".ljust(17) + "| Item Name:".ljust(34) + "| Item Category".ljust(18) + "| Quantity".ljust(11) + "| Price".ljust(10) + "| Description".ljust(29) + " |" puts "+----------------+---------------------------------+-----------------+----------+---------+-----------------------------+" # Loop through the results and output the data results.each_hash do |item| print "| #{item['Barcode']}".ljust(17) print "| #{item['ItemName']}".ljust(34) print "| #{item['ItemCategory']}".ljust(18) print "| #{item['Quantity']}".ljust(11) print "| #{item['Price']}".ljust(10) print "| #{item['Description']}".ljust(29) + " |" print "\n" end puts "+----------------+---------------------------------+-----------------+----------+---------+-----------------------------+" results.free rescue abort "Could not retrieve information from database. Ensure that table name has been entered properly." ensure db.close end home_screen end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_entries(db)\n\tentries = db.execute(\"SELECT * FROM books\")\n\tif entries == []\n\t\tputs \"You have zero logged books!\"\n\t\tputs\n\telse\n\t\tentries.each do |book|\n\t \t\tputs \"#{book['id']}. #{book['book_name']} by #{book['author']}\"\n\t \t\tputs \"\tPublished: #{book['year_pubished']}, Readin...
[ "0.72559404", "0.7142108", "0.7101807", "0.7033154", "0.7000157", "0.6966503", "0.6934878", "0.68238765", "0.6814954", "0.6741536", "0.6729001", "0.6693299", "0.6582194", "0.6545666", "0.6535862", "0.65237916", "0.6518217", "0.65140057", "0.641251", "0.6411742", "0.6404482", ...
0.7424993
0
This function allows the user to add information into the database
def add_information # Open connection db = open_connection # Get user input print "Enter Barcode: " barcode = gets.strip print "Enter Item Name: " item_name = gets.strip print "Item Category: " item_category = gets.strip print "Quantity: " quantity = gets.strip print "Price: " price = gets.strip print "Description: " description = gets.strip begin # Prepare database query and execute it insert_new_item = db.prepare "INSERT INTO #{$db_name}.#{$db_table_name} (Barcode, ItemName, ItemCategory, Quantity, Price, Description) VALUES (?, ?, ?, ?, ?, ?)" insert_new_item.execute barcode,item_name,item_category,quantity,price,description insert_new_item.close rescue # Catch any errors abort "There was an error adding information into the database." ensure # Close the connection to the database db.close end puts "Information added successfully!" home_screen end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_person\n puts \"Enter name: \"\n name = gets.chomp\n puts \"Enter job: \"\n job = gets.chomp\n puts \"Enter gender: \"\n gender = gets.chomp\n puts \"Enter age: \"\n age = gets.chomp\n\n # insert_person_to_db\n $db.execute(\"INSERT INTO people (name, job, gender, age) VALUES (?, ?, ?, ?)\", name,...
[ "0.71868336", "0.7167109", "0.7152866", "0.70868003", "0.7064213", "0.70191485", "0.70112765", "0.6990257", "0.6898604", "0.68650216", "0.6854931", "0.6853597", "0.68484724", "0.6813762", "0.68015987", "0.679783", "0.67779434", "0.6746536", "0.67458427", "0.67297417", "0.6714...
0.7112345
3
This function allows the user to delete information from the database
def delete_information # Open connection db = open_connection # Get user input print "Enter the barcode for the item you'd like to delete: " barcode = gets.strip begin # Check if barcode exists delete_item = db.prepare "DELETE FROM #{$db_name}.#{$db_table_name} WHERE Barcode = ?" delete_item.execute barcode delete_item.close rescue # Catch any errors abort "There was an error deleting item from the database. Please ensure that item exists." ensure # Close the connection to the database db.close end print "Information deleted successfully!\n" home_screen end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n \n end", "def delete\n end", "def delete\n end", "def delete\n \n end", "def delete\n end", "def delete\n DATABASE.execute(\"DELETE FROM students WHERE id = #{@id}\")\n end", "def delete\n DATABASE.execute(\"DELETE from students WHERE id = #{id}\")\n en...
[ "0.7882988", "0.7654785", "0.7601904", "0.7582073", "0.7538292", "0.75289404", "0.74948496", "0.7481941", "0.74549866", "0.74135745", "0.73811907", "0.73811907", "0.73811907", "0.73811907", "0.73811907", "0.73811907", "0.73811907", "0.7371326", "0.7367016", "0.7266481", "0.72...
0.7126751
29
This function displays the home screen for the application and receives user choice
def home_screen print "\n+---------------------------------------\n" puts "| What would you like to do?" puts "| 1: List Database Contents" puts "| 2: Enter New Item Into Database" puts "| 3: Remove Item From Database" puts "| 4: Update Item Information" puts "| 5: Exit" print "| " user_choice = gets.strip print "\n" case user_choice when "1" display_contents when "2" add_information when "3" delete_information when "4" update_information when "5" abort "Goodbye!" else puts "You entered an incorrect option." home_screen end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def home\n @prompt = TTY::Prompt.new\n clear_terminal\n divider\n choice = @prompt.select(\"Hi,#{@user.name} what do you want to do today?\\n\",\n [\"Look for player information\",\"Look for club information\",\"Look for league information\", \"Trivia\"],\"-> Quit\",\"-> Restart\" )\n ...
[ "0.7408151", "0.7368465", "0.69837356", "0.69769496", "0.6955913", "0.6898987", "0.68598676", "0.6807351", "0.6773787", "0.67671025", "0.6749658", "0.6742748", "0.6718981", "0.67119163", "0.67043835", "0.66926783", "0.6626166", "0.66145456", "0.6613175", "0.66129744", "0.6593...
0.7824819
0
This function loads the sample data from the global $sample_data_filename
def load_sample_data begin # try to load the file # open the file and create an array to hold it sample_data_file = File.open($sample_data_filename) sample_contents = Array.new{Array.new} i = 0 # add the contents of the file to the two-dimensional array sample_data_file.each do |line| sample_contents[i] = line.split(",").map(&:strip) i += 1 end return sample_contents rescue # catch exceptions abort "Unable to continue - sample data file #{$sample_data_filename} not found." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_sample(file)\n path = Rails.root.join(\"lib\", \"assets\", \"sample_data\", \"#{file}.json\")\n file_data = File.read(path)\n return JSON.parse(file_data, symbolize_names: true)\n end", "def sample_data(file_name)\n file = File.expand_path(File.dirname(\"spec/assets/*\")) + \"/#{file_name}\"\...
[ "0.71004534", "0.67214215", "0.63412744", "0.62579703", "0.62555635", "0.62486875", "0.6206031", "0.6188572", "0.61854774", "0.6144315", "0.6103762", "0.60928303", "0.6086961", "0.6086961", "0.6067275", "0.6058215", "0.5995293", "0.59876657", "0.59452933", "0.5939697", "0.592...
0.79335976
0
Sometimes we need to create more than one subject from a MARC field with a subfield 0, but the subject creation will fail if you try to create subjects with duplicate authority ids. Only create an authority id for the first subject created, and leaves authority id blank
def set_auth_id(node) siblings = node.search("./preceding-sibling::*[not(@code='0' or @code='2')]") auth_id = node.parent.at_xpath("subfield[@code='0']").inner_text if siblings.empty? auth_id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n admin_only\n @subject = Subject.new(subject_params)\n\n new_tutor_ids = []\n unless params[:subject][:people_teaching_attributes].blank?\n params[:subject][:people_teaching_attributes].each do |attribute|\n id = attribute[1][:incoming_tutor_id]\n new_tutor_ids << id unle...
[ "0.61229634", "0.60943455", "0.5982701", "0.59781104", "0.58848864", "0.58431", "0.5729768", "0.568986", "0.5645864", "0.56101215", "0.5574035", "0.5566314", "0.5512646", "0.55067426", "0.54951084", "0.54820055", "0.54783064", "0.546708", "0.542672", "0.54250157", "0.54154795...
0.0
-1
usually, rel will be :subjects, but in some cases it will be :places
def subject_map(terms, rel = :subjects) { :obj => :subject, :rel => rel, :map => { 'self::subfield' => proc { |subject, node| subject.publish = true subject.terms = terms.call(node) subject.source = node.parent.at_xpath("subfield[@code='2']").inner_text unless node.parent.at_xpath("subfield[@code='2']").nil? subject.vocabulary = '/vocabularies/1' subject.authority_id = set_auth_id(node) unless node.parent.at_xpath("subfield[@code='0']").nil? } }, :defaults => { :source => 'Source not specified' } } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rel; end", "def relation_subjects(record)\n query = ActiveFedora::SolrQueryBuilder.construct_query_for_rel(\n [[:has_model, proxy_class.to_rdf_representation], [:proxyFor, record.id]]\n )\n rows = ActiveFedora::SolrService::MAX_ROWS\n ActiveFedora::SolrService.query(query...
[ "0.63231575", "0.62572974", "0.6161934", "0.6097942", "0.5964886", "0.59556246", "0.5808036", "0.57749945", "0.57052696", "0.5643922", "0.56438655", "0.5627229", "0.55772585", "0.5560013", "0.55511343", "0.5538708", "0.5523052", "0.5514665", "0.5509129", "0.5509129", "0.54932...
0.607824
4
Sets operator and inserts separators in between variables.
def translate self.operator = OPERATORS.fetch(operator) { raise CompileError, "#{operator} operator not supported" } separator = Node[:separator].new(operator.separator) prefix = Node[:separator].new(operator.prefix) self.payload = Array(payload.inject { |list, element| Array(list) << t(separator) << t(element) }) payload.unshift(prefix) if operator.prefix self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def operators= new_ops\n @operators = new_ops.gsub(/[^+*-]/, '').split(//)\n reset\n end", "def operator_ruby_string\n operator_string + \" \"\n end", "def complete_operator(node)\n definition.operator_by_field_name(node.value).map { |o| o.end_with?(' ') ? o : \"#{o} \" }\n end", "def ...
[ "0.6840857", "0.67293906", "0.6564949", "0.65172076", "0.64232785", "0.64232785", "0.6243785", "0.61767745", "0.6145631", "0.61209726", "0.6101651", "0.6072702", "0.602878", "0.5966229", "0.5966229", "0.5961776", "0.5845326", "0.5845326", "0.5845326", "0.5832655", "0.5832655"...
0.53355706
65
buffer for potential look ahead
def lookahead_buffer @lookahead_buffer ||= [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def look_ahead(kclass, index, char, buffer, classified_sentence, nivel_parentese)\n if @raw[index + 1] && kclass::REGEX.match( \"#{buffer}#{char}#{@raw[index + 1]}\" )\n buffer.concat char\n else\n classified_sentence.push kclass.new(buffer+char)\n buffer.clear\n end\n end", "def look_ah...
[ "0.712338", "0.686266", "0.683747", "0.6594998", "0.63869214", "0.63171285", "0.6259396", "0.62466055", "0.62466055", "0.61881804", "0.60869163", "0.608431", "0.6067577", "0.59948516", "0.5991536", "0.5991536", "0.5991536", "0.59722984", "0.5960861", "0.58967763", "0.58943546...
0.7432294
1
handle a single element from the array
def track(element) return list_for(element) << element if lookahead_buffer.empty? return lookahead_buffer << element if lookahead? element lookahead = lookahead_buffer.dup lookahead = create_lookahead(lookahead, false) if element.is_a? Node[:separator] lookahead_buffer.clear payload.concat(lookahead) << element end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def retrieve_first_element_from_array(array)\n array[0]\nend", "def retrieve_first_element_from_array(array)\n return array[0]\nend", "def first_element(array)\n array[0]\nend", "def first_item(elective_array)\n return elective_array[0]\nend", "def retrieve_first_element_from_array(array)\n array.fi...
[ "0.6777386", "0.675957", "0.6727587", "0.6725391", "0.67118245", "0.66755676", "0.6492667", "0.64710563", "0.6448609", "0.6434025", "0.6419177", "0.6396486", "0.63961774", "0.63961774", "0.6299944", "0.6276904", "0.6276904", "0.6276904", "0.62559927", "0.62559927", "0.6255992...
0.0
-1
turn look ahead buffer into look ahead node
def create_lookahead(elements, *args) return elements unless elements.size > 1 [Node[:with_look_ahead].new(elements, *args)] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def look_ahead(kclass, index, char, buffer, classified_sentence, nivel_parentese)\n if @raw[index + 1] && kclass::REGEX.match( \"#{buffer}#{char}#{@raw[index + 1]}\" )\n buffer.concat char\n else\n classified_sentence.push kclass.new(buffer+char)\n buffer.clear\n end\n end", "def look_ah...
[ "0.6571995", "0.62932235", "0.6283378", "0.6283378", "0.62363005", "0.5944797", "0.5860652", "0.5851974", "0.5845201", "0.5843893", "0.5835297", "0.5835297", "0.5835297", "0.5824453", "0.56735045", "0.56394064", "0.5632233", "0.5623401", "0.55420375", "0.55302507", "0.5526820...
0.5525163
21
can the given element be used in a lookahead?
def lookahead?(element, in_lookahead = false) case element when Node[:char] then in_lookahead when Node[:group] then lookahead_payload?(element.payload, in_lookahead) when Node[:optional] then lookahead?(element.payload, true) or expect_lookahead?(element.payload) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lookahead(lookahead = nil) \n @lookahead = lookahead unless lookahead.nil?\n @lookahead\n end", "def expect_lookahead?(element)\n return element.class == Node[:capture] unless element.is_a? Node[:group]\n element.payload.all? { |e| expect_lookahead?(e) }\n end", ...
[ "0.7090985", "0.67719847", "0.67719847", "0.6658072", "0.6658072", "0.645582", "0.64471513", "0.6356109", "0.62440825", "0.62440825", "0.60656714", "0.5877403", "0.58204025", "0.58177274", "0.56340057", "0.56340057", "0.5560968", "0.5560968", "0.55575055", "0.5447348", "0.544...
0.6795669
2
does the list of elements look lookaheadish to you?
def lookahead_payload?(payload, in_lookahead) return unless payload[0..-2].all? { |e| lookahead?(e, in_lookahead) } expect_lookahead?(payload.last) or lookahead?(payload.last, in_lookahead) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_for(element)\n expect_lookahead?(element) ? lookahead_buffer : payload\n end", "def list_for(element)\n expect_lookahead?(element) ? lookahead_buffer : payload\n end", "def create_lookahead(elements, *args)\n return elements unless elements.size > 1\n ...
[ "0.6453942", "0.6453942", "0.6257085", "0.61439216", "0.5880077", "0.5837135", "0.5837135", "0.55989635", "0.55989635", "0.5563123", "0.5544219", "0.55290323", "0.55127263", "0.5496163", "0.5496163", "0.5470681", "0.5434442", "0.54006726", "0.54006726", "0.53724897", "0.53066...
0.5220684
26
can the current element deal with a lookahead?
def expect_lookahead?(element) return element.class == Node[:capture] unless element.is_a? Node[:group] element.payload.all? { |e| expect_lookahead?(e) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lookahead(lookahead = nil) \n @lookahead = lookahead unless lookahead.nil?\n @lookahead\n end", "def lookahead(input: $input)\n $lookahead = input.getc\nend", "def lookahead(input: $input)\n $lookahead = input.getc\nend", "def lookahead(input: $srcin)\n $lookahead = input.getc\nend"...
[ "0.67900527", "0.64776665", "0.64776665", "0.63481325", "0.6316817", "0.6316817", "0.6305322", "0.6260874", "0.6243686", "0.61513036", "0.61513036", "0.6115929", "0.6062335", "0.6032461", "0.5979385", "0.55537844", "0.55537844", "0.5526214", "0.5526214", "0.54737514", "0.5462...
0.6359956
4
helper method for deciding where to put an element for now
def list_for(element) expect_lookahead?(element) ? lookahead_buffer : payload end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def store_element_position_top locator, variable_name\r\n command 'storeElementPositionTop', locator, variable_name\r\n end", "def positioned where\n self[where] ||= RenderNodeList.new\n end", "def place_in_layout?; end", "def place_in_layout?; end", "def move_to element_name, right_by = nil, d...
[ "0.5854572", "0.5833458", "0.5619768", "0.5619768", "0.55928504", "0.54975057", "0.54975057", "0.54111356", "0.5389292", "0.53844744", "0.5369884", "0.5369884", "0.5369884", "0.5369884", "0.53650236", "0.5334279", "0.53278804", "0.532399", "0.53110635", "0.5277394", "0.527595...
0.0
-1
Add more helper methods to be used by all tests here...
def setup Sidekiq::Worker.clear_all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_legacy_helpers\n assert_equal @patron.primary_phone, @patron.primary_address_phone\n assert_equal @patron.secondary_phone, @patron.secondary_address_phone\n assert_nil @patron.primary_address_mobile_phone\n assert_nil @patron.secondary_address_mobile_phone\n end", "def helpers; end", "def...
[ "0.7330966", "0.701972", "0.701972", "0.701972", "0.6772961", "0.6679903", "0.6679903", "0.6583205", "0.65507036", "0.6377433", "0.63762784", "0.632961", "0.6280821", "0.6280821", "0.6249786", "0.6142927", "0.6137607", "0.6121912", "0.6108209", "0.60972595", "0.60949636", "...
0.0
-1
GET /addresses/1 GET /addresses/1.xml
def show render :partial => 'show', :object => @address end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_addresses(**params)\n get('addresses', params)\n end", "def addresses\n message = { nodes: { item: resource[:name]}}\n transport[wsdl].get(:get_address, message)\n end", "def addresses\n IbmCloudRest.get \"#{@uri}/addresses\"\n end", "def show\n @address = Address.find(...
[ "0.70659995", "0.6980729", "0.67692554", "0.6680082", "0.6662398", "0.6593149", "0.6581707", "0.65305597", "0.6475209", "0.6430766", "0.6424034", "0.64002424", "0.6387896", "0.62941444", "0.6278892", "0.6224116", "0.61983526", "0.6169594", "0.61588556", "0.61588556", "0.61496...
0.0
-1
GET /addresses/new GET /addresses/new.xml
def new @address = Address.new render :partial => 'new', :object => @address end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @address = Address.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @address }\n end\n end", "def new\n @person = Person.new\n @person.build_address\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml...
[ "0.75105965", "0.7177552", "0.7095347", "0.70659614", "0.70255035", "0.70088935", "0.6991741", "0.6991741", "0.6991741", "0.6982", "0.6962507", "0.6958841", "0.69266534", "0.69193476", "0.6803977", "0.67660844", "0.6743507", "0.6610345", "0.65838194", "0.6573972", "0.65257394...
0.0
-1
POST /addresses POST /addresses.xml
def create @address = Address.new(params[:address]) if @address.save flash[:notice] = 'Address was successfully created.' render :partial => 'element_container', :object => @address else render :partial => 'new', :object => @address, :status => 409 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def postEntityInvoice_address( entity_id, building_number, address1, address2, address3, district, town, county, province, postcode, address_type)\n params = Hash.new\n params['entity_id'] = entity_id\n params['building_number'] = building_number\n params['address1'] = address1\n params['address2'] ...
[ "0.631463", "0.6245289", "0.60543716", "0.6018989", "0.60139626", "0.5956214", "0.5948452", "0.5946253", "0.59098965", "0.58948094", "0.58936965", "0.5867695", "0.5867695", "0.5845449", "0.5821028", "0.581031", "0.5809577", "0.5792074", "0.57846224", "0.57422054", "0.57216", ...
0.0
-1
PUT /addresses/1 PUT /addresses/1.xml
def update if @address.update_attributes(params[:address]) and (@address.status == 'live' or @address.user_input) flash[:notice] = 'Address was successfully updated.' render :partial => 'show', :object => @address else render :partial => 'edit', :object => @address, :status => 409 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def upd...
[ "0.66847277", "0.65563285", "0.6184888", "0.61655885", "0.6144139", "0.6102229", "0.59433633", "0.59377646", "0.59377646", "0.59377646", "0.59377646", "0.5936607", "0.5897686", "0.5852343", "0.5824345", "0.58183295", "0.5799043", "0.5787573", "0.5755386", "0.5739251", "0.5735...
0.0
-1
DELETE /addresses/1 DELETE /addresses/1.xml
def destroy @address.destroy render :nothing => true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @address = Address.find(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { redirect_to(:action=>'index') }\n format.xml { head :ok }\n end\n end", "def destroy\n # @address = Address.find(params[:id])\n @address = Address.find_by_permalink!(para...
[ "0.69786114", "0.6934582", "0.68614566", "0.68110317", "0.6797546", "0.67844826", "0.66834015", "0.6653049", "0.6608906", "0.6578678", "0.6578678", "0.6578678", "0.6578678", "0.6558031", "0.65317494", "0.6476804", "0.6476491", "0.64417404", "0.640167", "0.63981533", "0.639429...
0.624746
36
Use callbacks to share common setup or constraints between actions.
def set_item @item = Item.find(params[:item_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.6164095", "0.6046031", "0.5945298", "0.59179014", "0.58890367", "0.58341795", "0.5776118", "0.5700777", "0.5700777", "0.5656277", "0.56218207", "0.5423995", "0.5411516", "0.5411516", "0.5411516", "0.5395004", "0.53783494", "0.53593004", "0.53412604", "0.534078", "0.5332865...
0.0
-1
Check if the owner of the item.
def check_buyable raise PermissionDeniedError, "出品したアイテムはサポートできません" if @item.owner?(current_user) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_owner?(item)\n current_user_id == item.user_id\n end", "def item_owner?\n unless user_signed_in? && !current_user.items.find_by(id: params[:id]).nil?\n flash.alert = \"You are not authorized to access that!\"\n redirect_to root_path\n end\n end", "def owner?(user)\n ...
[ "0.86574405", "0.80341214", "0.7641747", "0.7616202", "0.7561327", "0.7494988", "0.74660265", "0.74452186", "0.74128777", "0.74086225", "0.7380202", "0.7356623", "0.7353671", "0.7346775", "0.73422843", "0.73139346", "0.7305085", "0.7287406", "0.7273473", "0.72720855", "0.7248...
0.0
-1
Create mocks for Stratiform::Stack
def add_stack_mocks(obj) allow(obj).to receive(:read_template).and_return(MOCK_TEMPALTE) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(stack)\n @stack = stack\n super stack.api\n end", "def initialize\n @stack = []\n end", "def initialize\n @stack = []\n end", "def create_stack(stack_name, options = {})\n params = {\n 'StackName' => stack_name,\n }\n\n ...
[ "0.5836761", "0.5825939", "0.5825939", "0.57308805", "0.5691807", "0.56296855", "0.5556125", "0.5537543", "0.5536057", "0.5533132", "0.5498599", "0.54967946", "0.5495594", "0.549271", "0.5484807", "0.5475166", "0.54750097", "0.54750097", "0.5440714", "0.5402894", "0.53823984"...
0.71573895
0
Credentials mock for Stratiform::Target
def get_mocked_creds(obj) obj.target_credentials end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def credentials; end", "def credentials; end", "def credentials; end", "def credentials; end", "def credentials; end", "def credentials=(_arg0); end", "def credentials=(_arg0); end", "def credentials=(_arg0); end", "def credentials=(_arg0); end", "def credentials=(_arg0); end", "def mock_defect...
[ "0.62596613", "0.62596613", "0.62596613", "0.62596613", "0.62596613", "0.6157348", "0.6157348", "0.6157348", "0.6157348", "0.6157348", "0.60763097", "0.584286", "0.584286", "0.5740586", "0.57397795", "0.57397795", "0.5651312", "0.56274176", "0.5566876", "0.55356437", "0.55125...
0.7272078
0
GET /rentables GET /rentables.json
def index @rentables = params[:q] ? Rentable.where(['LOWER(name) LIKE ?', "%#{params[:q].downcase}%"]) : Rentable.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @rentable_items = RentableItem.all\n render json: @rentable_items\n end", "def index\n @rents = Rent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rents }\n end\n end", "def show\n render json: @rentable_item\n end", "de...
[ "0.7399179", "0.69396544", "0.692875", "0.674618", "0.6661663", "0.6579528", "0.6551279", "0.64669335", "0.64251274", "0.63881063", "0.6322577", "0.630479", "0.62961066", "0.6281314", "0.6281314", "0.6281314", "0.6277209", "0.625763", "0.6232797", "0.6210624", "0.6195956", ...
0.0
-1
GET /rentables/1 GET /rentables/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @rentable_items = RentableItem.all\n render json: @rentable_items\n end", "def show\n render json: @rentable_item\n end", "def index\n @rents = Rent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rents }\n end\n end", "de...
[ "0.7197679", "0.70144725", "0.6795755", "0.6617176", "0.6565496", "0.64870125", "0.634783", "0.63366985", "0.6275659", "0.6265954", "0.626387", "0.62233245", "0.61892474", "0.61892474", "0.61892474", "0.618295", "0.61814964", "0.6177243", "0.6161448", "0.61508054", "0.611972"...
0.0
-1
POST /rentables POST /rentables.json
def create @rentable = Rentable.new(rentable_params) respond_to do |format| if @rentable.save format.html { redirect_to @rentable, notice: 'Rentable was successfully created.' } format.json { render :show, status: :created, location: @rentable } else format.html { render :new } format.json { render json: @rentable.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_rental(options = {})\n post(:rentals, rentals: [options]).pop\n end", "def create\n rental = sporting_goods.rentals.new(rental_params)\n rental.user_id = current_user.id\n if rental.save\n render json: rental, status: 200\n else\n render json: rental, stat...
[ "0.64633626", "0.64216036", "0.6310469", "0.60686624", "0.60018194", "0.5951624", "0.58466923", "0.58385015", "0.57734996", "0.57711154", "0.5747123", "0.5658235", "0.5656907", "0.5647115", "0.56451344", "0.5634093", "0.55901647", "0.5584728", "0.5579384", "0.55745053", "0.55...
0.6715356
0
PATCH/PUT /rentables/1 PATCH/PUT /rentables/1.json
def update respond_to do |format| if @rentable.update(rentable_params) format.html { redirect_to @rentable, notice: 'Rentable was successfully updated.' } format.json { render :show, status: :ok, location: @rentable } else format.html { render :edit } format.json { render json: @rentable.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @rent = Rent.find(params[:id])\n\n respond_to do |format|\n if @rent.update_attributes(params[:rent])\n format.html { redirect_to @rent, notice: 'Rent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n...
[ "0.6288963", "0.6255919", "0.6255424", "0.6242062", "0.61973363", "0.61742324", "0.613978", "0.6131787", "0.6114515", "0.6093201", "0.60870504", "0.60806334", "0.6072711", "0.6046612", "0.6045368", "0.6035538", "0.60033894", "0.59804565", "0.5973474", "0.595235", "0.59512264"...
0.6638201
0
DELETE /rentables/1 DELETE /rentables/1.json
def destroy @rentable.destroy respond_to do |format| format.html { redirect_to rentables_url, notice: 'Rentable was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @rent = Rent.find(params[:id])\n @rent.destroy\n\n respond_to do |format|\n format.html { redirect_to rents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rent.destroy\n respond_to do |format|\n format.html { redirect_to rents_url }\n f...
[ "0.70265996", "0.70178044", "0.69753623", "0.6973389", "0.69565433", "0.68275833", "0.67586917", "0.67586917", "0.6750311", "0.6656551", "0.66538805", "0.6643503", "0.66408825", "0.6637895", "0.6632602", "0.6628441", "0.6616478", "0.66154647", "0.6611617", "0.6587973", "0.658...
0.73329103
0
Use callbacks to share common setup or constraints between actions.
def set_rentable @rentable = Rentable.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 rentable_params params.require(:rentable).permit(:name, :image, :description, :location, :quantity, :category, :hourly_rate) 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
The first email sent when a conversation is started. Looks very similar to subsequent reply emails, but puts an explanation of what this feature is front + center. Meat is: the last N elements (messages, frames) in this dicussion roll see private discussion_roll_mail_setup for explanation of opts
def on_discussion_roll_creation(opts) discussion_roll_mail_setup(opts) # for initial roll creation, always calling out video aspect verb, suffix = "sent", "video" @subject = subject_for(@poster_string_name, opts[:all_participants] - [opts[:posting_participant], opts[:receiving_participant]], verb, suffix) mail :from => "\"Shelby Mail\" <#{Settings::Email.discussion_roll['from_email']}>", :reply_to => "\"No Reply\" <#{Settings::Email.discussion_roll['from_email']}>", :to => opts[:receiving_participant_email_address], :subject => @subject end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def discussion_roll_mail_setup(opts)\n @roll = opts[:discussion_roll]\n @recipient_string_id = opts[:receiving_participant].is_a?(User) ? opts[:receiving_participant].id.to_s : opts[:receiving_participant]\n @poster_string_name = nickname_for_user_or_email(opts[:posting_participant])\n @token =...
[ "0.6823457", "0.6189862", "0.6045139", "0.5975519", "0.58648443", "0.5800153", "0.5519095", "0.5515834", "0.5437649", "0.5424975", "0.5369577", "0.5362117", "0.52879155", "0.52715766", "0.52672106", "0.5264828", "0.52642584", "0.5229633", "0.52242166", "0.52024496", "0.519629...
0.61954284
1