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
Exercise Debugging and Testing Example 4 Name: Arnold Redoblado Date: 20160330 Purpose: Create a class(es) that'll pass a test script This example requires methods that will take string values and manipulate and return string.
def echo( word ) word end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_fake_string_1\n pros = Prospector.new(0,0,0)\n assert pros.fake_string(1).eql? '1 fake ruby'\n end", "def test_method\n \"Here is the sample input\"\n end", "def test_end_string_ten\n pros = Prospector.new(0,0,0)\n pros.instance_variable_set(:@real, 10)\n assert pros.end_string.eql...
[ "0.66028106", "0.6293523", "0.6116811", "0.6054893", "0.60472727", "0.60425794", "0.6021271", "0.5947183", "0.59276813", "0.5903257", "0.5866471", "0.5864241", "0.5863483", "0.5855647", "0.58468235", "0.5841774", "0.5841774", "0.580936", "0.5803152", "0.57916427", "0.57772744...
0.0
-1
4. As a user, I need an API to subscribe to updates from an email address. GET
def create requestor = User.where(email: @requestor) target = User.where(email: @target) if requestor.exists? && !target.exists? render json: { success: false, message: "Target Email not found" } elsif !requestor.exists? && target.exists? render json: { success: false, message: "Requestor Email not found" } elsif !requestor.exists? && !target.exists? render json: { success: false, message: "Both Email not found" } else if @requestor != @target || @target != @requestor user = User.find_by_email @requestor aim = User.find_by_email @target user.subscribes.create target_id: aim.id render json: { success: true } else render json: { success: false, message: "You can't subscribe yourself" } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api_get\n handler.get({email: email}, path)\n end", "def subscriber(id_or_email)\n make_json_api_request :get, \"v2/#{account_id}/subscribers/#{CGI.escape id_or_email}\"\n end", "def subscribe(email, user_info = {}, email_type = \"html\", update_existing = true, double_opt = false)\n ...
[ "0.6914114", "0.6734552", "0.6635045", "0.6598303", "0.65398705", "0.6534972", "0.6442823", "0.6388719", "0.6379484", "0.6302087", "0.6218143", "0.62045735", "0.6199686", "0.6199686", "0.6178889", "0.61730903", "0.6170663", "0.6140942", "0.6129353", "0.6126644", "0.6122598", ...
0.0
-1
5. As a user, I need an API to block updates from an email address. PUT
def block requestor = User.find_by_email @requestor target = User.find_by_email @target if requestor && target list = Subscribe.where(user: requestor, target: target).first if list.nil? list = requestor.subscribes.create target_id: target.id end list.update_attribute(:block, true) render json: { success: true } else render json: { success: false, message: "email not found" } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_users_password_by_e_mail(args = {}) \n put(\"/users.json/backoffice/email/#{args[:email]}/password/#{args[:password]}\", args)\nend", "def update_users_password_by_e_mail(args = {}) \n put(\"/users.json/backoffice/email/#{args[:email]}/password/#{args[:password]}\", args)\nend", "def block!\n sel...
[ "0.6622866", "0.6622866", "0.65533775", "0.64161617", "0.63643134", "0.6277218", "0.62446797", "0.6206689", "0.6178919", "0.61589766", "0.61373353", "0.6131785", "0.612585", "0.61239576", "0.60875547", "0.6078666", "0.6078666", "0.6078666", "0.6078666", "0.6078666", "0.607866...
0.617453
9
6. As a user, I need an API to retrieve all email addresses that can receive updates from an email address. POST
def receive_update @text = params[:text] user = User.find_by_email params[:sender] if user friendship = Friendship.where user_id: user # get the recipient recipients = [] friendship.each do |f| recipients << f.friend.email end mention = @text.scan(/\w+@\w+.\w+/i) recipients << mention.join(', ') # get the block user excludes = [] subscribes = Subscribe.where user: user, block: true subscribes.each do |f| excludes << f.target.email end recipients = recipients.reject { |i| excludes.include?(i) } render json: { success: true, recipients: recipients } else render json: { success: false, message: "Sender email not found" } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def emails\n respond_with_entity(api.get('/api/v1/profile/emails'),\n NexaasID::Entities::Profile::Emails)\n end", "def emails(params={})\n @api.get(\"#{@api.path}/User/Emails\", params: params)\n end", "def emails(params = {})\n @api.get(\"#{@api.path}/List/#{@id}...
[ "0.6973286", "0.66707826", "0.64309734", "0.64139336", "0.6410701", "0.63569266", "0.6247899", "0.62467486", "0.6236308", "0.6225408", "0.61925274", "0.6137301", "0.6130819", "0.6130819", "0.6082476", "0.6063424", "0.6050747", "0.60409164", "0.6040702", "0.60211736", "0.60204...
0.5792296
55
Convert block_size and quantity to a humanreadable disk size.
def blocks_to_bytes(block_size, qty) size = ( block_size / 1024 ) * qty if size < 1000 output = "#{size} KB" elsif size < 1000000 output = "#{size / 1000} MB" elsif size < 1000000000 output = "#{size / 1000000} GB" else output = "#{size / 1000000000} TB" end return output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_size(block_size,blocks)\n size = block_size * blocks\n if size > SIZE_GB\n return [(size / SIZE_GB).to_i,\"GB\"]\n else\n return [(size / SIZE_MB).to_i,\"MB\"]\n end\n end", "def size\n ['o', 'k', 'G'].inject(super.to_f) do |s, unit|\n # recusively div...
[ "0.7407986", "0.6973419", "0.6972413", "0.67802286", "0.6763028", "0.6645691", "0.66076714", "0.6480695", "0.6436258", "0.6415762", "0.6373911", "0.62670386", "0.626032", "0.62537664", "0.62537664", "0.6238297", "0.6229371", "0.6218393", "0.62069184", "0.61644036", "0.6151029...
0.75626993
0
GET /hospital_categories GET /hospital_categories.json
def index @hospital_categories = HospitalCategory.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end", "def categories\n\t\tbegin\n\t\t\t@categories = Category.select(:id, :name)\n\t\t\trender json: @categories\n\t\trescue Exception => e\n\t\t\terror_handling_ba...
[ "0.7240655", "0.6939212", "0.69276583", "0.691725", "0.6863692", "0.6838845", "0.68023413", "0.66969234", "0.66304153", "0.6615906", "0.65032655", "0.6496176", "0.64305794", "0.64298975", "0.64056236", "0.63889074", "0.6367932", "0.6365213", "0.6356687", "0.63370764", "0.6328...
0.76618177
0
GET /hospital_categories/1 GET /hospital_categories/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @hospital_categories = HospitalCategory.all\n end", "def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end", "def index\n @incidentcategories = Incidentcategory.all\n json_response(@incidentc...
[ "0.75607556", "0.7058082", "0.69855326", "0.67622304", "0.6743545", "0.6741325", "0.6682665", "0.6641161", "0.65406924", "0.64844906", "0.64734966", "0.6455101", "0.64222234", "0.6403474", "0.6391466", "0.63758814", "0.6347086", "0.63459873", "0.6312276", "0.6303336", "0.6297...
0.0
-1
POST /hospital_categories POST /hospital_categories.json
def create @hospital_category = HospitalCategory.new(hospital_category_params) respond_to do |format| if @hospital_category.save format.html { redirect_to @hospital_category, notice: 'hospital_category was successfully created.' } format.json { render :show, status: :created, location: @hospital_category } else format.html { render :new } format.json { render json: @hospital_category.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATEGORIES, payload )\n\t\t\t\tend", "def CreateCategory params = {}\n \n APICall(path: 'categories.json',method: 'POST',payload: params.to_json)\n \n end", "def index\n @hospital_catego...
[ "0.69033563", "0.66519314", "0.6645564", "0.6614792", "0.6398817", "0.6384493", "0.6352882", "0.62959385", "0.6293843", "0.62786907", "0.6250535", "0.6215882", "0.6206162", "0.6178973", "0.6176571", "0.61559266", "0.610285", "0.61028105", "0.60753", "0.605269", "0.6052371", ...
0.72510314
0
PATCH/PUT /hospital_categories/1 PATCH/PUT /hospital_categories/1.json
def update respond_to do |format| if @hospital_category.update(hospital_category_params) format.html { redirect_to @hospital_category, notice: 'hospital_category was successfully updated.' } format.json { render :show, status: :ok, location: @hospital_category } else format.html { render :edit } format.json { render json: @hospital_category.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def UpdateCategory params = {}\n \n APICall(path: 'categories.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n json_update(category,category_params, Category)\n end", "def update\n respond_to do |format|\n if @incidentcategory.update(incidentcategory_p...
[ "0.68525875", "0.6836133", "0.6610611", "0.6419427", "0.64112025", "0.6373052", "0.6360285", "0.63505125", "0.6324173", "0.631055", "0.6308039", "0.6306478", "0.6298497", "0.6272521", "0.62650055", "0.6255187", "0.62522435", "0.6235679", "0.6223568", "0.62202203", "0.62198406...
0.7140228
0
DELETE /hospital_categories/1 DELETE /hospital_categories/1.json
def destroy @hospital_category.destroy respond_to do |format| format.html { redirect_to hospital_categories_url, notice: 'hospital_category was successfully deleted.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n #@incidentcategory.destroy\n render json: {}, status: 200\n end", "def destroy\n @hospitalization = Hospitalization.find(params[:id])\n @hospitalization.destroy\n\n respond_to do |format|\n format.html { redirect_to client_hospitalizations_url(@client) }\n format.json { he...
[ "0.7554948", "0.73819655", "0.7276389", "0.7198593", "0.71792185", "0.7163575", "0.71228874", "0.70979595", "0.7089987", "0.7089411", "0.70889765", "0.7080473", "0.7075293", "0.7067855", "0.7043566", "0.70379895", "0.7032809", "0.7025122", "0.7014303", "0.70063204", "0.700446...
0.78571284
0
Use callbacks to share common setup or constraints between actions.
def set_hospital_category @hospital_category = HospitalCategory.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 hospital_category_params params.require(:hospital_category).permit(:name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
GET /server_infos/1 GET /server_infos/1.json
def show @server_info = ServerInfo.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @server_info } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def info\n result = []\n Server.all.each do |server|\n result << server.short_result\n end\n\n status_key = makeStatusKey(result)\n render :json => {servers:result}.merge(status_key)\n\n end", "def details\n data = servers_client.get(server_path, json_headers).body\n JSON.parse(dat...
[ "0.7632482", "0.74078155", "0.7344179", "0.72670954", "0.719779", "0.71064585", "0.7093832", "0.7093832", "0.707999", "0.706134", "0.699807", "0.6989398", "0.6863124", "0.6851943", "0.68321496", "0.6794796", "0.6750907", "0.6720037", "0.6710388", "0.67014265", "0.66739947", ...
0.7817296
0
GET /server_infos/new GET /server_infos/new.json
def new @server_info = ServerInfo.new respond_to do |format| format.html # new.html.erb format.json { render json: @server_info } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @server = Server.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server }\n end\n end", "def new\n @server = Server.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server }\n end\n...
[ "0.7815124", "0.7815124", "0.74888957", "0.74751145", "0.74647427", "0.74019176", "0.7374422", "0.736835", "0.7130959", "0.6979633", "0.6953689", "0.6943579", "0.68458986", "0.6766609", "0.6716958", "0.67087966", "0.67079306", "0.6676945", "0.6673384", "0.6650428", "0.664408"...
0.8186276
0
POST /server_infos POST /server_infos.json
def create @server_info = ServerInfo.new(params[:server_info]) respond_to do |format| if @server_info.save format.html { redirect_to @server_info, notice: 'Server info was successfully created.' } format.json { render json: @server_info, status: :created, location: @server_info } else format.html { render action: "new" } format.json { render json: @server_info.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @server_info = ServerInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server_info }\n end\n end", "def new\n @server = Server.new\n\n @server_options = Server.all.map{|u| [ u.server_name, u.id ] }\n # @server_ips = Server.all.ma...
[ "0.6858404", "0.6665254", "0.6520468", "0.6514328", "0.6437755", "0.6425043", "0.64216435", "0.6335646", "0.62769574", "0.62668175", "0.6262841", "0.6225919", "0.62258923", "0.6202646", "0.6202646", "0.6192489", "0.6184717", "0.6174436", "0.61734205", "0.6169153", "0.6150943"...
0.7411865
0
PUT /server_infos/1 PUT /server_infos/1.json
def update @server_info = ServerInfo.find(params[:id]) respond_to do |format| if @server_info.update_attributes(params[:server_info]) format.html { redirect_to @server_info, notice: 'Server info was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @server_info.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n name = Server.find(params[:id]).name\n n = Neography::Node.find('servers', 'name', name)\n n.name = server_params[:name]\n n.add_to_index('servers', 'name', server_params[:name]) #TODO: is this necessary?\n if @server.update(server_params)\n ...
[ "0.6879228", "0.6814855", "0.6721013", "0.66957366", "0.6679785", "0.66616225", "0.6648926", "0.6648926", "0.6648926", "0.661417", "0.65991783", "0.6592893", "0.659201", "0.6576404", "0.6511239", "0.64895", "0.64728624", "0.64665985", "0.6298507", "0.62783134", "0.6250062", ...
0.72281516
0
DELETE /server_infos/1 DELETE /server_infos/1.json
def destroy @server_info = ServerInfo.find(params[:id]) @server_info.destroy respond_to do |format| format.html { redirect_to server_infos_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @server = Server.find(params[:id])\n checkaccountobject(\"servers\",@server)\n @server.send_delete\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :ok }\n end\n end", "def destroy\n @server1 = Server1.find(params[:id])\n @serve...
[ "0.76029724", "0.74445516", "0.7376597", "0.7358587", "0.73473054", "0.718371", "0.71238005", "0.71072155", "0.71072155", "0.71072155", "0.71072155", "0.7058676", "0.7048098", "0.7021026", "0.6986391", "0.69784296", "0.6972603", "0.6964402", "0.6963334", "0.69252425", "0.6907...
0.7829473
0
For older RubyGems versions
def latest_version? if (rval = super) Gem.unversioned(@name) end rval end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gem_version; end", "def gem_version; end", "def gem_version; end", "def gem_version; end", "def gem_version; end", "def gem_version; end", "def gem_available_old_rubygems?(gemname)\n\tGem.available?(gemname)\nend", "def require_gems; end", "def gems; end", "def gems; end", "def gems; end", ...
[ "0.6922463", "0.6922463", "0.6922463", "0.6922463", "0.6922463", "0.6922463", "0.6746295", "0.6737507", "0.67058414", "0.67058414", "0.67058414", "0.657117", "0.65647703", "0.63236374", "0.6308885", "0.62550277", "0.62550277", "0.62550277", "0.62550277", "0.62550277", "0.6255...
0.0
-1
custom actions with paper trail events
def archive self.paper_trail_event = "archive" self.discard end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def action_hook; end", "def add_actions; end", "def actions; end", "def run_actions; end", "def matt_custom_action_begin(label); end", "def action_run\n end", "def define_action_hook; end", "def action_target()\n \n end", "def action; end", "def action; end", "def act...
[ "0.7012183", "0.67381036", "0.65464526", "0.6540214", "0.64107007", "0.63149273", "0.6290072", "0.6268006", "0.6261901", "0.6261901", "0.6261901", "0.6261901", "0.6261901", "0.6203777", "0.60878474", "0.5980572", "0.5980572", "0.5966044", "0.59461975", "0.59430385", "0.594303...
0.0
-1
include nested taxonomies in json representation by default
def as_json(options={}) options[:include] = { :organisation => {}, :locations => { methods: :geometry, include: :accessibilities }, :taxonomies => { methods: :slug }, :meta => {}, :contacts => {}, :local_offer => {}, :send_needs => {}, :suitabilities => {}, :cost_options => {}, :regular_schedules => {}, :links => {} } super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def taxonomies_json\n @taxons_json = []\n query_string = \"%#{params[:term]}%\"\n @taxons = Spree::Taxonomy.categories.taxons#.where(\"name like ? OR id like ?\", query_string, query_string)\n @taxons.collect{ |taxon|\n if (taxon.parent.present? && taxon.parent.parent.present? ...
[ "0.747746", "0.639918", "0.6253621", "0.6112731", "0.6091568", "0.60406125", "0.59557766", "0.5881486", "0.5881486", "0.5870913", "0.5815009", "0.57920945", "0.5584982", "0.555276", "0.5549339", "0.5548807", "0.5523041", "0.55171233", "0.5516193", "0.55018777", "0.54711175", ...
0.63595897
2
fields that we don't care about for versioning purposes
def ignorable_fields ["created_at", "updated_at", "approved", "discarded_at", "organisation", "notes_count"] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fields; end", "def fields; end", "def fields; end", "def reserved_tracked_fields\n @reserved_tracked_fields ||= begin\n fields = ['_id', history_trackable_options[:version_field].to_s]\n modifier_field = history_trac...
[ "0.71595913", "0.71595913", "0.71595913", "0.702934", "0.6767574", "0.6604728", "0.6593999", "0.637134", "0.637134", "0.637134", "0.637134", "0.637134", "0.6359335", "0.6359335", "0.6316635", "0.62985396", "0.62604946", "0.6179765", "0.61607164", "0.6156254", "0.61280286", ...
0.6468058
7
Use callbacks to share common setup or constraints between actions.
def set_wearable_label @wearable_label = WearableLabel.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.6163927", "0.6046165", "0.59465253", "0.59167755", "0.58904207", "0.58346355", "0.577713", "0.5703502", "0.5703502", "0.56531286", "0.56215113", "0.54224145", "0.5410795", "0.5410795", "0.5410795", "0.53924775", "0.5379919", "0.53580743", "0.53401667", "0.53397506", "0.533...
0.0
-1
Only allow a trusted parameter "white list" through.
def wearable_label_params params.require(:wearable_label).permit(:device_id, :activity_id, :time_end) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
Passwords are always required if it's a new record, or if the password or confirmation are being set somewhere. From Devise gem
def password_required? !persisted? || !password.nil? || !password_confirmation.nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def password_required?\n if new_record?\n !(password.blank? && password_confirmation.blank?)\n else\n super\n end\n end", "def password_required?\n new_record? ? super : false\n end", "def password_required?\n new_record? ? super : false\n end", "def password_required?\n new_re...
[ "0.81638765", "0.7941983", "0.7941983", "0.79235035", "0.79235035", "0.79235035", "0.791259", "0.7848863", "0.7848863", "0.7837047", "0.78369117", "0.7766266", "0.7762016", "0.7751134", "0.7751134", "0.77381426", "0.77215606", "0.77215606", "0.7691685", "0.7691685", "0.768971...
0.75781906
45
Return full name of user
def full_name "#{first_name} #{last_name}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def full_name\n name = `finger $USER 2> /dev/null | grep Login | colrm 1 46`.chomp\n name.empty? ? \"John Doe\" : name.squish\n end", "def user_full_name\n if user\n user.first_name + ' ' + user.last_name\n else\n 'Anonymous'\n end\n end", "def full_name\n name = `fi...
[ "0.87781364", "0.87675637", "0.8756223", "0.8512964", "0.84118307", "0.835626", "0.83395845", "0.8329259", "0.83262295", "0.83164406", "0.83014554", "0.823807", "0.81992286", "0.818809", "0.818809", "0.8180574", "0.8163273", "0.81335753", "0.81133306", "0.8111114", "0.8111114...
0.0
-1
nulls user session (logout)
def destroy session[:user_id] = nil session[:user_name] = nil redirect_to '/login' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logout\n session[:user] = nil\n end", "def logout\n @session[:user] = nil\n end", "def log_out\n\t\tsession[:user_id] = nil\n\tend", "def log_out\n session.delete(:user_id)\n @current_user=nil\n end", "def logout\n session[:user_id] = nil\n end", "def logout\n session[:user_...
[ "0.8736652", "0.869647", "0.8557396", "0.8505858", "0.8501893", "0.8501893", "0.85011286", "0.8498595", "0.8488993", "0.84789145", "0.84646046", "0.8464518", "0.84386086", "0.8432696", "0.84289974", "0.8413266", "0.8412079", "0.84041405", "0.84024626", "0.8394547", "0.8386615...
0.0
-1
Initialize an Predicate optimizer
def initialize(*) super @left = optimize_left @right = optimize_right end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(*)\n super\n @predicate = Function.optimize_operand(operation.predicate)\n end", "def set_predicate\n @predicate = Predicate.find(params[:id])\n end", "def initialize(predicates=[])\n @options = {}\n @options_parser = OptionParser.new(\"Usage: #{$0}...
[ "0.7293722", "0.6444506", "0.6271204", "0.62665486", "0.6055156", "0.60215986", "0.59516376", "0.5875624", "0.5828855", "0.57455766", "0.56537163", "0.5625675", "0.55915254", "0.55871904", "0.55724514", "0.5539218", "0.5494119", "0.5494119", "0.547259", "0.5426721", "0.535894...
0.50907063
34
Optimize the left operand
def optimize_left Function.optimize_operand(operation.left) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def optimize\n left\n end", "def optimize\n left\n end", "def optimize\n left\n end", "def optimize\n left\n end", "def optimize\n left\n end", "def left_optimizable?\n !left.equal?(oper...
[ "0.7122969", "0.7122969", "0.7122969", "0.708683", "0.708683", "0.6968616", "0.6857908", "0.6715448", "0.6711576", "0.66502416", "0.66389805", "0.6638019", "0.6612207", "0.65555924", "0.65555924", "0.65492743", "0.6429408", "0.61505395", "0.61505395", "0.6094615", "0.6094615"...
0.82758355
0
Optimize the right operand
def optimize_right Function.optimize_operand(operation.right) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def optimize\n right\n end", "def optimize\n right\n end", "def optimize\n right\n end", "def optimize\n right\n end", "def right_optimizable?\n !right.equal?(operation.right)\n end", "def optimize...
[ "0.7409947", "0.7409947", "0.7399987", "0.7399987", "0.72095764", "0.72021836", "0.7165248", "0.7163501", "0.7056508", "0.70205927", "0.6978733", "0.6874189", "0.6874189", "0.6778807", "0.6682689", "0.6518567", "0.6463418", "0.6437694", "0.64291227", "0.64291227", "0.64291227...
0.8460492
0
Evaluate the operands and return the constant
def optimize operation.class.call(left, right) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate(op, left_arg, right_arg)\n case\n when op == '+' then return left_arg + right_arg\n when op == '-' then return left_arg - right_arg\n when op == '*' then return left_arg * right_arg\n when op == '/' then return left_arg / right_arg\n when op == '%' then return left_arg % right_arg\n end\nend", ...
[ "0.68874955", "0.6483065", "0.64162254", "0.6378099", "0.6352187", "0.6340181", "0.6301769", "0.62800187", "0.6260919", "0.62332726", "0.6224119", "0.6205368", "0.61952364", "0.6178997", "0.6166607", "0.61437136", "0.61366314", "0.61353755", "0.6089381", "0.6067032", "0.60607...
0.0
-1
Return a Binary connective with optimized operands
def optimize operation.class.new(left, right) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile_binary(node)\n compile_error(node) if node.operator != :|\n\n combine_or(compile_node(node.left), compile_node(node.right))\n end", "def binary(node, iff, label)\n #iff = true if `binary` was called to evaluate the condition clause of an (if-statement or while-stmt)\n if node...
[ "0.6564456", "0.61022294", "0.595796", "0.5902246", "0.5886567", "0.58098364", "0.5785752", "0.5736045", "0.5723668", "0.5708264", "0.57042634", "0.567623", "0.56520283", "0.5628926", "0.56267744", "0.5620675", "0.560004", "0.5570927", "0.55556345", "0.55517775", "0.55156803"...
0.597534
2
Test if the left operand is optimizable
def left_optimizable? !left.equal?(operation.left) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def right_optimizable?\n !right.equal?(operation.right)\n end", "def optimize_left\n Function.optimize_operand(operation.left)\n end", "def optimizable?\n super || !predicate.equal?(operation.predicate)\n end", "def optimize\n left.ne(right...
[ "0.7488885", "0.7419305", "0.7044481", "0.6612691", "0.65930456", "0.65930456", "0.65930456", "0.65369546", "0.65369546", "0.6535521", "0.63592416", "0.63511366", "0.6291252", "0.61894643", "0.6186002", "0.5990191", "0.5983856", "0.5983856", "0.59837115", "0.5745654", "0.5721...
0.81559587
0
Test if the right operand is optimizable
def right_optimizable? !right.equal?(operation.right) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def optimize_right\n Function.optimize_operand(operation.right)\n end", "def left_optimizable?\n !left.equal?(operation.left)\n end", "def optimizable?\n super || !predicate.equal?(operation.predicate)\n end", "def optimize(**options)\n if operan...
[ "0.74024963", "0.71386456", "0.69105935", "0.6681015", "0.6430766", "0.64075", "0.6326411", "0.6232442", "0.6232442", "0.621197", "0.621197", "0.61888534", "0.6075977", "0.5992004", "0.5937966", "0.5922706", "0.5922706", "0.5915728", "0.5874312", "0.57795644", "0.5689674", ...
0.835047
0
Party like it's mcmxcix!
def roman_to_integer(roman) values = {i: 1, v: 5, x: 10, l: 50, c: 100, d: 500, m: 1000} total = 0 prev = 0 index = roman.length - 1 while index >= 0 c = roman[index].downcase c = c.to_sym index = index - 1 value = values[c] if !value return "Not a valid roman numeral" end if value < prev value = value * -1 else prev = value end total = total + value end total end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mascot; end", "def mob; end", "def private; end", "def ca; end", "def imei; end", "def mech; end", "def mech; end", "def probers; end", "def cobasysprog\n end", "def getc() end", "def getc() end", "def getc() end", "def c\n end", "def mozart; end", "def forkless(interspinous_int...
[ "0.6819029", "0.6200246", "0.5905913", "0.5755679", "0.57191193", "0.5702974", "0.5702974", "0.5689283", "0.563712", "0.5572675", "0.5572675", "0.5572675", "0.54901147", "0.54894984", "0.54297084", "0.54051304", "0.53822505", "0.53822505", "0.5377077", "0.53739846", "0.535689...
0.0
-1
Marks inventory units short shipped. Adjusts the order based on the value of the inventory. Sends an email to the customer about what inventory has been short shipped.
def short_ship(inventory_units, whodunnit:nil) if inventory_units.map(&:order_id).uniq != [@order.id] raise ArgumentError, "Not all inventory units belong to this order" end unit_cancels = [] Spree::OrderMutex.with_lock!(@order) do Spree::InventoryUnit.transaction do inventory_units.each do |iu| unit_cancels << short_ship_unit(iu, whodunnit: whodunnit) end update_shipped_shipments(inventory_units) Spree::OrderMailer.inventory_cancellation_email(@order, inventory_units.to_a).deliver_later if Spree::OrderCancellations.send_cancellation_mailer end @order.recalculate if short_ship_tax_notifier short_ship_tax_notifier.call(unit_cancels) end end unit_cancels end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shipped(order)\n @order = order\n\n puts \">> shipped order email sent\"\n\n mail to: @admin_email, subject: 'Pragmatic Store Order Shipped'\n end", "def shipped(order)\n @order = order\n\n mail to: order.email, subject: '8 facts you will never believe! Doctors hate it!'\n end", "def shipp...
[ "0.67890847", "0.64178044", "0.64130884", "0.63560724", "0.6340769", "0.6320822", "0.6319823", "0.6302464", "0.629955", "0.6294293", "0.62783396", "0.6277701", "0.62108487", "0.61932886", "0.6162298", "0.6084835", "0.60737103", "0.6070343", "0.6069573", "0.60585403", "0.60576...
0.7190293
0
Marks inventory unit canceled. Optionally allows specifying the reason why and who is performing the action.
def cancel_unit(inventory_unit, reason: Spree::UnitCancel::DEFAULT_REASON, whodunnit:nil) unit_cancel = nil Spree::OrderMutex.with_lock!(@order) do unit_cancel = Spree::UnitCancel.create!( inventory_unit: inventory_unit, reason: reason, created_by: whodunnit ) inventory_unit.cancel! end unit_cancel end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cancel(reason, info = {})\n @cancelled = true\n @cancelled_by = caller(1, 1)\n @cancelled_reason = reason\n @cancelled_info = info\n cancel_notification\n nil\n end", "def cancel(*args)\n commit('cancel', *args)\n end", "def cancel!\n state_guard { modify_c...
[ "0.6363999", "0.63175195", "0.62801456", "0.6270991", "0.6211374", "0.6155653", "0.61353934", "0.6101082", "0.60764897", "0.60443234", "0.6041007", "0.6015684", "0.59909993", "0.59909993", "0.5933009", "0.58915377", "0.5881165", "0.58541816", "0.5844977", "0.5832736", "0.5816...
0.72021127
0
Reimburses inventory units due to cancellation.
def reimburse_units(inventory_units) reimbursement = nil Spree::OrderMutex.with_lock!(@order) do return_items = inventory_units.map(&:current_or_new_return_item) reimbursement = Spree::Reimbursement.new(order: @order, return_items: return_items) reimbursement.return_all end reimbursement end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cancel!\n if charged && !canceled\n refund!\n recharge!\n end\n end", "def cancel!(e, quantity)\n [e, e.matchee].each do |ex|\n ex.quantity -= quantity\n quantity.times {ex.registrations.pop}\n ex.save\n end\n end", "def destroy_along_with_units\n sel...
[ "0.65056944", "0.6341625", "0.631424", "0.631424", "0.61565065", "0.6146577", "0.6071971", "0.60280967", "0.60010153", "0.599832", "0.5982014", "0.59549403", "0.5896678", "0.589055", "0.58457714", "0.58274955", "0.582329", "0.57932764", "0.57355887", "0.5729849", "0.5717289",...
0.67158717
0
if any shipments are now fully shipped then mark them as such
def update_shipped_shipments(inventory_units) shipments = Spree::Shipment. includes(:inventory_units). where(id: inventory_units.map(&:shipment_id)). to_a shipments.each do |shipment| if shipment.inventory_units.all? { |iu| iu.shipped? || iu.canceled? } shipment.update_attributes!(state: 'shipped', shipped_at: Time.current) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_ship\n inventory_units.each { |u| u.ship! if u.can_ship? && !u.state?('shipped') }\n end", "def mark_as_shipped\n self.shipped_at = Time.now\n end", "def shipped\n \n end", "def mark_as_shipped\n @context.no_going_back\n\n list = @data.display_list\n update_from_form(list)\n\n ...
[ "0.75078195", "0.7410016", "0.73235494", "0.720803", "0.7173264", "0.7141775", "0.7078664", "0.70745313", "0.6990948", "0.6978275", "0.67967904", "0.6784475", "0.67810255", "0.67810255", "0.67527163", "0.67514145", "0.67463815", "0.67315227", "0.6694792", "0.6659854", "0.6650...
0.72758406
3
GET /reservacions GET /reservacions.json
def index @reservacions = Reservacion.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n render json: reservations\n end", "def employee_vacations\n #vacaciones de este año\n vacations = Employee.find(params[:id]).get_vacation_days\n\n respond_to do |format|\n format.json { render json: vacations }\n end\n end", "def index\n @vacations = User.find(params[:user_...
[ "0.69865173", "0.69388676", "0.6865676", "0.6819054", "0.6819054", "0.679509", "0.67582035", "0.668788", "0.66670537", "0.66409326", "0.66224086", "0.660064", "0.65913063", "0.6590446", "0.6590446", "0.6590446", "0.6590446", "0.6590446", "0.6590446", "0.6590446", "0.6590446",...
0.7295768
0
GET /reservacions/1 GET /reservacions/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @reservacions = Reservacion.all\n end", "def index\n render json: reservations\n end", "def employee_vacations\n #vacaciones de este año\n vacations = Employee.find(params[:id]).get_vacation_days\n\n respond_to do |format|\n format.json { render json: vacations }\n end\n e...
[ "0.7200696", "0.7076413", "0.6963883", "0.6902407", "0.6902407", "0.6902407", "0.6902407", "0.6902407", "0.6902407", "0.68727165", "0.6861734", "0.6861734", "0.6856421", "0.6836301", "0.6646989", "0.66036916", "0.66036916", "0.66036916", "0.66036916", "0.66036916", "0.6603691...
0.0
-1
POST /reservacions POST /reservacions.json
def create @reservacion = Reservacion.new(reservacion_params) respond_to do |format| if @reservacion.save format.html { redirect_to @reservacion, notice: 'Su solicitud fue realizada satisfactoriamente.' } format.json { render :show, status: :created, location: @reservacion } else format.html { render :new } format.json { render json: @reservacion.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @reservation = Reservation.new(reservation_params)\n @reservation.user = current_user\n @reservation.flight = flight\n\n if @reservation.save\n render json: @reservation\n else\n render json: @reservation.errors, status: :unprocessable_entity\n end\n end", "def create_re...
[ "0.64979404", "0.64805186", "0.64497864", "0.6440722", "0.6385648", "0.6333808", "0.6319449", "0.6315092", "0.6313366", "0.6262636", "0.6238035", "0.6231008", "0.61954", "0.61954", "0.6189839", "0.6158287", "0.61571306", "0.61452997", "0.6145169", "0.6130581", "0.61285365", ...
0.64593047
2
PATCH/PUT /reservacions/1 PATCH/PUT /reservacions/1.json
def update respond_to do |format| if @reservacion.update(reservacion_params) format.html { redirect_to @reservacion, notice: 'La información de su reservación fue actualizada satisfactoriamente.' } format.json { render :show, status: :ok, location: @reservacion } else format.html { render :edit } format.json { render json: @reservacion.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n puts \"HACE ALGOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO\"\n if !params[:reserva][:tipo_reserva].blank?\n @tipo_reserva = TipoReserva.find(params[:reserva][:tipo_reserva])\n @reserva.tipo_reserva = @tipo_reserva\n end\n\n if !params[:reserva]...
[ "0.639913", "0.6363221", "0.6337682", "0.6325511", "0.6313938", "0.6266817", "0.6241336", "0.6227062", "0.6212029", "0.62042904", "0.6191312", "0.6191312", "0.61896724", "0.61825114", "0.6178", "0.6173726", "0.6160837", "0.6144482", "0.61315525", "0.6122983", "0.6113391", "...
0.5968782
41
DELETE /reservacions/1 DELETE /reservacions/1.json
def destroy @reservacion.destroy respond_to do |format| format.html { redirect_to reservacions_url, notice: 'Su Reservación fue eliminada satisfactoriamente.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n reservation = Reservation.find(params[:id])\n if reservation\n reservation.destroy\n render json: reservation\n else \n render json: [\"Reservation doesnt exist\"], status: 404 \n end \n end", "def destroy\n @vacancy.destroy\n respond_to do |format|\n format.h...
[ "0.72532225", "0.71367794", "0.71306396", "0.7126787", "0.7090269", "0.7072185", "0.7061395", "0.7012805", "0.7009868", "0.7009868", "0.7009868", "0.70001155", "0.6990178", "0.6989203", "0.6989203", "0.6989203", "0.6989203", "0.69835985", "0.69809735", "0.69809735", "0.698097...
0.70752263
5
Use callbacks to share common setup or constraints between actions.
def set_reservacion @reservacion = Reservacion.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 reservacion_params params.require(:reservacion).permit(:nresponsable, :nevento, :fechainicio, :fechafin, :horainicio, :horafin, :repeticion, :idrepeticiones, :aprobacion, :tipoactividad, :fechasolicitud) 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.6980629", "0.67819995", "0.67467666", "0.67419875", "0.67347664", "0.65928614", "0.6504013", "0.6498014", "0.64819515", "0.64797956", "0.64562726", "0.64400834", "0.6380117", "0.6377456", "0.63656694", "0.6320543", "0.63002014", "0.62997127", "0.629425", "0.6293866", "0.62...
0.0
-1
creates new user from sign up page
def create # check for errors if params[:username].blank? || params[:username].blank? || params[:email].blank? || params[:password].blank? || params[:verifypassword].blank? redirect_to signup_path, notice: 'Please fill in all the required fields' else if !User.exists?(username: params[:username]) if params[:password] == params[:verifypassword] if !User.exists?(email: params[:email]) @user = User.new(:username => params[:username], :email => params[:email], :password => params[:password], :member_since => Time.now) if @user.save create_cookies(params[:username], params[:password]) redirect_to root_path else redirect_to signup_path end else redirect_to signup_path, notice: 'registration is limited per 1 student email acount' end else redirect_to signup_path, notice: 'Password doesnt match, retype password' end else redirect_to signup_path, notice: 'Username is taken' end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @user = User.new(params[:user])\n if @user.save\n redirect_to root_url, :notice => \"Signed up!\"\n else\n render \"new\"\n end\n end", "def create\n @user = User.new(user_params)\n @user.save\n if @user.save\n redirect_to root_path, :notice => \"Signed up!\"\n ...
[ "0.79006076", "0.7896057", "0.78539085", "0.7823053", "0.7810865", "0.77963984", "0.77963984", "0.77775645", "0.7759127", "0.77134234", "0.7712291", "0.7712246", "0.7703805", "0.7702826", "0.77009547", "0.7681409", "0.76804477", "0.7676785", "0.7668975", "0.7664327", "0.76618...
0.0
-1
gets profile information to be displayed
def profile if User.exists?(id: params[:id]) @user = User.where(id: params[:id]) @name = @user[0].username @member_since = @user[0].member_since @email = @user[0].email @xp = @user[0].xp @answercount = @user[0].no_comment @postcount = @user[0].no_thread #add achievements if @u_id == params[:id].to_i @achievements = Achievement.find(:all) @achievements.each do |a| if @xp >= a.condition if UserAchievement.where(user_id: @u_id, achievement_id: a.id).empty? @ua = UserAchievement.new(:user_id => @u_id, :achievement_id => a.id) @ua.save end end end end # retrieves achievements to be displayed @achievement = UserAchievement.where(user_id: params[:id]) else redirect_to root_path end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_profile_information\n # body = {\n # cmd: \"get_profile_information\"\n # }\n\n end", "def profile\n end", "def profile\n end", "def profile\n end", "def profile\n end", "def profile\n end", "def profile\n end", "def profile\n \n end", "def profile\n\n end", ...
[ "0.7838227", "0.7756334", "0.7756334", "0.7756334", "0.7756334", "0.7756334", "0.7756334", "0.7639181", "0.7620818", "0.755514", "0.7547923", "0.7539129", "0.73539233", "0.72903836", "0.72903836", "0.72892445", "0.7282755", "0.7260617", "0.7218822", "0.7206924", "0.7197529", ...
0.0
-1
Version 2 Dynamic Programming
def DP_solve(a) max, head, tail = 0, 0, 0 cur_head = 0 sum = [ [0, a[0]].max ] # base case (1...a.size).each do |j| sum[j] = [0, sum[j-1] + a[j]].max # bottom-up cur_head = j if sum[j-1] == 0 and sum[j] > 0 if sum[j] > max head = cur_head tail = j max = sum[j] end end return max, head, tail end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dynamicArray(n, queries)\n solver = Solver.new(n, queries)\n solver.execute\nend", "def alg; end", "def recursive_solution\n\n end", "def solve\n perms = (1..9).to_a.permutation.map {|p| p.join}\n prods = []\n\n perms.each do |p|\n (1..2).each do |len|\n a, b, c = p[0, len].to_i, ...
[ "0.6096856", "0.5896055", "0.5887088", "0.58372724", "0.5804033", "0.57174605", "0.5714055", "0.5639955", "0.55930513", "0.5584535", "0.5579958", "0.5576427", "0.5576427", "0.5576427", "0.5576427", "0.5576427", "0.5548676", "0.5542368", "0.5540436", "0.55289817", "0.55137277"...
0.5179445
64
find the maximum sub array in an array
def max_sub_array (0...self.size).inject([self.first]) do |max_sub,i| (i...self.size).each do |j| if max_sub.int_sum < self[i..j].int_sum max_sub = self[i..j] end end max_sub end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def maximum_sub_array2(arr)\n current = []\n max_sum = cur_sum = 0\n max = (0...arr.size).inject([]) do |max, i|\n current << arr[i]\n cur_sum += arr[i]\n if cur_sum > max_sum\n max << i\n max_sum = cur_sum\n end\n max\n end\n arr[max[0]..max[-1]]\nend", "def maxSubarray(arr)\n [_m...
[ "0.82740986", "0.82339823", "0.81471395", "0.80629534", "0.7910162", "0.7902042", "0.78675115", "0.7766517", "0.7761502", "0.7736341", "0.7718618", "0.77082103", "0.77059853", "0.76874137", "0.7681162", "0.76617724", "0.7643433", "0.76412463", "0.76098824", "0.7598411", "0.75...
0.8459658
0
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.subscriber_mailer.subscribe.subject
def subscribe(subscriber) @subscriber = subscriber mail to: subscriber.email, subject: "Subscription Confirmation: Welcome, #{subscriber.name}!" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def message_subject=(value)\n @message_subject = value\n end", "def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\...
[ "0.7304906", "0.70163953", "0.68857616", "0.6840519", "0.682674", "0.65897477", "0.6577401", "0.65592337", "0.6558088", "0.6542849", "0.6540858", "0.6483301", "0.6449051", "0.6400153", "0.6400153", "0.6400153", "0.6400153", "0.6400153", "0.6400153", "0.6400153", "0.6400153", ...
0.6683858
5
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.subscriber_mailer.unsubscribe.subject
def unsubscribe(subscriber) @subscriber = subscriber mail to: subscriber.email, subject: "Unsubscribed from ML@B" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def newsletter_unsubscribe_alert(subscription, email)\n\t\t@list_name = User.human_attribute_name subscription\n\t\t@email = email\n\t\tsendgrid_category 'Newsletter Unsubscribe Alert'\n\t\tmail subject: \"User with email #{email} has unsubscribed from \\\"#{@list_name}\\\" newsletters\", to: ADMIN_EMAIL\n\tend", ...
[ "0.68017083", "0.679624", "0.67463094", "0.6642214", "0.64759916", "0.6364603", "0.6307766", "0.61941695", "0.61399263", "0.6115054", "0.60848945", "0.60542506", "0.60260874", "0.6019179", "0.601729", "0.6011866", "0.5983655", "0.5981097", "0.59723336", "0.5951749", "0.595045...
0.6717176
3
A user should be able to choose from the menu
def menu puts "Please type the menu number for the calculation you'd like to perfrom: " puts " Put 1 for Basic calculator and 2 for Advanced calculator" calculator = gets.chomp.to_i if calculator == 1 basic_calc else calculator == 2 advanced_calc end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main_menu_choose_option(user_input)\n case user_input\n when 'trains'\n manage_trains\n when 'routes'\n manage_routes\n when 'stations'\n manage_stations\n when 'cars'\n manage_cars\n else\n @ui.wrong_input_msg\n end\n end", "def manage_account_menu\n choice = ...
[ "0.7613777", "0.75420403", "0.7501483", "0.7460398", "0.7355061", "0.7299225", "0.7294461", "0.72457236", "0.7244415", "0.7227641", "0.71914387", "0.71618307", "0.7137189", "0.7116351", "0.71134084", "0.70925593", "0.70901567", "0.7060775", "0.7048038", "0.7033166", "0.701643...
0.0
-1
A user should be able to enter numbers to perform the operation on A user should be shown the result
def basic_calc print "(a)dd, (s)ubtract, (m)ultiply, (d)ivide: " function = gets.chomp.downcase return 'q' if function == 'q' print "Enter first number: " num_1 = gets.chomp.to_i answer = 0 case function when "a" puts "Enter the second number" add_num = gets.chomp.to_i answer = num_1 + add_num when "s" puts "Enter the second number" sub_num = gets.chomp.to_i answer = num_1 - sub_num when "m" puts "Enter the second number" multi_num = gets.chomp.to_i answer = num_1 * multi_num when "d" puts "Enter the second number " divide_num = gets.chomp.to_i answer = num_1 / divide_num else puts "Wrong!" end print "The answer equals: #{answer}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculator \n valid_operations = [\"add\",\"+\",\"subtract\",\"-\",\"multiply\",\"*\",\"divide\",\"/\"]\n \n # ask user for math operations \n # check if operation is valid and if not ask for a new input \n puts \"What is the math operation?\"\n operation = gets.chomp.strip.downcase \n unt...
[ "0.7353776", "0.7261326", "0.7144973", "0.7108331", "0.7084886", "0.70307255", "0.6970599", "0.69213164", "0.69042903", "0.68959683", "0.6826718", "0.6804019", "0.6791891", "0.6767537", "0.6752613", "0.6747193", "0.6741544", "0.6740266", "0.6722096", "0.66933537", "0.668875",...
0.64688903
48
GET /messages_comments/1 GET /messages_comments/1.json
def show @messages_comment = MessagesComment.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @messages_comment } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def comments\n client.get(\"/#{id}/comments\")\n end", "def new\n @messages_comment = MessagesComment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @messages_comment }\n end\n end", "def comments\n @article = Article.find(params[:id])\n ...
[ "0.7700898", "0.69862753", "0.69298095", "0.6915482", "0.6915482", "0.67945457", "0.678092", "0.6692832", "0.6643637", "0.6626985", "0.65854377", "0.65843046", "0.65795463", "0.6535529", "0.65031946", "0.64852715", "0.64826703", "0.64664644", "0.6460586", "0.6449252", "0.6434...
0.75209457
1
GET /messages_comments/new GET /messages_comments/new.json
def new @messages_comment = MessagesComment.new respond_to do |format| format.html # new.html.erb format.json { render json: @messages_comment } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @comment = @commentable.comments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end", "def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @...
[ "0.78621703", "0.7730281", "0.77216625", "0.77216625", "0.77216625", "0.77216625", "0.77216625", "0.77216625", "0.77216625", "0.77216625", "0.77216625", "0.77216625", "0.77216625", "0.77216625", "0.7663547", "0.7657444", "0.7657444", "0.756381", "0.75368035", "0.7378663", "0....
0.8366363
0
POST /messages_comments POST /messages_comments.json
def create @messages_comment = MessagesComment.new(params[:messages_comment]) respond_to do |format| if @messages_comment.save format.html { redirect_to @messages_comment, notice: 'Messages comment was successfully created.' } format.json { render json: @messages_comment, status: :created, location: @messages_comment } else format.html { render action: "new" } format.json { render json: @messages_comment.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n\t\t@comment = Comment.new\n\t\t@comment.comment = params[:message] \n\t\t@comment.user = current_user\n\t\t\n\t\t@comment.save\n\t\trespond_with(@comment)\n end", "def create_comment\n @user = User.find(params[:user_id])\n @message = Message.find(params[:message_id])\n @comment = @message....
[ "0.69470954", "0.6902832", "0.6787189", "0.6776868", "0.67043555", "0.6638144", "0.66221327", "0.661672", "0.652321", "0.6503006", "0.6503006", "0.6503006", "0.648112", "0.64441323", "0.6440048", "0.6402352", "0.63985837", "0.63964766", "0.6380872", "0.6375054", "0.6375054", ...
0.7440708
0
PUT /messages_comments/1 PUT /messages_comments/1.json
def update @messages_comment = MessagesComment.find(params[:id]) respond_to do |format| if @messages_comment.update_attributes(params[:messages_comment]) format.html { redirect_to @messages_comment, notice: 'Messages comment was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @messages_comment.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n user = User.find_by({token: env['HTTP_TOKEN']})\n comment = user.comments.find(params[:id])\n comment.update(comment_params)\n render json: comment\n end", "def update\n @comment = Comment.find(params[:comment_id])\n @comment.update(comment_params)\n render json: @comme...
[ "0.70348257", "0.6787702", "0.6676065", "0.6634039", "0.66048676", "0.6600948", "0.65784985", "0.65628254", "0.65628254", "0.6556255", "0.6528029", "0.6518304", "0.6501202", "0.6499012", "0.64843047", "0.64348024", "0.6432864", "0.64287406", "0.6400872", "0.63966185", "0.6362...
0.7263574
0
DELETE /messages_comments/1 DELETE /messages_comments/1.json
def destroy @messages_comment = MessagesComment.find(params[:id]) @messages_comment.destroy respond_to do |format| format.html { redirect_to messages_comments_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_comment(id)\n record \"/msg/delete_comment/#{id}\"\n end", "def destroy\n @comment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n\n @comment.destroy\n render json: @comment, status: :ok\n\n end", "def destroy\n # delete...
[ "0.71931666", "0.71432465", "0.71238524", "0.70616955", "0.70515424", "0.7010227", "0.69748765", "0.6969526", "0.6964472", "0.69637764", "0.6957433", "0.69319874", "0.6931949", "0.6930181", "0.69289327", "0.6913211", "0.6904451", "0.6884654", "0.6884654", "0.6883664", "0.6880...
0.76316255
0
Last week = 6 points, last month = 3 points, etc.
def trend_points_for_creation_date(obj) if obj.created_at > 1.day.ago then 50 elsif obj.created_at > 1.week.ago then 25 elsif obj.created_at > 2.weeks.ago then 10 elsif obj.created_at > 3.weeks.ago then 3 else 0 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def last_week(x = 1)\n\t\tself - (604800 * x)\n\tend", "def fortnights ; self * 2.weeks ; end", "def last_week\n Date.week(Date.today - 7)\n end", "def last\n Koyomi::Week.new(self.koyomi_month.last, self.week_start).last\n end", "def weekly_points\n weekly_crime_points + weekly_suspension_p...
[ "0.68824637", "0.66347146", "0.65889657", "0.6560385", "0.65458685", "0.64930737", "0.64930737", "0.63922644", "0.63708544", "0.6308124", "0.6286398", "0.62782514", "0.62782514", "0.627393", "0.62198424", "0.62009054", "0.6187007", "0.61620647", "0.61537266", "0.61521596", "0...
0.6347862
9
Name: create Objective: this method create a new session on system. Parameters: email object. Return: render a new page of logged user.
def create user = User.find_by(email: params[:session][:email].downcase) if(user && user.authenticate(params[:session][:password])) log_in(user) redirect_to(root_path) flash[:success] = "Logado com sucesso!" else flash.now[:danger] = 'Combinação inválida de e-mail/senha' render('new') end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\r\n\t\t# find the user based on the email\r\n\t\tuser = User.find_by(email: params[:session][:email].downcase) # all our emails in our database is downcased\r\n\t\t# check if the email is valid\r\n\t\tif user && user.authenticate(params[:session][:password])\r\n\t\t\t# simulate logging in\r\n\t\t\tsessi...
[ "0.71827555", "0.7137751", "0.7003368", "0.6905353", "0.6875992", "0.6838573", "0.67557836", "0.6720435", "0.66980386", "0.66937447", "0.66278744", "0.6590726", "0.65827316", "0.6578271", "0.65762967", "0.6574897", "0.6570402", "0.65665936", "0.65475833", "0.6541455", "0.6540...
0.64003307
42
Name: destroy Objective: this method destroy a session instance. Parameters: user identifier. Return: redirect to login page.
def destroy if(current_user) log_out else #nothing to do end return redirect_to login_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n user_session = UserSession.find\n logout_url = user_session.logout_url(params) unless user_session.nil?\n user_session.destroy unless user_session.nil?\n redirect_to user_session_redirect_url(logout_url) unless performed?\n end", "def destroy\n\t\tsession.delete(:us...
[ "0.82049865", "0.8028638", "0.79665333", "0.7947247", "0.7929838", "0.78877896", "0.7836255", "0.7834341", "0.78295714", "0.78295714", "0.78295714", "0.78101003", "0.7810086", "0.7777524", "0.7752483", "0.77423453", "0.7731553", "0.7723651", "0.7722579", "0.7720228", "0.77178...
0.0
-1
aContent can be a String or File eg. 'something' or open('file.txt')
def put_content(aFilename, aContent, aBucketName) AWS::S3::S3Object.store(aFilename, aContent, aBucketName) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_or_content(str)\n return str if str.nil?\n return str unless file_param? str\n\n content = File.read(str[1..-1])\n content\n end", "def content= content\n @file = content\n @content = content.dup\n @content &&= @content.read if @content.respond_to? :rea...
[ "0.6534427", "0.5836122", "0.57659453", "0.5691215", "0.5561858", "0.550435", "0.550435", "0.54323554", "0.5423568", "0.5394593", "0.53341824", "0.53096086", "0.52251583", "0.5157046", "0.50730383", "0.5052393", "0.5008223", "0.500723", "0.500304", "0.499282", "0.49864995", ...
0.47503465
65
should replace string_to_file with file object
def download(aFilename,aBucketName,aObjectName=nil) aObjectName ||= File.basename(aFilename) #AWS::S3::S3Object.store(aObjectName, MiscUtils.string_from_file(aFilename), aBucketName) MiscUtils.string_to_file(get_content(aObjectName,aBucketName),aFilename) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def string2file(string,filename='string2file.txt',filepath='.')\n File.open(\"#{filepath}/#{filename}\",\"w\") do |f|\n f << string\n end\nend", "def s_to_file file_path_str, new_content_str='' \n File.open(file_path_str, \"w+\") { |f| f.write(new_content_str) }\n end", "def convertStringToFile(text, ...
[ "0.751318", "0.7244803", "0.7091236", "0.70541245", "0.69614416", "0.6875502", "0.6748058", "0.60938233", "0.6085724", "0.6036612", "0.6030456", "0.60107046", "0.59898883", "0.5981235", "0.5981235", "0.5934211", "0.59325916", "0.5922589", "0.5892549", "0.58885515", "0.5884918...
0.0
-1
Summary: Uploads the given file to the bucket, then gives up permissions to the bucket owner Details : intended to allow files to be uploaded to S3, but not allowing the files to be interfered with should the web server get hacked. In truth, S3 permissions aren't adequate and the best we can do is that the file can't be read, but can be written over. The user also can't get a listing of the bucket S3 won't allow objects (or buckets) to change owner, but we do everything else ie give FULL_CONTROL, and remove it from self, to hand control to the bucket owner This requires the bucket to give WRITE & READ_ACP permissions to this user
def upload_backup(aFileName,aBucketName,aObjectName = nil) aObjectName ||= File.basename(aFileName) AWS::S3::S3Object.store(aObjectName, open(aFileName), aBucketName) bucket_owner = AWS::S3::Bucket.acl(aBucketName).owner policy = AWS::S3::S3Object.acl(aObjectName,aBucketName) policy.grants.clear policy = policy_add(policy,{'id' => bucket_owner.id, 'display_name' => bucket_owner.display_name},'FULL_CONTROL') # replace policy with full control to bucket owner, none to test_user AWS::S3::S3Object.acl(aObjectName,aBucketName,policy) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upload(bucket, file); end", "def bucket_acl_set_for_owner_id?(\r\n s3_client,\r\n bucket_name,\r\n permission,\r\n owner_id\r\n)\r\n s3_client.put_bucket_acl(\r\n access_control_policy: {\r\n grants: [\r\n {\r\n grantee: {\r\n id: owner_id,\r\n type: 'Canoni...
[ "0.74061835", "0.7285796", "0.7169991", "0.7007247", "0.69954664", "0.69686705", "0.6748115", "0.67469937", "0.6663613", "0.6625622", "0.662101", "0.66089386", "0.65975314", "0.6584539", "0.65426373", "0.65320307", "0.6520847", "0.6515147", "0.6501233", "0.6493073", "0.648835...
0.77392226
0
Adds additional semantics to +reject+ by accepting an optional argument.
def reject_with_list_arg(list=nil, &block) if !block_given? && list && list.any? hash = self.dup list.each do |f| case f when Regexp hash.delete_if {|k, v| k.to_s =~ f} when Symbol hash.delete_if {|k, v| k.to_s == f.to_s} when String hash.delete_if {|k, v| k.to_s == f} end end return hash end return reject_without_list_arg(&block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reject(reason: nil, **keyword_args)\n append(Reject.new(reason: reason, **keyword_args))\n end", "def my_reject(&prc)\n end", "def reject(&block)\n @reject = block if block\n @reject\n end", "def reject(&blk); end", "def reject(&block); end", "def reject!(&block); end", "d...
[ "0.7113229", "0.7048072", "0.65520954", "0.64220786", "0.6386754", "0.62827384", "0.61577344", "0.6134144", "0.61030483", "0.61018914", "0.6076733", "0.60468227", "0.60454667", "0.59868747", "0.5839345", "0.5820302", "0.5819923", "0.5769507", "0.56937534", "0.56717926", "0.55...
0.0
-1
Provides a destructive version of the new +reject+ method.
def reject_with_list_arg!(list, &block) self = reject_with_list_arg(list, &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reject(&block); end", "def reject(&blk); end", "def reject!(&block); end", "def reject\n throw :reject\n end", "def reject(&block)\n @reject = block if block\n @reject\n end", "def reject\n return enum_for(:reject) if not block_given?\n select { |item| !yield(item) }\n ...
[ "0.8056053", "0.7999276", "0.77571875", "0.7721478", "0.76465046", "0.7601805", "0.75710267", "0.7369114", "0.72596496", "0.71915877", "0.7160614", "0.70874673", "0.70834696", "0.7003528", "0.68517697", "0.68517697", "0.683299", "0.67969996", "0.67536914", "0.6712829", "0.670...
0.601969
55
GET /businesses GET /businesses.json
def index @businesses = Business.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @businesses = Business.all.offset(offset).limit(limit)\n render json: @businesses\n end", "def index\n @businesses = @user.businesses.all\n end", "def index\n @user_businesses = Business.where({user_id: current_user.id})\n render json: JSONAPI::Serializer.serialize(@user_businesses...
[ "0.7400743", "0.7197552", "0.7160107", "0.71516067", "0.68540794", "0.65826195", "0.6515095", "0.6439602", "0.6375034", "0.63264203", "0.62786835", "0.624988", "0.6246235", "0.6220708", "0.6220708", "0.620454", "0.6173559", "0.61406076", "0.61128026", "0.6089432", "0.6082277"...
0.71204215
6
PATCH/PUT /businesses/1 PATCH/PUT /businesses/1.json
def update respond_to do |format| if @business.update(business_params) format.html { redirect_to businesses_path, notice: 'Business was successfully updated.' } format.json { render :index, status: :ok } else format.html { render :edit } format.json { render json: @business.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @businesstype = Businesstype.find(params[:id])\n\n respond_to do |format|\n if @businesstype.update_attributes(params[:businesstype])\n format.html { redirect_to @businesstype, notice: 'Businesstype was successfully updated.' }\n format.json { render :show, status: :ok, locati...
[ "0.66081786", "0.6493838", "0.6349723", "0.633397", "0.6246713", "0.6232901", "0.62016004", "0.6192224", "0.61865616", "0.6159051", "0.6112868", "0.60710156", "0.6051207", "0.60199416", "0.60014904", "0.5925034", "0.59224087", "0.5908766", "0.5908766", "0.5908766", "0.5908766...
0.62294775
6
Use callbacks to share common setup or constraints between actions.
def set_business @business = Business.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163754", "0.6045816", "0.5944853", "0.59169096", "0.58892167", "0.58342934", "0.5776148", "0.57057375", "0.57057375", "0.56534296", "0.56209534", "0.54244673", "0.54101455", "0.54101455", "0.54101455", "0.53951085", "0.5378493", "0.53563684", "0.53399915", "0.5338049", "0...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def business_params params.require(:business).permit(:name, :price) 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.6978086", "0.6780264", "0.6742658", "0.6738813", "0.67338693", "0.65908474", "0.6501793", "0.6495506", "0.64796513", "0.64755446", "0.6454826", "0.6437561", "0.6377127", "0.63722163", "0.6364058", "0.63178706", "0.62979764", "0.62968165", "0.62913024", "0.6289789", "0.6289...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_grade @grade = Grade.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 grade_params params.require(:grade).permit(:assignment_name, :grade, :student_id, :teacher_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Place an order without requiring a cart.
def place raise CatalogAPI::Error, 'No Items' if items.nil? || items.length.zero? raise CatalogAPI::Error, 'No Socket ID' if items.first.socket_id.nil? raise CatalogAPI::Error, 'No First Name' if first_name.nil? raise CatalogAPI::Error, 'No Last Name' if last_name.nil? raise CatalogAPI::Error, 'No Adress1' if address_1.nil? raise CatalogAPI::Error, 'No City' if city.nil? raise CatalogAPI::Error, 'No State' if state_province.nil? raise CatalogAPI::Error, 'No Postal Code' if postal_code.nil? raise CatalogAPI::Error, 'No Country' if country.nil? raise CatalogAPI::Error, 'No Items' if items.nil? request = CatalogAPI.request.new(:order_place) request.post(place_params(request)) json = request.json.dig(:order_place_response, :order_place_result) request.data = CatalogAPI::Order.new(json) request end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def place_order!()\n if has_order_items?\n order_template = order_object\n order_template = yield order_object if block_given?\n\n @virtual_server.softlayer_client[:Product_Order].placeOrder(order_template)\n end\n end", "def place_buy_order(price, amount)\n @log.info \"pla...
[ "0.73740715", "0.68440413", "0.64735687", "0.640894", "0.6368956", "0.63323236", "0.63211626", "0.6303132", "0.6273557", "0.6263134", "0.62284905", "0.61651814", "0.6055347", "0.6046078", "0.6007279", "0.5968888", "0.5967344", "0.5952569", "0.59455806", "0.59429735", "0.59397...
0.5656783
48
creates a new book
def initWithType(typeName, error:outError) super @unzipPath = Dir.mktmpdir(UNZIP_DIRECTORY_PREFIX) @container = Container.new(@unzipPath) @issues = [] self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n\t\t@book = Book.new(book_params)\n\t\t@book.save\n\t\tredirect_to books_path\n\tend", "def create\n @book = params[:book]\n add(@book)\n end", "def create\n #raise params.inspect\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n flash[:notic...
[ "0.7764643", "0.7717482", "0.7546675", "0.75023097", "0.7478946", "0.74436086", "0.74318075", "0.7416036", "0.7416036", "0.740435", "0.73903453", "0.7389598", "0.738658", "0.73805344", "0.7374629", "0.7365513", "0.7362937", "0.7328084", "0.73181134", "0.73014843", "0.7301215"...
0.0
-1
opens an existing book
def readFromURL(absoluteURL, ofType:inTypeName, error:outError) progressController = ProgressController.alloc.init progressController.showWindowWithTitle("Opening...") do |progressBar| @unzipPath = Dir.mktmpdir(UNZIP_DIRECTORY_PREFIX) progressBar.doubleValue = 10 runCommand("unzip -q -d '#{@unzipPath}' \"#{absoluteURL.path}\"") progressBar.doubleValue = 50 @container = Container.load(@unzipPath, progressBar) progressBar.doubleValue = 100 @issues = [] true end rescue StandardError => exception info = { NSLocalizedDescriptionKey => "The book \"#{absoluteURL.lastPathComponent}\" could not be opened.", NSLocalizedRecoverySuggestionErrorKey => exception.message } outError.assign(NSError.errorWithDomain(NSOSStatusErrorDomain, code:1, userInfo:info)) close false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addBook(book)\n\t\tinventories.create(book_id: book.id)\n\tend", "def book\n fetch('harry_potter.books')\n end", "def book\n response = request(:book, {\n \"currentInvoiceHandle\" => handle.to_hash\n })\n\n # Find the created Invoice\n session.invoices.find(respon...
[ "0.60611194", "0.60306656", "0.6000759", "0.5888902", "0.5861752", "0.58355224", "0.5831696", "0.58066", "0.5806328", "0.5798352", "0.5788571", "0.5778525", "0.5766758", "0.57602376", "0.57599753", "0.57362884", "0.571981", "0.5717504", "0.57125825", "0.57125825", "0.57125825...
0.0
-1
validation issues not specific to a manifest item are assigned to book
def addIssue(issue) @issues << issue if issue end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_manifest_inventory(moab_version)\n manifest_file_path = \"#{moab_version.version_pathname}/#{MANIFESTS}/#{MANIFESTS_XML}\"\n parse_verification_subentities(moab_version.verify_manifest_inventory)\n rescue Nokogiri::XML::SyntaxError\n results.add_result(AuditResults::INVALID_MANIFEST, manifes...
[ "0.5976847", "0.59281254", "0.5923643", "0.58835566", "0.5875581", "0.58732754", "0.58533806", "0.58429986", "0.5794322", "0.5762619", "0.5743804", "0.5740936", "0.5725063", "0.5613098", "0.56012326", "0.5578933", "0.5578933", "0.5557999", "0.55558175", "0.5551157", "0.554666...
0.0
-1
to send email to members to notify room booking
def send_signup_email(email) mail( :to =>email, :subject => 'Room Booked') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reservation_email(user,room_id)\n room = Room.find(room_id)\n hotel_name = room.hotel.name\n name = room[:name]\n \n mail( :to => user.email,\n :subject => \"Thank You\",\n :body => \"Thank you very much for making a reservation with us. You have been assigned the Room #{name} at the #{hot...
[ "0.7962079", "0.78763574", "0.7807634", "0.7773675", "0.7676186", "0.7545965", "0.753494", "0.7498815", "0.74715805", "0.7465573", "0.7432735", "0.73820776", "0.73649836", "0.73246986", "0.7316565", "0.7316047", "0.73010224", "0.7298088", "0.72966355", "0.72916", "0.7288923",...
0.74428
10
This should return the minimal set of values that should be in the session in order to pass any filters (e.g. authentication) defined in WorkoutTemplatesController. Be sure to keep this updated too.
def valid_session {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_session_variables_from_authenticated_system\n @return_to_query = session[:return_to_query] || params[:return_to_query]\n @return_to = session[:return_to] || params[:return_to]\n @previous_protocol = session[:previous_protocol] || params[:previous_protocol]\n session[:return_to_query] = session[...
[ "0.6224541", "0.61205846", "0.60596937", "0.5992933", "0.59271634", "0.58413523", "0.5786495", "0.5753187", "0.57268506", "0.568938", "0.5677962", "0.5643993", "0.563859", "0.563859", "0.5628149", "0.5628149", "0.5624661", "0.5619442", "0.56172645", "0.5607406", "0.5594568", ...
0.0
-1
check to see if there is already a scheduled job for the listserv id
def duplicate_scheduled_job?(listserv) scheduled_queue = Sidekiq::ScheduledSet.new scheduled_queue.any? { |job| check_for_duplicate(listserv, job) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exists?\n SideJob.redis.sismember 'jobs', id\n end", "def do_scheduling?\n\t\t!self.scheduled_at.blank?\n\tend", "def scheduled?\n status == Status[:scheduled]\n end", "def valid?\n id && cron_schedule && worker\n end", "def in_shipped_list?\n MeadSchedulerService.in_ship...
[ "0.67153364", "0.6387039", "0.63815665", "0.63321555", "0.6285404", "0.62040794", "0.6186232", "0.61440206", "0.61372703", "0.61194336", "0.6050787", "0.60322905", "0.5997739", "0.5981781", "0.59495723", "0.5930317", "0.59269184", "0.5874908", "0.5836512", "0.5805794", "0.574...
0.8337974
0
define a fonction for Email et le password.
def send_email_line() #define a variable gmail. gmail = Gmail.connect("email","password") #define a variable email with a loop. email = gmail.deliver do to ws subject "Présentation The hacking poject" html_part do content_type'text/html; charset=UTF8' body send_email_text end end #show email acount loggin. puts gmail.logged_in? #desconnecte after work. gmail.logout end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def email_login\n end", "def email\n login\n end", "def login_valido email, password\n $helper.preencher_web_edit(txt_EmailAddress(), email)\n $helper.preencher_web_edit(txt_Password(), password)\n $helper.clicar_objeto(btn_SigIn())\n end", "def password; end", "def password; e...
[ "0.75093555", "0.70577794", "0.70352787", "0.697476", "0.697476", "0.697476", "0.697476", "0.697476", "0.697476", "0.6838461", "0.6838461", "0.67972976", "0.6744937", "0.6744937", "0.6744937", "0.6744937", "0.6651562", "0.6625391", "0.6613267", "0.6613267", "0.6613267", "0....
0.0
-1
define fonction for the texte.
def send_email_text(cities) #text a return return"<h2>Bonjour</h2> <p>Je m'appelle Charles Dacquay, je suis co-fondateur de lorganisme The Hacking Project qui propose une formation de dévelopeur web gratuite, ouverte à tous, sans restriction géographique, ni restriction de niveau.<br> Voici le lien de la formation s'appelle The Hacking Project (http://thehackingproject.org/).<br> la foramtion des baser sur la méthode du peer-learning : les étudiants sont répartie en petit groupes ou nous leur proposons la réaliation de projets concrets qui leur sont assignés chaque jours, sur lesquel ils travaillent et cherches des solution . Le projet du jour est d'envoyer des emails à nos élus locaux pour qu'ils nous aident à faire de The Hacking Project un nouveau format d'éducation gratuite.</p> <p>Nous vous contactons pour vous parler du projet, et vous dire que vous pouvez ouvrir une cellule à #{cities}, où vous pouvez former gratuitement 6 personnes (ou plus), qu'elles soient débutantes, ou confirmées.<br> Le modèle d'éducation de The Hacking Project n'a pas de limite en terme de nombre de moussaillons (c'est comme cela que l'on appelle les élèves), donc nous serions ravis de travailler avec #{cities} !</p> <p>Charles, co-fondateur de The Hacking Project pourra répondre à toutes vos questions : 06.95.46.60.80</p>" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def text text\n end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text; end", "def text=(_arg0); end...
[ "0.7315133", "0.6906378", "0.6906378", "0.6906378", "0.6906378", "0.6906378", "0.6906378", "0.6906378", "0.6906378", "0.6906378", "0.6906378", "0.6906378", "0.6906378", "0.6906378", "0.6906378", "0.67930114", "0.6764332", "0.66713053", "0.65442693", "0.6533853", "0.6533853", ...
0.0
-1
define a fonction email list
def list_email() session = GoogleDrive::Session.from_config("config.json") ws = session.spreadsheet_by_key("1v7XEnpGDtgjgRom3bp7OwzaK99zlUQIfKuW3QdawXBc").worksheets[0] #define a lopp with each for the spreadsheet. (1..w_sheet.num_rows).each do |list| mail = ws[list, 2] city = ws[list, 1] list_email("email","password",mail, city) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def email_list\n end", "def email_list\n @entries.collect do |line|\n name, email = line.split(\",\")\n format_email_address name, email.chomp\n end.join(\", \")\n end", "def mail_list\n str =\"\"\n self.users.each do |person|\n str << \"#{person.login} <#{person.email}> \\...
[ "0.8491395", "0.75682986", "0.7467314", "0.72210306", "0.7167031", "0.7070096", "0.70440525", "0.69833934", "0.69553554", "0.69419616", "0.68911684", "0.6841979", "0.6816934", "0.6803366", "0.67704386", "0.67364573", "0.6730073", "0.6723742", "0.6701323", "0.6701323", "0.6701...
0.62810117
59
GET /pagemasters GET /pagemasters.json
def index @pagemasters = Pagemaster.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @masters = Master.all.paginate(page: params[:page], per_page: 200)\n end", "def index\n @pharmaceutical_masters = PharmaceuticalMaster.page(params[:page])\n # @pharmaceutical_masters = PharmaceuticalMaster.all\n end", "def index\n @sites = current_user.sites.page(params[\"page\"])\n\n...
[ "0.7053716", "0.667946", "0.66463715", "0.65678316", "0.6535094", "0.64710444", "0.6429073", "0.62397164", "0.62287617", "0.6213205", "0.6213205", "0.6213205", "0.6213205", "0.6213205", "0.6213205", "0.6213205", "0.6211827", "0.61739004", "0.615255", "0.6136375", "0.61148226"...
0.72797215
0
GET /pagemasters/1 GET /pagemasters/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @pagemasters = Pagemaster.all\n end", "def index\n @masters = Master.all.paginate(page: params[:page], per_page: 200)\n end", "def index\n @pharmaceutical_masters = PharmaceuticalMaster.page(params[:page])\n # @pharmaceutical_masters = PharmaceuticalMaster.all\n end", "def index\n ...
[ "0.70652896", "0.6898956", "0.67192096", "0.6697065", "0.6681186", "0.6590563", "0.65252167", "0.64541876", "0.6452271", "0.64078385", "0.64078385", "0.64078385", "0.64078385", "0.64078385", "0.64078385", "0.64078385", "0.6387668", "0.63579065", "0.6301785", "0.6293287", "0.6...
0.0
-1
POST /pagemasters POST /pagemasters.json
def create @pagemaster = Pagemaster.new(pagemaster_params) respond_to do |format| if @pagemaster.save format.html { redirect_to @pagemaster, notice: 'Pagemaster was successfully created.' } format.json { render :show, status: :created, location: @pagemaster } else format.html { render :new } format.json { render json: @pagemaster.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @pagemasters = Pagemaster.all\n end", "def create\n @page = Page.new(page_params)\n\n if @page.save\n render json: @page, status: :created, location: @page\n else\n render json: @page.errors, status: :unprocessable_entity\n end\n end", "def create\n @page = Page.new(p...
[ "0.6266468", "0.60528743", "0.5970794", "0.58868665", "0.5836367", "0.5770931", "0.57577395", "0.5746898", "0.569049", "0.5682702", "0.56336886", "0.56322575", "0.5621664", "0.55991244", "0.5586411", "0.5579931", "0.55636925", "0.55626917", "0.55606896", "0.55377597", "0.5529...
0.7136485
0
PATCH/PUT /pagemasters/1 PATCH/PUT /pagemasters/1.json
def update respond_to do |format| if @pagemaster.update(pagemaster_params) format.html { redirect_to @pagemaster, notice: 'Pagemaster was successfully updated.' } format.json { render :show, status: :ok, location: @pagemaster } else format.html { render :edit } format.json { render json: @pagemaster.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.json { render json: @page.errors, status: :unprocessable_entity }\n for...
[ "0.62844384", "0.6203034", "0.6201689", "0.6175606", "0.61736435", "0.615435", "0.61402535", "0.60688686", "0.6041272", "0.6027496", "0.6021571", "0.602073", "0.59844893", "0.59844893", "0.59843415", "0.59802234", "0.5979805", "0.59676296", "0.5962027", "0.5962027", "0.595718...
0.68065405
0
DELETE /pagemasters/1 DELETE /pagemasters/1.json
def destroy @pagemaster.destroy respond_to do |format| format.html { redirect_to pagemasters_url, notice: 'Pagemaster was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @pharmaceutical_master.destroy\n respond_to do |format|\n format.html { redirect_to pharmaceutical_masters_url, notice: DELETE_NOTICE }\n format.json { head :no_content }\n end\n end", "def delete_page(id)\n @client.raw('delete', \"/content/pages/#{id}\")\n end", "def dest...
[ "0.71098185", "0.70382106", "0.69768494", "0.6946361", "0.69462955", "0.6938194", "0.6883078", "0.6880598", "0.6878404", "0.6878228", "0.6860168", "0.6841834", "0.68235165", "0.6822673", "0.68214947", "0.6820508", "0.6813039", "0.6797299", "0.67955667", "0.6789765", "0.678976...
0.7490353
0
Use callbacks to share common setup or constraints between actions.
def set_pagemaster @pagemaster = Pagemaster.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 pagemaster_params #params.require(:pagemaster).permit(: params.fetch(:pagemaster, {}) 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.6980629", "0.67819995", "0.67467666", "0.67419875", "0.67347664", "0.65928614", "0.6504013", "0.6498014", "0.64819515", "0.64797956", "0.64562726", "0.64400834", "0.6380117", "0.6377456", "0.63656694", "0.6320543", "0.63002014", "0.62997127", "0.629425", "0.6293866", "0.62...
0.0
-1
Save current user information
def current_user @current_user = User.find(session[:user_id]) if session[:user_id] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_user_info\n if current_user\n cookies[:provider] = current_user.provider\n cookies[:current_institution] = current_institution.code.downcase\n end\n end", "def set_user_info\n @user_info = UserInfo.find_by_user_id(session[:user_id])\n if (@user_info == nil)\n @user_info...
[ "0.7337099", "0.72821903", "0.7010088", "0.69120586", "0.68439937", "0.67950225", "0.679166", "0.66993386", "0.6687807", "0.66836864", "0.66836864", "0.66497755", "0.66264516", "0.65870184", "0.6584568", "0.6563492", "0.6540971", "0.6536809", "0.65148044", "0.6514691", "0.650...
0.0
-1
Create a word with the given string
def initialize(word) @word = word @letters = unique_letters_in(word) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_word(word)\n \n end", "def new_word(s)\n\ts[0] = ''\n\treturn s\nend", "def add_word(word)\r\n \r\n end", "def create_word_one(word)\n index = find_last_vowel(word)\n result = word.slice(0, index)\n return result\n end", "def add_letter(word, index, let)\n word.split(...
[ "0.6986271", "0.6919456", "0.68202907", "0.67290735", "0.65936077", "0.65819746", "0.6505832", "0.6479408", "0.6464417", "0.64395213", "0.6403397", "0.62902457", "0.6249584", "0.62478864", "0.6228439", "0.6208239", "0.6188045", "0.6180487", "0.61770433", "0.6171708", "0.61692...
0.0
-1
Add one word to the dictionary
def add(word) change_wordlist(@words + [ Word.new(word) ] ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_word word #Function shovels individual strings into the dictionary array\n @dictionary << word\n end", "def add(word)\n\t\tif word.class == String\n\t\t\tword = {word => nil}\n\t\tend\n\n\t\tword.each do |key, value|\n\t\t\t@entries[key] = value\n\t\tend\n\...
[ "0.8524028", "0.8147995", "0.7814593", "0.76858705", "0.76194024", "0.75758594", "0.74321216", "0.7424859", "0.7394087", "0.7360386", "0.7339526", "0.7331375", "0.72518903", "0.71986586", "0.71597856", "0.7137131", "0.7130073", "0.7094894", "0.69974625", "0.696708", "0.693195...
0.6930533
21
Load all words from a text file (one word per line) Keep only words that are 5 ascii letters or more Words all all lower case
def load(file) words = File.readlines(file) words = words.collect {|word| Word.new(word.chomp.downcase) } change_wordlist(words.select {|word| word.word.length >= 5 && word.word =~ /^([a-z])+$/ }) self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_words\n return @valid_words if @valid_words && @valid_words.length > 0\n\n @valid_words = Set.new\n @io.each_line do |l|\n l.encode!('UTF-8', 'UTF-8', invalid: :replace, undef: :replace, replace: '')\n # Funny story, in place methods are faster.\n l.gsub!(/[^[:alnum:]^...
[ "0.7316448", "0.7250181", "0.716863", "0.7066948", "0.70191926", "0.6926973", "0.679912", "0.67781585", "0.6740626", "0.67250496", "0.668779", "0.66851044", "0.6638561", "0.6616625", "0.655909", "0.6550625", "0.6515035", "0.64642227", "0.6454608", "0.6449782", "0.64079714", ...
0.74152505
0
Return a new Dictionary with only the words of the given length
def with_only_words_of_size(len) other = Dictionary.new @dictionary_per_size[len] ||= @words.select{|word| word.word.length == len } words = @dictionary_per_size[len] other.add_words(words) other end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collect_words_of_length\n\t\t@dictionary.select! { |el| el.length == @word_length + 1 }\n\t\tmake_smart_dictionary\n\tend", "def narrow_search_by_length\n self.dictionary.select { |word| word.length == self.word_length }\n end", "def keep_only_words_of_length(len)\n change_wordlist(@words.select{|...
[ "0.84181213", "0.77309114", "0.7625024", "0.7382154", "0.73415136", "0.72445273", "0.72357553", "0.7179031", "0.71778965", "0.714575", "0.71394193", "0.70540893", "0.6883865", "0.6879563", "0.68610084", "0.6850231", "0.65873605", "0.6499255", "0.64796543", "0.638994", "0.6372...
0.85993326
0
Access each Word individually
def [](index) @words[index].word end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_words\n words = self.dictionary.map do |dictionary_entry|\n dictionary_entry.word.lexical_item\n end\n words \n end", "def in_a_word\n WORDS[self]\n end", "def idx_get_word(i)\n @tparses[i][:word]\n end", "def word\n @word\n end", "def word\n @w...
[ "0.72010344", "0.68452895", "0.68267137", "0.6762287", "0.6762287", "0.6762287", "0.6741771", "0.6721848", "0.6675079", "0.66309434", "0.66185355", "0.6602826", "0.660076", "0.6596457", "0.65897566", "0.65838426", "0.65637046", "0.65538186", "0.65489805", "0.6541548", "0.6541...
0.6928339
1
Filter out all words that don't have the given length
def keep_only_words_of_length(len) change_wordlist(@words.select{|word,letters| word.word.length == len }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_lengths(strings, length = 5)\n words = []\n strings.each do |word|\n if word.length >= length\n words << word\n end\n end\n return words\nend", "def filter_lengths(strings, length=5)\n big_words = []\n strings.each { |ele| big_words << ele if ele.length >= le...
[ "0.8268905", "0.82069004", "0.8036487", "0.77160835", "0.7701686", "0.75003904", "0.7208516", "0.71411645", "0.7057447", "0.7047899", "0.6997992", "0.69461554", "0.6808017", "0.6679938", "0.6667339", "0.66432947", "0.66265607", "0.6538837", "0.65367144", "0.6516269", "0.65061...
0.86861956
0
Filter out all words that contain the given letter
def reject_words_that_contain(letter) change_wordlist(@words.select { |word,letters| word.word.index(letter) == nil }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_words_with_letter array, letter\n array.filter_map{ |value| value if value.include? letter }\nend", "def words_with_letter (array,letter)\n array.select{|word| word.include? letter}\nend", "def letter_checker(array, letter_variable)\n# loop over array and return only words that include a given l...
[ "0.8088286", "0.74130577", "0.7368156", "0.7300006", "0.7235947", "0.7066958", "0.66895235", "0.6686267", "0.6682136", "0.6672857", "0.6629614", "0.65127003", "0.6464307", "0.64636683", "0.646075", "0.6435366", "0.64256155", "0.64143544", "0.63935244", "0.6380838", "0.6379877...
0.8102956
0
Keep only the words that match the partial solution
def keep_only_words_that_match(hangman_pattern) pattern = Regexp.new('^' + hangman_pattern.gsub(/-/,'.') + '$') change_wordlist(@words.select { |word,letters| word.word =~ pattern }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_results_of_partial_phrases(results)\n cleaned_results = []\n results.each do |current_result|\n current_result_phrase = current_result[0]\n\n cleaned_results << current_result unless results.any? do |other_result|\n other_result_phrase = other_result[0]\n is_a_partial_string...
[ "0.68372524", "0.67587155", "0.66453785", "0.6633344", "0.66284317", "0.6566852", "0.65604645", "0.65322715", "0.6530867", "0.6521575", "0.64905804", "0.6483015", "0.64492726", "0.6443264", "0.64324", "0.6421518", "0.6417509", "0.63569254", "0.6351105", "0.6314205", "0.629324...
0.68202984
1
Return the number of words in the dictionary that contain the given letter
def words_that_contain(letter) letter_count(letter) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def word_count_by_letter(letter)\n\t\tputs \"#{@dictionary_analyzer.word_count_by_letter(letter, @dictionary)} words begin with the letter #{letter}\"\n\tend", "def letter_counts(word) =\n word.chars.each_with_object(Hash.new(0)) { |c, counts| counts[c] += 1 }", "def letter_counts(word)\n counter = Hash.new(...
[ "0.8189641", "0.7937864", "0.7869434", "0.7787882", "0.77715236", "0.7695184", "0.7650494", "0.7650218", "0.7646654", "0.75720036", "0.75609696", "0.7557417", "0.75205106", "0.7516355", "0.75112134", "0.7421506", "0.7420873", "0.74122286", "0.7393609", "0.7370991", "0.7356189...
0.84663004
0
Iterate over each Word
def each(&block) @words.each(&block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each\n words.each { |word| yield( word ) }\n end", "def each\n words.each { |word| yield(word) }\n end", "def each_v1\n words.each { |word| yield(word) }\n end", "def each_word(data=nil)\n\t\t\tself.words(data).each {|word| yield word }\n\t\tend", "def each\n word_array = words\n inde...
[ "0.80814636", "0.803478", "0.7768043", "0.7676784", "0.7528286", "0.7179631", "0.7112211", "0.7099856", "0.7093306", "0.70314497", "0.70074385", "0.69655263", "0.69551146", "0.68131745", "0.6710978", "0.6708269", "0.6625018", "0.6625018", "0.6625018", "0.66104347", "0.6576403...
0.7526428
5