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
Creates a new account associated with a user
def create_account(user) account = Account.to_adapter.get!(user.id) update_status = account.update_with_password({ "email" => user.email, "name" => user.username }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_account_user(options = {})\n post('accountuser?_method=PUT', options)\n end", "def create\n user = User.new(user_params)\n if user.save\n auth_token = AuthenticateUser.new(user.email, user.password).call\n response = { message: Message.account_created, auth_token: auth_toke...
[ "0.8249613", "0.8177913", "0.8169718", "0.8167203", "0.81080574", "0.8106919", "0.80858177", "0.80858177", "0.80858177", "0.8024215", "0.7987127", "0.7946853", "0.7906529", "0.7906014", "0.79030114", "0.7872508", "0.78147525", "0.7814468", "0.7783149", "0.7780288", "0.7758448...
0.0
-1
Creates or finds an object by id. If an actor is given, will use the actor to create the object. Otherwise, will just use the new method on the model given
def find_or_create(model, actor, id, user, params) curation_concern = model.where(desc_metadata__identifier_tesim: id).first if curation_concern.nil? curation_concern = model.new(identifier: id) if actor.present? actor.new(curation_concern, user, params).create else curation_concern.attributes = params curation_concern.apply_depositor_metadata(user.user_key) curation_concern.save! end end curation_concern end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_or_create( id )\n begin\n get( id )\n rescue\n create!( :id => id )\n end \n end", "def set_actor\n @actor = Actor.find(params[:id])\n end", "def get_object\n class_name.create_from_database(id)\n end", "def set_actor\n ...
[ "0.6491675", "0.6340175", "0.62531507", "0.6214431", "0.6214431", "0.6214431", "0.6080644", "0.6033748", "0.5943735", "0.5898148", "0.58860064", "0.58745116", "0.58000165", "0.57822293", "0.57809085", "0.5729493", "0.57106215", "0.56893176", "0.5664932", "0.5632625", "0.56208...
0.64547354
1
Creates or finds a library collection by description. If an actor is given, will use the actor to create the object. Otherwise, will just use the new method on the model given
def find_or_create_library_collection(description, user, params) collection = LibraryCollection.where(desc_metadata__description_tesim: description).first if collection.nil? collection = LibraryCollection.new collection.attributes = params collection.apply_depositor_metadata(user.user_key) collection.save! end collection end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_collection\n Models::Collection.new\n end", "def find_or_create_collection(collection)\n\t # collection is response from sohpify api\n\t\tc = collections.find_by_shopify_collection_id(collection.id)\n \tRails.logger.debug(\"Found existing collection (#{collection.class.name}): #{c.title}...
[ "0.55714256", "0.5533466", "0.55154943", "0.5514012", "0.54876447", "0.5331431", "0.53138965", "0.52313167", "0.52232236", "0.52202266", "0.5167979", "0.515217", "0.51007354", "0.49806887", "0.49253234", "0.4910403", "0.49039218", "0.49008265", "0.4878139", "0.48753464", "0.4...
0.6880261
0
GET /sites GET /sites.json
def index if current_user if current_user.id == 1 && current_user.email == 'master@inruby.com' @sites = Site.order("updated_at desc").page(params[:page] || 1) else @sites = current_user.sites.page(params[:page] || 1) end elsif current_member @sites = current_member.sites.page(params[:page] || 1) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n end", "def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n...
[ "0.77209103", "0.77209103", "0.7517273", "0.7412494", "0.73809344", "0.7306581", "0.7016558", "0.6896694", "0.684382", "0.68408626", "0.6827524", "0.6827524", "0.6827524", "0.67936283", "0.67904365", "0.6769869", "0.67423725", "0.66910815", "0.66882485", "0.66785043", "0.6652...
0.0
-1
GET /sites/1 GET /sites/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n end", "def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n...
[ "0.7444836", "0.7444836", "0.7214904", "0.7204854", "0.7108241", "0.70891887", "0.70891887", "0.70891887", "0.7068557", "0.703299", "0.69449097", "0.68207115", "0.68081486", "0.67804134", "0.67772996", "0.6742932", "0.67404276", "0.6618609", "0.656212", "0.6556428", "0.655562...
0.0
-1
POST /sites POST /sites.json
def create @site = Site.new(site_params) @site.user_id = current_user.id if current_user @site.member_id = current_member.id if current_member @site.typo = ['personal', 'business'].delete(params[:typo].to_s.downcase) || 'personal' respond_to do |format| if @site.save! if params[:typo] == 'business' @site.site_payment.price = ENV["PRICE_BUSINESS"] @site.site_payment.save! end if @site.template.property == 'free' @site.set_free end #build site_page via template_page Templates::Page.where(template_id: @site.template_id).order("position ASC").each do |temp_page| @site.site_pages.create( site_id: @site.id, template_page_id: temp_page.id, title: temp_page.title) end #add a comment SiteComment.create(site_id: @site.id, name: '维斗喜帖', content: '小维斗来过,提前送上一声祝福~') #send notice to admin # if Rails.env == 'production' # SmsSendWorker.perform_async(ENV['ADMIN_PHONE'].split('|').join(','), "#{@site.user.try(:email) || @site.member.try(:auth_id)}创建了应用:#{get_site_url(@site)}") # end #redirect format.html { redirect_to site_site_steps_path(@site), notice: t('notice.site.created') } format.json { render action: 'show', status: :created, location: @site } else format.html { render action: 'new' } format.json { render json: @site.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @site = current_user.sites.create(params[:site])\n respond_to do |format|\n if @site.save\n format.html { flash_and_redirect(\"successfully saved!\", sites_url) }\n format.json { render json: @site, status: :created, location: @site }\n else\n format.html { render ...
[ "0.67946297", "0.66968215", "0.65516245", "0.65030956", "0.64209604", "0.64209604", "0.64209604", "0.6335178", "0.63177776", "0.629245", "0.62879896", "0.6279627", "0.6162099", "0.61234045", "0.6087425", "0.6069964", "0.6069242", "0.6069242", "0.6049953", "0.60482645", "0.602...
0.0
-1
PATCH/PUT /sites/1 PATCH/PUT /sites/1.json
def update authorize!(@site) respond_to do |format| if @site.update(site_params) format.html { redirect_to site_site_steps_path(@site), notice: t('notice.site.updated') } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @site.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @site = current_user.sites.find(params[:id])\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n format.html { flash_and_redirect(\"successfully updated!\", sites_url) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" ...
[ "0.66009605", "0.6526346", "0.63324624", "0.6311438", "0.6302069", "0.6299964", "0.6291095", "0.6290031", "0.6267976", "0.62325794", "0.61879224", "0.61804986", "0.6174384", "0.6156619", "0.61509115", "0.6141815", "0.6141815", "0.6099228", "0.6093527", "0.60913587", "0.608539...
0.6248215
9
DELETE /sites/1 DELETE /sites/1.json
def destroy authorize!(@site) @site.destroy respond_to do |format| format.html { redirect_to sites_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @site.destroy\n\n respond_to do |format|\n format.html { redirect_to sites_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @site.destroy\n respond_to do |format|\n format.html { redirect_to sites_url }\n format.json { head :no_content }\n ...
[ "0.7356214", "0.73258954", "0.73258954", "0.73258954", "0.73258954", "0.73258954", "0.7317765", "0.7289903", "0.7289903", "0.7289903", "0.7289903", "0.7289903", "0.7289426", "0.7267864", "0.72534925", "0.7246142", "0.7225299", "0.7222419", "0.7191969", "0.71299064", "0.710079...
0.7050253
29
Use callbacks to share common setup or constraints between actions.
def set_site @site = Site.find_by(id: params[:id]) #for preview/themes/set_theme @site ||= Site.find_by(id: params[:site_id]) not_found if @site.nil? 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 site_params params.require(:site).permit(:user_id, :member_id, :template_id, :short_title, :title, :description, :domain, :is_publiched, :is_comment_show, :updated_by, :note, :typo) 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
expired, we used QRcode API to generate qrcode
def generate_qrcode_bak(page) url = get_site_url(page) return if url.blank? qr = RQRCode::QRCode.new( url, :size => 6, :level => :h ) png = qr.to_img # returns an instance of ChunkyPNG qr_dir = File.join(Rails.root, 'public', 'qrcode') FileUtils.mkdir_p qr_dir png_path = File.join(qr_dir, "#{page.id}.png") if File.exist? png_path #FileUtils.rm png_path else png.resize(120, 120).save(png_path) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_qr_code\n self.qr_code = QrCodeFetcher.qr_code(code)\n end", "def qrcode\n @qr = RQRCode::QRCode.new(\"http://0.0.0.0:3000/visit/#{self.tag}\", :size => 6)\n return @qr\n end", "def create_qrcode\n\t\t@qr = RQRCode::QRCode.new( qr_code_params[:text], size: 4)\n\t\tbyebug \n\tend", "def q...
[ "0.6940199", "0.682166", "0.6792996", "0.6791151", "0.6786073", "0.6724819", "0.6723486", "0.6717326", "0.67033046", "0.6611236", "0.6510714", "0.64748716", "0.64384496", "0.6358037", "0.6141618", "0.6131795", "0.6102591", "0.6087611", "0.6081585", "0.6073607", "0.6040163", ...
0.62623596
14
GET /roles/1 GET /roles/1.json
def show @role = Role.find(params[:id]) @permissions = @role.permissions.group_by &:subject_class end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n authorize Role\n\n respond_to do |format|\n format.json { render json: @roles }\n end\n end", "def get_user_roles\n @roles = @user.roles.pluck(:name)\n render json: @roles\n end", "def GetRole id\n\n APICall(path: \"custom_roles/#{id}.json\")\n\n end", "def index...
[ "0.78213215", "0.758502", "0.7496266", "0.7405081", "0.71934754", "0.7189593", "0.71655685", "0.71655685", "0.71655685", "0.71500736", "0.7138432", "0.71365404", "0.7123315", "0.71224034", "0.71155775", "0.7091493", "0.7074178", "0.70495325", "0.7039511", "0.7039511", "0.7039...
0.0
-1
GET /roles/new GET /roles/new.json
def new permissions @role = Role.new #render layout: "users" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @role }\n end\n end", "def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @role }\n end\n end", "d...
[ "0.8056065", "0.8056065", "0.8056065", "0.8047554", "0.7925329", "0.7899501", "0.75905114", "0.7552672", "0.75305", "0.7404623", "0.73878103", "0.73797524", "0.73708034", "0.73708034", "0.73668516", "0.73646253", "0.73598355", "0.73466617", "0.73466617", "0.73466617", "0.7346...
0.7036298
37
PUT /roles/1 PUT /roles/1.json
def update @role = Role.find(params[:id]) if @role.update_attributes(params[:role]) msg= "Role updated successfully!" else msg= "Role update failed!" end redirect_to roles_path, :flash => { :notice => msg } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit_role(id, *roles)\n request(:put, \"/users/#{id}.json\", default_params(:role_ids => roles))\n end", "def UpdateRole params = {}\n \n APICall(path: 'custom_roles.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n @role = Role.find(params[:id])\n ...
[ "0.73883325", "0.7328734", "0.71556437", "0.7143024", "0.7127945", "0.7085617", "0.69865286", "0.6953493", "0.6936841", "0.69317037", "0.6862839", "0.68599266", "0.6855699", "0.6850963", "0.6815799", "0.68097216", "0.680326", "0.67881626", "0.6777378", "0.6759132", "0.6749898...
0.67518514
20
DELETE /roles/1 DELETE /roles/1.json
def destroy @role = Role.find(params[:id]) if @role.destroy msg= "Role deleted successfully!" else msg= "Role delete failed!" end redirect_to roles_path, :flash => { :notice => msg } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @role = Role.find(params[:id])\n @role.destroy\n \n respond_to do |format|\n format.html { redirect_to roles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @role = Role.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n format...
[ "0.7583307", "0.7525977", "0.7523992", "0.75092655", "0.74943435", "0.7418692", "0.738887", "0.73744464", "0.73679906", "0.7358079", "0.731516", "0.72902375", "0.72487247", "0.72487247", "0.72487247", "0.72487247", "0.72487247", "0.72487247", "0.723153", "0.7230734", "0.72307...
0.681107
68
Required function, gets the user's permissions
def get_permissions(username) p = lookup_permissions(username) if p return p else return nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def permissions\n User.do_find_permissions session_id: kb_session_id\n end", "def get_permissions_for_user(user)\n get_filtered_policy(0, user)\n end", "def core_getUsersPermissions\n # definisco permessi iniziali\n initial_permissions = (1...11).to_a\n\n unpermitted = core_getHi...
[ "0.7721293", "0.76671964", "0.7524065", "0.7485433", "0.7480434", "0.74454635", "0.74011177", "0.7354342", "0.73300326", "0.73300326", "0.731497", "0.72748226", "0.7213902", "0.71776867", "0.7167066", "0.7166284", "0.7164", "0.71080077", "0.7106864", "0.7092431", "0.70769835"...
0.73144835
11
Required function, sets the user's permissions
def set_permissions(username,tags,is_admin = false) begin p = lookup_permissions(username) if !p # upsert p = Permissions.create! p.username = username end p[:tags] = tags p[:is_admin] = is_admin p.save! if !p.persisted? raise "Failed to save user data for #{username}" end return true rescue # TODO: log message? return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_perms\n self.perms = Access.for_user(self)\n end", "def add_user_permission(u)\n\t\t\n\tend", "def set_permissions\n return if @permissions_set\n\n @permissions_set = true\n resource[:configure_permission] ||= configure_permission\n resource[:read_permission] ||= read_permission\n ...
[ "0.7977588", "0.7109746", "0.70483655", "0.70214736", "0.6990836", "0.6971471", "0.6963179", "0.69421303", "0.69361514", "0.69091797", "0.6882876", "0.68732065", "0.68329626", "0.68142605", "0.66860443", "0.66695046", "0.66576314", "0.6646836", "0.6645479", "0.6643446", "0.66...
0.6673354
15
Required function, enables a user
def enable_user(username) begin p = get_permissions(username) if !p raise "Username not found" end p[:enabled] = true p.save! if !p.persisted? raise "Failed to save user data for #{username}" end return true rescue return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enable\n account = Account.for(\"github\").with_username(params[:id]).first!\n @user = User.unscoped.where(id: account.user_id).first\n authorize! @user\n @user.enabled = true\n @user.save\n redirect_back fallback_location: root_path, notice: t(\"user.enabled\", name: @user.username)\n end",...
[ "0.7553401", "0.75487393", "0.7347638", "0.72980523", "0.7216887", "0.71703404", "0.703553", "0.6938965", "0.6922789", "0.6870529", "0.686023", "0.6708095", "0.6679455", "0.6674792", "0.6631365", "0.6609623", "0.65958905", "0.6594616", "0.65693635", "0.65651494", "0.65570587"...
0.7260108
4
Required function, disables a user
def disable_user(username) begin p = get_permissions(username) if !p raise "Username not found" end p[:enabled] = false p.save! if !p.persisted? raise "Failed to save user data for #{username}" end return true rescue return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def disable\n\t\tif user = check_admin\n\t\t\ttarget_user = User.find_by(id: params[:id])\n\t\t\ttarget_user.toggle!(:enabled)\n\t\t\tredirect_back fallback_location: '/home'\n\t\tend\n\tend", "def disable\n authorize! @user\n @user.enabled = false\n @user.save\n @user.owned_extensions.update_all(ena...
[ "0.780542", "0.779273", "0.76537454", "0.75238055", "0.74835455", "0.73480237", "0.7169268", "0.71021056", "0.7081415", "0.7074036", "0.70579636", "0.7019934", "0.6970868", "0.683677", "0.67915636", "0.6782685", "0.6763669", "0.6744167", "0.6735878", "0.67284983", "0.6693534"...
0.7210115
6
Required function, returns the storage class for this module.
def get_storage_module(config) return StorageMongo.new(config) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_storage_class\n return @m_storage_class\n end", "def storage_class\n @storage_class || storage_loader.storage_class\n end", "def storage_class\n raise NotImplementedError\n end", "def storage_instance; end", "def storage \n Trole::Storage::BaseOne\n e...
[ "0.87562126", "0.8634465", "0.8194757", "0.75012326", "0.72874165", "0.7138072", "0.70258355", "0.6935941", "0.68922484", "0.6846309", "0.6666178", "0.6666178", "0.6653607", "0.6620355", "0.66112405", "0.66050255", "0.66050255", "0.66050255", "0.6579115", "0.6556527", "0.6542...
0.7398641
4
Returns the name of the script. This can be used in blocks.
def name @@name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raw_script_name\n File.basename($0)\n end", "def script_name # not file name\n sname = fetch(:script_name)\n return sname if sname\n name = dklet_script.basename('.rb').to_s\n pname = script_path.basename.to_s\n \"#{pname}_#{name}\"\n end", "def script_name\n return @reques...
[ "0.82970184", "0.8199234", "0.81594294", "0.7578686", "0.74230343", "0.7398198", "0.7313718", "0.6917737", "0.67348295", "0.6654268", "0.6600941", "0.65731126", "0.65731126", "0.6366667", "0.6302989", "0.6214558", "0.6150102", "0.6139151", "0.61264306", "0.610206", "0.6100191...
0.0
-1
Prints the usage message. This can be used in blocks.
def print_usage puts @@usage end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def usage\n puts @usage_text\n end", "def print_usage; end", "def printUsage\n \n print \"usage -- main.rb <structureFile> <outFile>\\n\"\n print \" <numTimesteps> - total number of timesteps to run\\n\"\n print \" <structureFile> - the PDB file to read in\\n\"\n print \" <outFilePrefi...
[ "0.7909556", "0.7436143", "0.7390462", "0.7385388", "0.7350944", "0.7316139", "0.73084694", "0.7294692", "0.72527647", "0.72032785", "0.71514326", "0.71102524", "0.70941794", "0.70545274", "0.7014615", "0.6957898", "0.6949345", "0.69478637", "0.6907171", "0.68970203", "0.6880...
0.71498704
11
A string of all possible options. Use split to get an array of all options. This can be used in blocks.
def options @@auto_completion.inject do |opts,opt| opts + " " + opt end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def options\n self.read_attribute(:options).split(\"\\n\") unless self.read_attribute(:options).nil?\n end", "def options # :nodoc:\n [].tap do |o|\n o << \"Lazy\" if lazy?\n o << \"Reverse\" if reverse?\n o << \"Exclude [#{all_excluded_words.join(\", \")}]\" if excluded_words.any?\...
[ "0.68131024", "0.67295176", "0.66375643", "0.6523511", "0.6333441", "0.62912744", "0.6160395", "0.6158594", "0.61347073", "0.61346024", "0.5998505", "0.5959725", "0.59404093", "0.5923119", "0.5923119", "0.58971095", "0.5851608", "0.58389515", "0.5818988", "0.5818988", "0.5818...
0.5540982
77
An array of the argument types of a given option. This can be used in blocks.
def arguments command @@auto_completion_arguments[command] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def argument_types\n @arguments.map(&:type)\n end", "def types\n @opt_types.values\n end", "def valid_argument_list!(rest, *types)\n if rest.size == types.size\n result = rest.zip(types).collect do |arg, type|\n if String == type\n arg.to_s\n e...
[ "0.76946187", "0.69814646", "0.62571347", "0.6144715", "0.6029329", "0.60183674", "0.5975797", "0.5949074", "0.5856", "0.5834082", "0.5785334", "0.5737654", "0.57023454", "0.5683804", "0.5661047", "0.56579965", "0.5611273", "0.56039774", "0.5590399", "0.5587844", "0.55810493"...
0.0
-1
Remembers the current directory. It can be restored with restore_dir. This can be used in blocks.
def store_dir @dir = Dir.pwd end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def restore_dir\n cd @dir\n end", "def pop_dir\n # the first time we pop, we need to put the current on stack\n @visited_dirs.push Dir.pwd unless @visited_dirs.index(Dir.pwd)\n ## XXX make sure thre is something to pop\n d = @visited_dirs.delete_at 0\n ## XXX make sure the dir exists, cuold have been de...
[ "0.78397775", "0.681919", "0.66100454", "0.6450121", "0.616536", "0.61498183", "0.6125742", "0.6103921", "0.60885924", "0.60654163", "0.6063722", "0.5972469", "0.5951613", "0.5904455", "0.5887028", "0.58789873", "0.5850239", "0.58397055", "0.5826174", "0.582608", "0.582608", ...
0.67519134
2
Sets the working directory to the previously remembered directory. This can be used in blocks.
def restore_dir cd @dir end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def working_dir(&block)\n return Dir.chdir(@working_dir, &block) if block_given?\n @working_dir\n end", "def set_workdir(filename)\n @workdir = File.dirname(filename)\n end", "def work_dir=(path)\n path << '/' unless path.end_with?('/')\n @work_dir = path\n end", "def store_...
[ "0.70690095", "0.67744815", "0.66051114", "0.6562462", "0.6540574", "0.6527892", "0.6491792", "0.64081013", "0.6394955", "0.6367231", "0.6363701", "0.63587695", "0.63111115", "0.63071555", "0.62982917", "0.6174338", "0.61456275", "0.61456275", "0.61456275", "0.6143104", "0.61...
0.65541875
4
Call once per request to determine how long to sleep.
def get_delay @call_times << Time.now if @call_times.size < 2 then return 0 else @call_times.shift while @call_times.size > @history_size first = @call_times[0] last = @call_times[-1] expected = (@call_times.size / (@calls_per_minute / 60.0)) actual = last - first # float: number of seconds delay = [0, expected-actual].max return delay end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sleep_time\n\t\t\t# TODO: Hard-coded for now. See doc/app_manager.rdoc for some\n\t\t\t# thoughts on this.\n\t\t\t1\n\t\tend", "def find_with_sleep\n sleep(request.sleep || 1)\n response.name = 'Request should have timed out'\n end", "def sleep_time\n 60\n end", "def poll_sleep\n ...
[ "0.7475334", "0.73335546", "0.7328012", "0.7303496", "0.71901864", "0.7125286", "0.6984744", "0.6844913", "0.6777024", "0.6771848", "0.67280704", "0.67259413", "0.6720418", "0.66785264", "0.66757053", "0.666766", "0.66594046", "0.6642802", "0.66375846", "0.6629606", "0.659455...
0.0
-1
Checkin date should not be less than today's date.
def checkin_at_after_or_on_today return if dates_blank if checkin_at < Date.today self.errors.add(:checkin_at, ": Should be greater than or equal to today's date") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_in_cannot_be_in_the_past\n if check_in.present? && check_in < Date.today\n errors.add(:check_in, \"can't be in the past\")\n end\n end", "def checkout_before_checkin\n errors.add(:guest_id, \"Check out date must be before Check In date\") if checkin != nil && checkout != nil && checkout ...
[ "0.7624395", "0.7586155", "0.7478645", "0.7250873", "0.72344786", "0.72283113", "0.7192968", "0.7068701", "0.699601", "0.6960622", "0.6960622", "0.68803966", "0.6801893", "0.67565036", "0.6746318", "0.67265224", "0.6720884", "0.67051125", "0.666174", "0.66460663", "0.6625849"...
0.7987446
0
Booking should only be for day1 to day2 as booking is done for night for example today's 12pm to next day's 12pm.
def checkout_at_after_checkin_at return if dates_blank if checkout_at <= checkin_at self.errors.add(:checkout_at, ': Should be greater than checkin date ') end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @status = \"Booked\"\n @status_notice = 'booking was successfully created.'\n @bookings = Booking.where(:conference_room_id => params[:conference_room_id])\n @bookings.each do |booking| \n if (booking.start_time..booking.end_time).cover?(params[:booking][:start_time]) || (bo...
[ "0.6871077", "0.66731143", "0.6518779", "0.6506147", "0.6464772", "0.6320888", "0.6309181", "0.62830985", "0.62649715", "0.6259603", "0.6251623", "0.6242036", "0.6233639", "0.62059397", "0.6191687", "0.61739093", "0.6173694", "0.6172085", "0.614515", "0.61417675", "0.61385643...
0.0
-1
Restriction to book only upto 6 months. User can do checkin within 6 months. Checkout is not restricted.
def checkin_before_6_months return if dates_blank if checkin_at >= (Date.today + 6.months) self.errors.add(:checkin_at, ': Should be less than or equal to 6 months') end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time_period_for_room_reservation\n time_period = (self.start_date.year * 12 + self.start_date.month) - (Date.today.year * 12 + Date.today.month)\n errors.add(:start_date, \"you can book your room before 6 months only\") if time_period > 6\n end", "def bookable?(date)\n date < booking_date_limit\n ...
[ "0.65613383", "0.6254185", "0.61772865", "0.58629364", "0.5851184", "0.58436793", "0.581441", "0.5775874", "0.5738204", "0.573172", "0.571981", "0.57090956", "0.5690138", "0.567225", "0.56311065", "0.56303257", "0.56210506", "0.56154925", "0.5610927", "0.56055796", "0.5603714...
0.6652991
0
Checks if the system is properly setup. This method is used by the bootstrapper to see if the system should be initialized. If the system is not properly setup, the bootstrapper will crash. Checks are performed to see if all the tables exists.
def check unless check_tables puts "CBAC: not properly initialized: one or more tables are missing. Did you install it correctly? (run generate)" return false end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialized?\r\n if ENV[\"RAILS_ENV\"] == \"test\" || !User.table_exists? || $setup_disabled \r\n return false\r\n else \r\n $tmp_env = ENV[\"RAILS_ENV\"] || \"development\"\r\n return true\r\n end \r\n end", "def sanityCheck\n @executor.nil? and raise \"Executor has not been ...
[ "0.7000241", "0.639725", "0.62109065", "0.61498785", "0.6081087", "0.59626234", "0.59558016", "0.59019995", "0.59019995", "0.5891363", "0.58892536", "0.58763915", "0.586858", "0.5817226", "0.5798799", "0.5797024", "0.57703197", "0.5764787", "0.57598954", "0.5753579", "0.57528...
0.7547931
0
get all repositories TODO: get this somehow in line with using the Searchable module
def index @criteria = {} @criteria['sort'] = repositories_sort_by # let's not include any 0-collection repositories unless specified # include_zero = (!params.blank? && params['include_empty']) # ok, page sizing is kind of complicated if not including zero counts page_size = params['page_size'].to_i if !params.blank? page_size = AppConfig[:pui_search_results_page_size] if page_size == 0 query = 'primary_type:repository' facets = find_resource_facet page = params['page'] || 1 if !params.blank? @criteria['page_size'] = 100 @search_data = archivesspace.search(query, page, @criteria) || {} @json = [] if !@search_data['results'].blank? @pager = Pager.new("/repositories?", @search_data['this_page'], @search_data['last_page']) @search_data['results'].each do |result| hash = ASUtils.json_parse(result['json']) || {} id = hash['uri'] if !facets[id].blank? hash['count'] = facets[id] @json.push(hash) end end else raise NoResultsError.new("No repository records found!") end @page_title = I18n.t('list', {:type => (@json.length > 1 ? I18n.t('repository._plural') : I18n.t('repository._singular'))}) render end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_repositories\n get(\"#{url_base}/repositories?#{dc}\")[\"data\"]\n end", "def repositories\n response = self.class.get('/repositories').body\n JSON.parse(response)\n end", "def repositories\n # TODO : merge with current data\n load_repos\n end", "def repositories\n\t\t\telems ...
[ "0.814363", "0.8037317", "0.7947352", "0.7901802", "0.7874824", "0.7850466", "0.7836493", "0.78187156", "0.7746905", "0.76963997", "0.76888", "0.7649038", "0.7593359", "0.75741094", "0.75416505", "0.7531467", "0.75255126", "0.7510282", "0.74784523", "0.7455886", "0.7341373", ...
0.0
-1
get counts of various records belonging to a repository
def get_counts(repo_uri) types = %w(pui_collection pui_archival_object pui_record_group pui_accession pui_digital_object pui_agent pui_subject) counts = archivesspace.get_types_counts(types, repo_uri) # 'pui_record' as defined in AppConfig ('record_badge') is intended for archival objects only, # which in solr is 'pui_archival_object' not 'pui_record' so we need to flip it here counts['pui_record'] = counts.delete 'pui_archival_object' final_counts = {} counts.each do |k, v| final_counts[k.sub("pui_", '')] = v end final_counts['resource'] = final_counts['collection'] final_counts['classification'] = final_counts['record_group'] final_counts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count\n size = 0\n core_search.group(\"name.id, #{main_group_by_columns}\").each do |_x|\n size += 1\n end\n size\n end", "def project_counts\n @project_counts ||= Kithe::Model.joins(:contains_contained_by).\n where(published: true, contains_contained_by: {container_id: project_...
[ "0.68711966", "0.6806252", "0.677834", "0.6774241", "0.6767395", "0.6765067", "0.67167723", "0.67054987", "0.6692752", "0.665436", "0.6565099", "0.6556102", "0.6518391", "0.6428198", "0.640877", "0.6387814", "0.63485754", "0.63485754", "0.6326861", "0.6313247", "0.6310123", ...
0.6806599
1
compose a string of 'OR'd titles for a query
def compose_title_list(pairs) query = '' pairs.each do |s, ct| query = query + " title:\"#{s}\"" end "(#{query})" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ar_transform_query_terms terms\n if terms && !terms.empty? && terms !~ /^\\s*[*? ]*\\s*$/\n terms.split(\" \").inject([]) do |query, token| \n query << \"*#{token}*\" \n end.join(\" or \")\n else\n \"\"\n end\n end", "def build_query(query, options={})\n que...
[ "0.66017383", "0.6592401", "0.6447617", "0.63557243", "0.63136", "0.62717295", "0.61357176", "0.6098254", "0.6058769", "0.6050013", "0.6035338", "0.60258174", "0.59983474", "0.59329987", "0.5874354", "0.58663225", "0.5860598", "0.58542967", "0.5850351", "0.58428484", "0.58413...
0.63271016
4
USED called from trigger service Send event reminder to user
def scheduled_event_reminder_triggered(user_id, event_ids) return if user_id.nil? || event_ids.nil? || event_ids.empty? user = User.find(user_id) return unless user.should_send_email? events = event_ids.map { |id| Event.find(id) } if(events.size==1) tse = events.first.teamsheet_entry_for_user(user) if user.junior? JuniorMailerService.scheduled_event_reminder_single(user, tse) else UserMailer.delay.scheduled_event_reminder_single(tse) end else teamsheet_entries = events.map { |e| e.teamsheet_entry_for_user(user)} if user.junior? JuniorMailerService.scheduled_event_reminder_multiple(user, teamsheet_entries) else UserMailer.delay.scheduled_event_reminder_multiple(user, teamsheet_entries) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reminder_sent\n end", "def reminder_received(event)\n @event = event\n\n mail :to => event.email, :subject => 'Reminder alert'\n end", "def acknowledged_event(user,event)\n @greeting = \"Hi\"\n @event = event\n mail to: user.email\n end", "def reminder\n DateEventApplicationsMailer.r...
[ "0.7809899", "0.7316274", "0.71923053", "0.71556234", "0.7012851", "0.6966477", "0.6963192", "0.6955951", "0.6951478", "0.6891523", "0.6850651", "0.6811893", "0.67579454", "0.6750615", "0.66504407", "0.66271234", "0.66061294", "0.6562785", "0.65620184", "0.6515868", "0.651467...
0.61183244
69
USED called from user registrations service send confirmation email to user
def invited_user_registered(user) UserMailer.delay.user_registered_confirmation(user) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_confirmation_to(user)\n token_link = \"http://localhost:9292/validate/\" + user.validation_token\n template_locals = { :user => user, :token_url => token_link}\n send_email_to_user(user,\"Frank requests that you verify your email address.\" ,:'mail/new_registration', template_locals)\n end", "...
[ "0.8240044", "0.8081391", "0.8028264", "0.802101", "0.79306096", "0.79186344", "0.7882507", "0.78680325", "0.7867517", "0.78668797", "0.7848442", "0.7838104", "0.78369564", "0.78168875", "0.7813571", "0.7813351", "0.78127444", "0.7792471", "0.77844536", "0.77539027", "0.77521...
0.0
-1
find a team's updated events, for the schedule.
def updated_events(team) return team.future_events if team.schedule_last_sent.nil? team.future_events.select do |event| !event.last_edited.nil? && event.last_edited > team.schedule_last_sent end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def schedule_updated(app_event)\n team = app_event.obj\n return [] unless team.schedule_updates? \n event_ids = team.updated_events.map(&:id)\n generate_nis(app_event, \"schedule_updated\", event_ids)\n end", "def create_or_update_google_calendar_events\n client = Google::Apis::Calenda...
[ "0.6999584", "0.603998", "0.59195554", "0.5888743", "0.58881843", "0.58482814", "0.5760947", "0.56692815", "0.56352264", "0.56202865", "0.5536202", "0.55358547", "0.55117476", "0.5509245", "0.547375", "0.5459001", "0.5457908", "0.5454145", "0.54526347", "0.54355556", "0.54353...
0.8029248
0
Use callbacks to share common setup or constraints between actions.
def set_project @project = Project.friendly.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 project_params params.require(:project).permit(:title, :image, :banner, :date, :description, :summary, :link, :status) 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
print documentation ri 'Arraypop' Array.ri Array.ri :pop arr.ri :pop
def ri(method = nil) unless method && method =~ /^[A-Z]/ # if class isn't specified klass = self.kind_of?(Class) ? name : self.class.name method = [klass, method].compact.join('#') end puts `ri '#{method}'` end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def using_pop(array)\n array.pop()\nend", "def \n \n using_pop(array)\n \n\n array.pop()\n \nend", "def pop\r\n @arr.shift\r\n end", "def using_pop(array)\n array.pop\nend", "def using_pop(array)\n array.pop\nend", "def using_pop(arr)\n arr.pop\nend", "def using_pop(array)\n element = ...
[ "0.7991969", "0.7976135", "0.7928831", "0.7905559", "0.7868258", "0.78483194", "0.7819838", "0.779345", "0.779345", "0.779345", "0.779345", "0.779345", "0.779345", "0.779345", "0.779345", "0.779345", "0.7650248", "0.7580603", "0.747871", "0.7279898", "0.72511715", "0.720249...
0.0
-1
description: serialize the current instance into a question object params: retval: the question object
def serialize super(ATTR_NAME_ARY) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialize\n end", "def serialize; end", "def serialize; end", "def serialize!\n end", "def to_str( )\n @question\n end", "def serialize\n raise NotImplementedError\n end", "def serialize\n raise NotImplementedError\n end", "def serialize\n YAML::dump(self)\n e...
[ "0.641145", "0.6276993", "0.6276993", "0.62692004", "0.6193972", "0.6187958", "0.6187958", "0.6151299", "0.61481744", "0.6139823", "0.6042619", "0.5874564", "0.58579063", "0.58282727", "0.58166385", "0.56716084", "0.5668924", "0.5660885", "0.56190443", "0.56190443", "0.561904...
0.0
-1
stringifies and sorts hashes by key at all levels.
def params_sorted_by_key(params) case params when Hash params.map { |k, v| [k.to_s, params_sorted_by_key(v)] } .sort_by { |k, v| k } .to_h when Array params.map { |val| params_sorted_by_key(val) } else params.to_s end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fixed_keys_sort(hash)\n hash.keys.sort_by(&:to_s)\n end", "def deep_stringify_and_sort(&sort_by)\n result = ActiveSupport::OrderedHash.new\n hash = self.stringify_keys\n hash.stringify_keys.keys.sort(&sort_by).each do |key|\n ...
[ "0.72697985", "0.7064936", "0.6816567", "0.678557", "0.64280444", "0.6369996", "0.63179386", "0.6286139", "0.62857866", "0.6284841", "0.6240203", "0.62281466", "0.6168877", "0.6166443", "0.6144299", "0.60586685", "0.6055375", "0.605347", "0.6000603", "0.5945983", "0.59232247"...
0.6136199
15
Render straight markdown templates. As no ruby will be evaluated the view handler, locals and content block will be ignored.
def render(template_name, view_handler, locals, &content) self.kramdown_source.render(template_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_markdown\n return @render if @render\n @render = Markdown.new(:content => content, :indent => self.indent, :path => self.commit ? \"/commits/#{self.commit.id}#{self.web_path}\" : self.web_path)\n @render\n end", "def render_md page, content\n markdown(content || self.body) # HACK\...
[ "0.72609544", "0.72320473", "0.72320473", "0.72225416", "0.70029414", "0.6962477", "0.6707446", "0.65958196", "0.6485835", "0.6475052", "0.6405583", "0.6397387", "0.63704205", "0.6340168", "0.63400334", "0.63383126", "0.63383126", "0.6332613", "0.6328182", "0.6327208", "0.630...
0.62538296
25
Render straight markdown partial templates. As no ruby will be evaluated the locals and content block will be ignored.
def partial(template_name, locals, &content) self.kramdown_source.render(template_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def partial(page, locals={})\n haml page, {:layout => false}, locals\n end", "def render_md page, content\n markdown(content || self.body) # HACK\n end", "def render_md page, content\n markdown(content || self.body) # HACK\n end", "def partial(template, locals = {})\n haml(template, { layout: ...
[ "0.7001233", "0.6778516", "0.6778516", "0.67237145", "0.6688345", "0.6688345", "0.6649767", "0.66445214", "0.6524422", "0.6524422", "0.6514172", "0.6492352", "0.642148", "0.642148", "0.6387135", "0.6384678", "0.6332803", "0.63063526", "0.6269621", "0.6229147", "0.61983186", ...
0.7253534
0
this is used when chaining engines where another engine initially loads the template file
def compile(template_name, compiled_content) self.kramdown_source.compile(template_name, compiled_content) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def template_engine\n @template_engine ||= :erb\n end", "def initialize()\n @template = \"call load_file() or load_url() to load a template\"\n @loadOK = false \n end", "def template\n raise \"Template was not loaded: #{@template}\" if !@loadOK\n @template\n end", "def loadTempl...
[ "0.6663644", "0.65755", "0.6564395", "0.65490884", "0.65490884", "0.64438295", "0.64160377", "0.6399417", "0.6397451", "0.6397347", "0.63802975", "0.63603044", "0.6356546", "0.63317317", "0.63317317", "0.6326819", "0.6326625", "0.6274839", "0.6269271", "0.62640345", "0.625910...
0.0
-1
check if chapter is completed
def completed?(chapter) chapters_completed.include? chapter end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_chapter?()\n end", "def whole_chapter?\n starting_bibleverse.verse.zero?\n end", "def whole_book?\n starting_bibleverse.chapter.zero?\n end", "def chapter_valid?(chapter)\n chapter.positive? && chapter <= nr_of_chapters\n end", "def chapters?\n !chapters.empty?\n end", "def ...
[ "0.7454416", "0.7354883", "0.7082739", "0.6996206", "0.69689006", "0.6820225", "0.67828554", "0.6707823", "0.6693948", "0.66886413", "0.66775817", "0.66647863", "0.6630133", "0.6594676", "0.65755224", "0.6534223", "0.65311223", "0.64830786", "0.644937", "0.6446057", "0.644072...
0.82123095
0
calculate progress of lesson
def progress(lesson) "%0.2f%" % (chapters_completed.where(lesson: lesson).count / lesson.chapters.count.to_f * 100) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def progress\n total_steps_count = self.steps.count\n\n if total_steps_count.zero?\n 0.0\n else\n approved_steps_count = self.steps.where(state: 'approved').count\n (approved_steps_count * 100.0 / total_steps_count).round(2)\n end\n end", "def calc_progress\n p = 0.25\n unless s...
[ "0.771072", "0.7305538", "0.726116", "0.71067166", "0.70205104", "0.6955883", "0.69348335", "0.6862262", "0.6855532", "0.6753974", "0.6659185", "0.6659185", "0.6659185", "0.6652969", "0.6642433", "0.66372055", "0.6595403", "0.6595403", "0.6595403", "0.6595403", "0.6595403", ...
0.8135817
0
calculate if the lesson is completed
def completed_lesson?(lesson) chapters_completed.where(lesson: lesson).count == lesson.chapters.count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def completed?\n attributes['percentDone'] >= 1\n end", "def completed?\n completed\n end", "def completed?\n @completed\n end", "def completed?\n @completed\n end", "def completed?\n\t\t@completed\n\tend", "def completed?\n completed == '1'\n end", "def completed?\n...
[ "0.7369519", "0.73497653", "0.72654337", "0.72654337", "0.7237391", "0.7233562", "0.7189574", "0.71696645", "0.71528494", "0.71528375", "0.7105793", "0.7067047", "0.7036601", "0.69687784", "0.69624245", "0.69539607", "0.69492173", "0.6939414", "0.6907739", "0.6864672", "0.686...
0.7348603
2
set role to student prior to initial registration
def ensure_there_is_a_role if role.blank? self.role = "student" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_default_role\n self.role ||= :student\n end", "def set_default_role\n self.role ||= :student\n end", "def set_role\n return if role?\n\n self.role = 'regular'\n end", "def assign_role\n self.role = Role.find_by name: \"Regular\" if self.role.nil?\n end", "def set_initial_role\n ...
[ "0.76837623", "0.76837623", "0.7334064", "0.72828394", "0.7263591", "0.7050061", "0.70451283", "0.70170414", "0.694737", "0.6940768", "0.6921373", "0.692065", "0.691259", "0.691259", "0.691259", "0.6871036", "0.68561524", "0.685213", "0.68275684", "0.6790663", "0.6779628", ...
0.81538695
0
Display current user profile
def my_profile render json: { user: current_user} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def profile\n @user = @current_user\n\n render :show\n\n end", "def profile\n\t\t\n\t\tif !current_user\n\t\t\tredirect_to root_url and return\n\t\tend\n\t\t\n\t\t@user = current_user\n\t\t\n\tend", "def profile\n\t\t@user = User.find(current_user)\n\tend", "def profile\n\t@user = current_user\n\t@tit...
[ "0.8318606", "0.8191088", "0.81457615", "0.8071622", "0.79949397", "0.79619086", "0.7926748", "0.7895707", "0.7849802", "0.7718731", "0.7714287", "0.7606168", "0.75425965", "0.75332993", "0.7532596", "0.7421233", "0.7374534", "0.7367124", "0.73658246", "0.7352173", "0.7325948...
0.0
-1
Display the users profile
def show user = User.find_by(id: params[:id]) if user render json: {status: 200, user: user} else render json: {status: 500, message: user.errors.full_messages} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def profile\n @user = @current_user\n\n render :show\n\n end", "def show\n\n\t\t@current_profile = Profile.get_profile params[:id], \"asdf\"\n\n\t\tpretty_render \"api/public_user\"\t\n\n\tend", "def profile\n\t@user = current_user\n\t@title = \"This is your profile page\"\n end", "def show\n ...
[ "0.7887373", "0.7818151", "0.7782933", "0.7772873", "0.773372", "0.7582773", "0.75272965", "0.7511028", "0.7508242", "0.74860704", "0.74238795", "0.7387908", "0.7346951", "0.73407084", "0.7318082", "0.73044443", "0.7300331", "0.72889876", "0.72794", "0.72725403", "0.72640085"...
0.0
-1
Returns the current context for this thread, or nil if none exists.
def current all_contexts[Thread.current.object_id] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def context\n Thread.current[:ctx] ||= {}\n Thread.current[:ctx]\n end", "def thread_context\n Thread.current[:runshell_context] ||= Context.new(main_context.to_h)\n end", "def context\n Thread.current[NAME] ||= Hash.new\n end", "def context\n self.current_custom_context || ...
[ "0.7655154", "0.6975651", "0.6944315", "0.6748186", "0.6727816", "0.65430796", "0.6531631", "0.6488136", "0.6460435", "0.64238375", "0.63846403", "0.63006943", "0.62653214", "0.62554944", "0.62480384", "0.6219154", "0.6214809", "0.62039614", "0.6193466", "0.61918724", "0.6174...
0.76682615
0
Assigns a context instance to the current thread.
def current=(context) all_contexts[Thread.current.object_id] = context end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def local=(ctx)\n Thread.current[@key] = ctx\n end", "def thread_context\n Thread.current[:runshell_context] ||= Context.new(main_context.to_h)\n end", "def context\n Thread.current[:ctx] ||= {}\n Thread.current[:ctx]\n end", "def context=(ctx)\n @context.local = ctx\n end", ...
[ "0.68504316", "0.6741534", "0.6576933", "0.6523754", "0.64893126", "0.6470508", "0.63716793", "0.633284", "0.62927586", "0.62610793", "0.6169457", "0.61591464", "0.612363", "0.6121851", "0.6097193", "0.6097007", "0.6081057", "0.6069125", "0.60365206", "0.6027005", "0.6010464"...
0.67486894
1
Clears the assigned context for the current thread.
def clear_current all_contexts.delete(Thread.current.object_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_context\n @current_context = nil\n end", "def clear\n context.clear if Thread.current[NAME]\n self\n end", "def clear\n context.clear if Thread.current[NAME]\n self\n end", "def clear!\n context_manager.clear!\n end", "def reset_context\n @context = ni...
[ "0.8428168", "0.81905293", "0.81905293", "0.7738027", "0.7592086", "0.7390783", "0.7390783", "0.73234934", "0.7300959", "0.7300959", "0.72644985", "0.72190547", "0.72048604", "0.6845888", "0.67057955", "0.663552", "0.65859765", "0.63439965", "0.6276657", "0.621809", "0.603469...
0.821916
1
GET /steps GET /steps.json
def index @steps = Step.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n \n @steps = @quest.steps\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n end\n end", "def index\n @steps = Step.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps ...
[ "0.7637826", "0.71650946", "0.6820434", "0.67121947", "0.6697843", "0.66859204", "0.6614578", "0.6571187", "0.6571187", "0.6571187", "0.6489213", "0.6478076", "0.6385908", "0.63753617", "0.6344778", "0.6264669", "0.62381005", "0.62057096", "0.61792237", "0.61588967", "0.61372...
0.68370473
5
GET /steps/1 GET /steps/1.json
def show render :show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n \n @steps = @quest.steps\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n end\n end", "def show\n @step = Step.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render js...
[ "0.7460156", "0.7168968", "0.7168968", "0.7168968", "0.7037824", "0.6926366", "0.68012416", "0.6732481", "0.6719113", "0.6685765", "0.6685765", "0.6685765", "0.6685765", "0.6669708", "0.6632687", "0.6623837", "0.65953994", "0.65694636", "0.6544564", "0.6513855", "0.6479822", ...
0.0
-1
POST /steps POST /steps.json
def create @testcase = Testcase.find(params[:testcase_id]) @step = @testcase.steps.new(step_params) byebug if @step.save render :show, status: :created else render json: @step.errors, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @step = Step.new(step_params)\n\n respond_to do |format|\n if @step.save\n format.html { redirect_to api_v1_step_url(@step), notice: 'Step was successfully created.' }\n format.json { render :show, status: :created, location: @step }\n else\n ...
[ "0.727691", "0.71616596", "0.71529734", "0.70521736", "0.6979661", "0.69371253", "0.6862949", "0.6795791", "0.6771561", "0.67710626", "0.67408836", "0.6711147", "0.66153246", "0.6606931", "0.65982497", "0.657702", "0.6566822", "0.65651876", "0.65401566", "0.6530762", "0.64940...
0.66162527
12
PATCH/PUT /steps/1 PATCH/PUT /steps/1.json
def update if @step.update(step_params) render :show, status: :ok else render json: @step.errors, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @step = @guide.steps.find(params[:id])\n\n respond_to do |format|\n if @step.update_attributes(params[:step])\n format.html { redirect_to [@guide, @step], notice: 'Step was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac...
[ "0.71927685", "0.71523595", "0.7116217", "0.7104519", "0.7026183", "0.7013438", "0.6940124", "0.6940124", "0.6918359", "0.682918", "0.6745699", "0.67377734", "0.66899604", "0.66848296", "0.66759956", "0.6626989", "0.6592262", "0.65648484", "0.651355", "0.651099", "0.65043366"...
0.6908252
9
DELETE /steps/1 DELETE /steps/1.json
def destroy @step.destroy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @step = Step.find(params[:id])\n @step.destroy\n\n respond_to do |format|\n format.html { redirect_to steps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @step = Step.find(params[:id])\n @step.status = \"deleted\"\n @step.save!\n\n respond_...
[ "0.7910436", "0.78295755", "0.78116536", "0.7774464", "0.75964475", "0.7572063", "0.7572063", "0.7572063", "0.7572063", "0.742347", "0.74095196", "0.7402601", "0.7400754", "0.73675877", "0.7339873", "0.73136175", "0.73052126", "0.73025376", "0.7301966", "0.73009235", "0.72825...
0.71376354
33
Use callbacks to share common setup or constraints between actions.
def set_step @step = Step.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 step_params params.require(:step).permit(:number, :description, :locator, :skip, :testcase_id, :actionValue) 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
Part 0 cmd[0] : ip of currNode cmd[1] : ip of destNode cmd[2] : name of destNode
def edgeb_stdin(cmd) $record_ip[$hostname] = cmd[0] $record_ip[cmd[2]] = cmd[1] node = $node_info.new time = nil $lock.synchronize{ node.src = $hostname node.dst = cmd[2] node.cost = 1 node.nexthop = cmd[2] time = $clock.to_i $rt[cmd[2]] = node if $local_ip == nil then $local_ip = cmd[0] end $network.undir_connection($hostname, cmd[2], time, 1) } client = TCPSocket.open(cmd[1], $nodesFile[cmd[2]]["PORT"]) client.puts("EDGEB2 #{cmd[2]} #{$hostname} #{cmd[1]} #{time}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dest\n self[:ip_dest]\n end", "def dest_ip\n self[:dest_ip]\n end", "def edgeb_network(cmd)\n node = $node_info.new \n $lock.synchronize{\n \n node.src = $hostname\n node.dst = cmd[1]\n node.cost = 1\n node.nexthop = cmd[1]\n ...
[ "0.6213358", "0.5807358", "0.55782133", "0.5537308", "0.54837286", "0.5476828", "0.5357043", "0.53223133", "0.52930564", "0.528568", "0.528568", "0.52326375", "0.51781124", "0.51679504", "0.51147133", "0.51019484", "0.50953513", "0.50868034", "0.5041119", "0.50144404", "0.500...
0.5129832
14
cmd[0] : name of currNode cmd[1] : name of destNode cmd[2] : ip of currNode cmd[3] : time edge was made
def edgeb_network(cmd) node = $node_info.new $lock.synchronize{ node.src = $hostname node.dst = cmd[1] node.cost = 1 node.nexthop = cmd[1] $rt[cmd[1]] = node if $local_ip == nil then $local_ip = cmd[2] end $network.undir_connection($hostname, cmd[1], cmd[3].to_i, 1) } #puts "THIS IS THE ROUTING TABLE: #{$rt}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edgeu(cmd)\n $dist[cmd[0]] = cmd[1].to_i\n $neighbors[cmd[0]] = cmd[1].to_i\n client = $clients[cmd[0]]\n msg = Msg.new\n msg.setConfig(\"type\", 2)\n msg.setMessage($hostname + \" \" + cmd[1].to_i.to_s)\n sendMessage(client, msg)\n fillInNodes()\nend", "def edgeu(cmd)\n time = nil\n $lock.sync...
[ "0.6386743", "0.6305659", "0.6026351", "0.60089004", "0.5930569", "0.57697797", "0.56592053", "0.5602687", "0.5590002", "0.55648386", "0.55371714", "0.5525014", "0.545143", "0.5281572", "0.5271316", "0.5220897", "0.5171023", "0.516839", "0.5148021", "0.5145073", "0.5144903", ...
0.6612269
0
Part 1 Dest of node to remove edge from
def edged(cmd) $lock.synchronize{ $network.remove_edge($hostname,cmd[0]) if $rt.has_key? cmd[0] $rt.delete cmd[0] end } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_edge(id1, id2)\n # YOUR WORK HERE\n end", "def delete_edge!(from, to)\n protected_delete_edge!(from, to)\n protected_delete_edge!(to, from)\n @edge_number -= 1\n end", "def remove_edge(from, to)\n\t\t\t@size -= 1 if disconnect(from, to)\n\t\t\tself\n\t\tend", "def del...
[ "0.71168524", "0.7091838", "0.70847076", "0.7054624", "0.70041543", "0.6983194", "0.69370836", "0.6833785", "0.669455", "0.64881223", "0.6478261", "0.64762974", "0.64500105", "0.640798", "0.63919973", "0.63730836", "0.6360826", "0.6359386", "0.6342667", "0.6341068", "0.632237...
0.54720014
72
cmd[0] : DEST cmd[1] : COST
def edgeu(cmd) time = nil $lock.synchronize{ time = $clock.to_i $network.update_cost($hostname, cmd[0], cmd[1].to_i, time) if $rt.has_key? cmd[0] $rt[cmd[0]][:cost] = cmd[1].to_i end } client = TCPSocket.open($local_ip, $nodesFile[cmd[0]]["PORT"]) client.puts("EDGEU2 #{$hostname} #{cmd[1]} #{time}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edgeu_network(cmd)\n $lock.synchronize{\n $network.update_cost($hostname, cmd[0], cmd[1].to_i,cmd[2].to_i)\n \n if $rt.has_key? cmd[0]\n $rt[cmd[0]][:cost] = cmd[1].to_i\n end\n }\nend", "def command(cmd, arg = 2)\n return if @sp == nil\n #<SOT><CMD_BYTE><...
[ "0.58614534", "0.56380147", "0.55545676", "0.5505499", "0.5289272", "0.52743083", "0.5253263", "0.52382857", "0.5230898", "0.5194175", "0.5187378", "0.51801586", "0.5164179", "0.51584613", "0.51559526", "0.51432997", "0.51432997", "0.5137132", "0.5135012", "0.512023", "0.5099...
0.61732787
0
cmd[0] : DEST cmd[1] : COST cmd[2] : Time of updated edge
def edgeu_network(cmd) $lock.synchronize{ $network.update_cost($hostname, cmd[0], cmd[1].to_i,cmd[2].to_i) if $rt.has_key? cmd[0] $rt[cmd[0]][:cost] = cmd[1].to_i end } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edgeu(cmd)\n time = nil\n $lock.synchronize{\n time = $clock.to_i\n $network.update_cost($hostname, cmd[0], cmd[1].to_i, time)\n\n if $rt.has_key? cmd[0]\n $rt[cmd[0]][:cost] = cmd[1].to_i\n end\n } \n\n client = TCPSocket.open($local_ip, $nodesFile[cmd[0]][\"P...
[ "0.75870264", "0.678527", "0.6460501", "0.61730546", "0.6092415", "0.58193505", "0.57349604", "0.55861866", "0.55764824", "0.5494816", "0.537581", "0.529418", "0.529418", "0.529418", "0.5195012", "0.51921046", "0.5174208", "0.5133308", "0.5125066", "0.5058883", "0.5056944", ...
0.714894
1
do main loop here....
def main() while(line = STDIN.gets()) line = line.strip() arr = line.split(' ') cmd = arr[0] args = arr[1..-1] case cmd when "EDGEB"; edgeb_stdin(args) when "EDGED"; edged(args) when "EDGEU"; edgeu(args) when "DUMPTABLE"; dumptable(args) when "SHUTDOWN"; shutdown(args) when "STATUS"; status() when "SENDMSG"; sendmsg(arr) when "PING"; ping(args) when "TRACEROUTE"; traceroute(arr) when "FTP"; ftp(arr) when "CIRCUITB"; circuitb(args) when "CIRCUITM"; circuitm(arr) when "CIRCUITD"; circuitd(args) else STDERR.puts "ERROR: INVALID COMMAND \"#{cmd}\"" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loop; end", "def loop\n end", "def loop\n end", "def loop\n end", "def run_loop\n end", "def post_loop; end", "def loop_forever; end", "def pre_loop; end", "def postloop\n end", "def preloop\n end", "def parentloop; end", "def main_loop\n @main_loop ||= lambda do\n # S...
[ "0.8564647", "0.8516369", "0.8516369", "0.84616023", "0.82521206", "0.8024656", "0.7735339", "0.7631197", "0.7602355", "0.7532698", "0.7404509", "0.73160857", "0.7300256", "0.7291489", "0.72511065", "0.72511065", "0.72511065", "0.7250268", "0.7250268", "0.72476906", "0.724659...
0.0
-1
cmd[0] Flood message sent from probably don't need but can be used for debugging cmd[1] name of srcNode cmd[2] name of destNode cmd[3] cost of edge cmd[4] time of Edge Shift or delete cmd[1],cmd[2], cmd[3], cmd[4] to get the next edge src,edge dest and edge time USE $rt to check if we need to change graph. will reduce the runtime These are strings so remember to change to integers to_i Use dijkstras for next hop in $rt
def updateTable(cmd) # puts "TRYING TO UPDATE TABLE" sentFrom = cmd.shift curr_edge_time = nil new_edge_time = nil new_edge_cost = nil node = $node_info.new arr = nil hops = nil lis = nil loop{ new_edge_time = cmd[3].to_i new_edge_cost = cmd[2].to_i $lock.synchronize{ curr_edge_time = $network.get_time(cmd[0],cmd[1]) } if curr_edge_time == 0 #name of srcNode,name of destNode,cost of edge,time of Edge $lock.synchronize{ $network.undir_connection(cmd[0], cmd[1], new_edge_time, new_edge_cost) } if ($rt.has_key?(cmd[0]) != true) node.src = $hostname node.dst = cmd[0] node.cost = nil #do dijsktras node.nexthop = nil #do dijsktras $lock.synchronize{ $rt[cmd[0]] = node } end if($rt.has_key?(cmd[1]) != true) node.src = $hostname node.dst = cmd[1] node.cost = nil #do dijsktras node.nexthop = nil #do dijsktras $lock.synchronize{ $rt[cmd[1]] = node } end elsif curr_edge_time < new_edge_time $lock.synchronize{ $network.update_cost(cmd[0], cmd[1], new_edge_time, new_edge_cost) } end cmd.shift(4) break if cmd.length < 4 # puts "ABOUT TO RUN DIJKSTRAS" $lock.synchronize{ arr = $network.dijkstra($hostname) } $full_path = arr[0] #puts "THIS IS THE RETURN OF DIJKSTRAS #{arr}" $lock.synchronize{ $rt.each_key {|key| update = $node_info.new # puts "Key IS #{key}" hops = arr[0] lis = arr[1] prevs = hops[key] update.src = $hostname update.dst = key update.cost = lis[key] update.nexthop = prevs[1] $rt[key] = update # puts "ROUTING TABLE #{$rt}" } } } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edgeu(cmd)\n $dist[cmd[0]] = cmd[1].to_i\n $neighbors[cmd[0]] = cmd[1].to_i\n client = $clients[cmd[0]]\n msg = Msg.new\n msg.setConfig(\"type\", 2)\n msg.setMessage($hostname + \" \" + cmd[1].to_i.to_s)\n sendMessage(client, msg)\n fillInNodes()\nend", "def edgeu(cmd)\n time = nil\n $lock.sync...
[ "0.6579866", "0.63999313", "0.62158346", "0.60665673", "0.5780086", "0.5779895", "0.5770335", "0.56623864", "0.555246", "0.5360149", "0.529686", "0.5241645", "0.5213028", "0.51927036", "0.51253843", "0.51174945", "0.50856936", "0.5031403", "0.5015003", "0.49930185", "0.494991...
0.5981413
4
A thread that handles all incoming connections
def serverHandling() loop { #puts "ServerHandling thread: #{Thread.current}" thread = Thread.start($serv.accept) do |client| message = client.gets.chomp arr = message.split(' ') server_cmd = arr[0] args = arr[1..-1] # if server_cmd != "UPDATE" then puts "THIS IS THE MESSAGE: #{message}" end case server_cmd when "EDGEB2"; edgeb_network(args) when "EDGEU2"; edgeu_network(args) when "UPDATE"; updateTable(args) when "TOSOURCE"; source_console(args) when "PING"; ping_network(args) when "FORWARD"; forward_packet(args) when "SEND"; packet_forward(args) when "SEND2"; file_forward(args) when "SUCCESS"; transfer_success(args) when "CIRCUITB2"; circuitb_network(args) else STDERR.puts "ERROR: INVALID COMMAND \"#{server_cmd}\"" end client.close end } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run\n loop do\n memcached = Memcached.new # each client has its oun cache storage\n new_client = @tcp_Server.accept # when a new client connects to the server\n client_handler_id = rand(999999).to_s\n client_handler = ClientHandler.new(id: client_handler_id, clientSocket: new_client, mem...
[ "0.74341583", "0.7157197", "0.7110875", "0.70952433", "0.7015998", "0.6843977", "0.6842806", "0.683896", "0.682579", "0.6790225", "0.6780209", "0.67702806", "0.67486066", "0.67424226", "0.6728888", "0.6696061", "0.6688816", "0.668869", "0.66851056", "0.6674531", "0.66651124",...
0.618364
79
GET /liners GET /liners.json
def index @liners = Liner.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @trainer = Trainer.find(params[:id])\n\n render json: @trainer.as_json(only: [:name], include: [:trainees])\n end", "def index\n @litters = Litter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @litters }\n end\n end", "def index...
[ "0.6039168", "0.58767325", "0.58016515", "0.57443225", "0.57294405", "0.5728215", "0.5728215", "0.5728215", "0.5728215", "0.5711922", "0.5696984", "0.5663344", "0.5617804", "0.5560731", "0.5555264", "0.55024165", "0.5497077", "0.5494845", "0.5459527", "0.5457283", "0.5456509"...
0.704166
0
GET /liners/1 GET /liners/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @liners = Liner.all\n end", "def show\n @trainer = Trainer.find(params[:id])\n\n render json: @trainer.as_json(only: [:name], include: [:trainees])\n end", "def show\n @line = Line.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { ...
[ "0.6836065", "0.6083431", "0.58974695", "0.57809585", "0.5733845", "0.5717326", "0.56469184", "0.56080073", "0.55987537", "0.5595026", "0.5595026", "0.5595026", "0.5595026", "0.55837494", "0.55795395", "0.5577129", "0.55625665", "0.55320835", "0.55211914", "0.5517878", "0.547...
0.0
-1
POST /liners POST /liners.json
def create company_name = params[:liner][:company_name] company = Company.find_or_create_by name: company_name @liner = company.liners.new(liner_params) respond_to do |format| if @liner.save format.html { redirect_to @liner, notice: 'Liner was successfully created.' } format.json { render :show, status: :created, location: @liner } else format.html { render :new } format.json { render json: @liner.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n p'*'*800\n p params\n\n @trainer = Trainer.new(trainer_params)\n\n p @trainer\n\n if @trainer.save\n render json: @trainer, status: :created, location: @trainer\n else\n render json: @trainer.errors, status: :unprocessable_entity\n end\n end", "def create\n @line_l...
[ "0.6214964", "0.5854367", "0.5851985", "0.5804397", "0.57401246", "0.5656456", "0.5631725", "0.5631725", "0.55973405", "0.54875636", "0.54869634", "0.54577047", "0.54260683", "0.5419705", "0.541122", "0.54039025", "0.53778136", "0.53751636", "0.5367665", "0.5345483", "0.53257...
0.64722174
0
PATCH/PUT /liners/1 PATCH/PUT /liners/1.json
def update respond_to do |format| liner = Liner.find_by(liner_reference: liner_params["liner_reference"]) original_thickness = liner.original_thickness.to_i current_thickness = liner_params["current_thickness"].to_i thickness_loss_per_day = original_thickness - current_thickness liner_params["thickness_loss_per_day"] = thickness_loss_per_day if @liner.update(liner_params) format.html { redirect_to @liner, notice: 'Liner was successfully updated.' } format.json { render :show, status: :ok, location: @liner } else format.html { render :edit } format.json { render json: @liner.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch!\n request! :patch\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def update\n @line = Line....
[ "0.63021463", "0.6240131", "0.62213457", "0.6167319", "0.6144966", "0.61180913", "0.60936266", "0.60936266", "0.60729194", "0.6064583", "0.6004544", "0.5993123", "0.5982784", "0.59353393", "0.59270674", "0.5896436", "0.58894765", "0.5865916", "0.5860658", "0.5841712", "0.5834...
0.6334987
0
DELETE /liners/1 DELETE /liners/1.json
def destroy @liner.destroy respond_to do |format| format.html { redirect_to liners_url, notice: 'Liner was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @line = Line.find(params[:id])\n @line.destroy\n\n respond_to do |format|\n format.html { redirect_to new_line_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @line_item1 = LineItem1.find(params[:id])\n @line_item1.destroy\n\n respond_to do |fo...
[ "0.6721495", "0.6701221", "0.66580856", "0.6639705", "0.65312654", "0.6512321", "0.64748347", "0.6471383", "0.64278835", "0.64278835", "0.6427347", "0.64245266", "0.64131874", "0.64053595", "0.6404969", "0.6404969", "0.6404969", "0.6404969", "0.63895476", "0.63891643", "0.635...
0.71730655
0
Use callbacks to share common setup or constraints between actions.
def set_liner @liner = Liner.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 liner_params puts(params) params.require(:liner).permit(:new_liner_reference, :previous_liner_reference, :liner_reference, :location, :row, :collumn, :structure, :plant, :width, :height, :thickness, :original_thickness, :thickness_loss_per_day, :current_thickness) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6980957", "0.6783065", "0.6747844", "0.6741468", "0.67356336", "0.6592548", "0.65036845", "0.64978707", "0.64825076", "0.64795035", "0.64560914", "0.64397955", "0.6379666", "0.6376688", "0.6366702", "0.6319728", "0.6300833", "0.6300629", "0.6294277", "0.6293905", "0.629117...
0.0
-1
Convert an image of text into a binarized (light and dark) view Perform an adaptive binarization algorithm on the input image to prepare it for further OCR operations.
def preprocessing_binarize(image_file, opts = {}) data, _status_code, _headers = preprocessing_binarize_with_http_info(image_file, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preprocessing_binarize_advanced(image_file, opts = {})\n data, _status_code, _headers = preprocessing_binarize_advanced_with_http_info(image_file, opts)\n data\n end", "def binarize id\n m_begin \"binarize\"\n put_image(id, get_image(id).bilevel_channel(QuantumRange/2))\n# put_image(id, ...
[ "0.59254843", "0.57710195", "0.5659876", "0.5643329", "0.55341864", "0.5517297", "0.5444709", "0.5424364", "0.53248155", "0.52780914", "0.52743953", "0.5258123", "0.52495515", "0.5228497", "0.52118057", "0.52086914", "0.5180699", "0.5142263", "0.51032317", "0.51001775", "0.50...
0.55367297
4
Convert an image of text into a binarized (light and dark) view Perform an adaptive binarization algorithm on the input image to prepare it for further OCR operations.
def preprocessing_binarize_with_http_info(image_file, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PreprocessingApi.preprocessing_binarize ...' end # verify the required parameter 'image_file' is set if @api_client.config.client_side_validation && image_file.nil? fail ArgumentError, "Missing the required parameter 'image_file' when calling PreprocessingApi.preprocessing_binarize" end # resource path local_var_path = '/ocr/preprocessing/image/binarize' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) # form parameters form_params = {} form_params['imageFile'] = image_file # http body (model) post_body = nil auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'String') if @api_client.config.debugging @api_client.config.logger.debug "API called: PreprocessingApi#preprocessing_binarize\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preprocessing_binarize_advanced(image_file, opts = {})\n data, _status_code, _headers = preprocessing_binarize_advanced_with_http_info(image_file, opts)\n data\n end", "def binarize id\n m_begin \"binarize\"\n put_image(id, get_image(id).bilevel_channel(QuantumRange/2))\n# put_image(id, ...
[ "0.59265715", "0.5771552", "0.5659796", "0.5642477", "0.5538126", "0.55338806", "0.55168307", "0.54437375", "0.5421915", "0.5322964", "0.52762336", "0.52564114", "0.5248734", "0.5228602", "0.52128536", "0.5208213", "0.51808894", "0.51410204", "0.5101911", "0.5099944", "0.5076...
0.52756774
11
Convert an image of text into a binary (light and dark) view with ML Perform an advanced adaptive, Deep Learningbased binarization algorithm on the input image to prepare it for further OCR operations. Provides enhanced accuracy than adaptive binarization. Image will be upsampled to 300 DPI if it has a DPI below 300.
def preprocessing_binarize_advanced(image_file, opts = {}) data, _status_code, _headers = preprocessing_binarize_advanced_with_http_info(image_file, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recognize(image)\n # quantize to two-color\n image = quantize_image(image)\n\n # the binary string we expect to see from the output nodes\n assign_inputs image\n\n calculate_hidden_outputs\n calculate_final_outputs\n\n #@output_values.each.with_index { |v, i| puts \"index: #{...
[ "0.625005", "0.5837121", "0.57955396", "0.56946397", "0.56144047", "0.55855155", "0.5580679", "0.55004734", "0.54777443", "0.54315495", "0.5407322", "0.5384784", "0.53844863", "0.5331769", "0.530962", "0.5291183", "0.5279446", "0.5228138", "0.5177895", "0.51711464", "0.515119...
0.5202608
18
Convert an image of text into a binary (light and dark) view with ML Perform an advanced adaptive, Deep Learningbased binarization algorithm on the input image to prepare it for further OCR operations. Provides enhanced accuracy than adaptive binarization. Image will be upsampled to 300 DPI if it has a DPI below 300.
def preprocessing_binarize_advanced_with_http_info(image_file, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PreprocessingApi.preprocessing_binarize_advanced ...' end # verify the required parameter 'image_file' is set if @api_client.config.client_side_validation && image_file.nil? fail ArgumentError, "Missing the required parameter 'image_file' when calling PreprocessingApi.preprocessing_binarize_advanced" end # resource path local_var_path = '/ocr/preprocessing/image/binarize/advanced' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) # form parameters form_params = {} form_params['imageFile'] = image_file # http body (model) post_body = nil auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'String') if @api_client.config.debugging @api_client.config.logger.debug "API called: PreprocessingApi#preprocessing_binarize_advanced\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recognize(image)\n # quantize to two-color\n image = quantize_image(image)\n\n # the binary string we expect to see from the output nodes\n assign_inputs image\n\n calculate_hidden_outputs\n calculate_final_outputs\n\n #@output_values.each.with_index { |v, i| puts \"index: #{...
[ "0.6249741", "0.58387315", "0.5795003", "0.56958514", "0.56134284", "0.558428", "0.5581397", "0.5499139", "0.54791594", "0.54326797", "0.5406956", "0.53870916", "0.5385192", "0.53341883", "0.5310227", "0.529243", "0.5280662", "0.52283746", "0.5201758", "0.51803356", "0.517122...
0.49927145
31
Get the angle of the page / document / receipt Analyzes a photo or image of a document and identifies the rotation angle of the page.
def preprocessing_get_page_angle(image_file, opts = {}) data, _status_code, _headers = preprocessing_get_page_angle_with_http_info(image_file, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def angle\n @angle\n end", "def angle()\n a, c = @view__.angle, @context__\n c ? c.fromDegrees__(a) : a * Processing::GraphicsContext::DEG2RAD__\n end", "def angle(path)\n io_for(path).angle\n end", "def angle\r\n self.data.map(&:angle)\r\n end", "def angle\n Math....
[ "0.6770511", "0.6355038", "0.63267356", "0.61359376", "0.59200954", "0.5912687", "0.58901113", "0.5869649", "0.5843366", "0.5825865", "0.5711544", "0.56564385", "0.5617053", "0.5522956", "0.54968333", "0.5480202", "0.54528534", "0.53941053", "0.5391114", "0.53884804", "0.5365...
0.6324517
3
Get the angle of the page / document / receipt Analyzes a photo or image of a document and identifies the rotation angle of the page.
def preprocessing_get_page_angle_with_http_info(image_file, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PreprocessingApi.preprocessing_get_page_angle ...' end # verify the required parameter 'image_file' is set if @api_client.config.client_side_validation && image_file.nil? fail ArgumentError, "Missing the required parameter 'image_file' when calling PreprocessingApi.preprocessing_get_page_angle" end # resource path local_var_path = '/ocr/preprocessing/image/get-page-angle' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) # form parameters form_params = {} form_params['imageFile'] = image_file # http body (model) post_body = nil auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'GetPageAngleResult') if @api_client.config.debugging @api_client.config.logger.debug "API called: PreprocessingApi#preprocessing_get_page_angle\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def angle\n @angle\n end", "def angle()\n a, c = @view__.angle, @context__\n c ? c.fromDegrees__(a) : a * Processing::GraphicsContext::DEG2RAD__\n end", "def angle(path)\n io_for(path).angle\n end", "def preprocessing_get_page_angle(image_file, opts = {})\n data, _status_cod...
[ "0.6768921", "0.63535494", "0.6324994", "0.6323119", "0.61341214", "0.5917737", "0.5910855", "0.5867298", "0.58424896", "0.58236796", "0.5709026", "0.5654838", "0.5614643", "0.55210483", "0.5494646", "0.54773164", "0.5451332", "0.53925353", "0.53895533", "0.53867155", "0.5365...
0.58898544
7
Detect and unrotate a document image Detect and unrotate an image of a document (e.g. that was scanned at an angle). Great for document scanning applications; once unskewed, this image is perfect for converting to PDF using the Convert API or optical character recognition using the OCR API.
def preprocessing_unrotate(image_file, opts = {}) data, _status_code, _headers = preprocessing_unrotate_with_http_info(image_file, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recognize_detect_and_unskew_document(image_file, opts = {})\n data, _status_code, _headers = recognize_detect_and_unskew_document_with_http_info(image_file, opts)\n data\n end", "def deskew_angle(img)\n temp = Tempfile.new 'split-subjects-vertically'\n sample = img.clone\n # inset crop 10% fr...
[ "0.65515685", "0.57661265", "0.57574654", "0.5617368", "0.561659", "0.54309416", "0.54123574", "0.5409436", "0.53968537", "0.526657", "0.52456695", "0.52381593", "0.51836926", "0.5181587", "0.5152635", "0.5125302", "0.51029867", "0.50686276", "0.5058208", "0.5053604", "0.5046...
0.52896756
9
Detect and unrotate a document image Detect and unrotate an image of a document (e.g. that was scanned at an angle). Great for document scanning applications; once unskewed, this image is perfect for converting to PDF using the Convert API or optical character recognition using the OCR API.
def preprocessing_unrotate_with_http_info(image_file, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PreprocessingApi.preprocessing_unrotate ...' end # verify the required parameter 'image_file' is set if @api_client.config.client_side_validation && image_file.nil? fail ArgumentError, "Missing the required parameter 'image_file' when calling PreprocessingApi.preprocessing_unrotate" end # resource path local_var_path = '/ocr/preprocessing/image/unrotate' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) # form parameters form_params = {} form_params['imageFile'] = image_file # http body (model) post_body = nil auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'String') if @api_client.config.debugging @api_client.config.logger.debug "API called: PreprocessingApi#preprocessing_unrotate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recognize_detect_and_unskew_document(image_file, opts = {})\n data, _status_code, _headers = recognize_detect_and_unskew_document_with_http_info(image_file, opts)\n data\n end", "def deskew_angle(img)\n temp = Tempfile.new 'split-subjects-vertically'\n sample = img.clone\n # inset crop 10% fr...
[ "0.6553658", "0.57664627", "0.5758398", "0.56170475", "0.56168735", "0.54295", "0.54106456", "0.5407409", "0.5397315", "0.5290326", "0.52672964", "0.5245596", "0.5235849", "0.5181416", "0.51793104", "0.5151516", "0.5123107", "0.51022315", "0.5069915", "0.5056831", "0.5054204"...
0.49868545
26
Detect and unrotate a document image (advanced) Detect and unrotate an image of a document (e.g. that was scanned at an angle) using deep learning. Great for document scanning applications; once unskewed, this image is perfect for converting to PDF using the Convert API or optical character recognition using the OCR API.
def preprocessing_unrotate_advanced(image_file, opts = {}) data, _status_code, _headers = preprocessing_unrotate_advanced_with_http_info(image_file, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recognize_detect_and_unskew_document(image_file, opts = {})\n data, _status_code, _headers = recognize_detect_and_unskew_document_with_http_info(image_file, opts)\n data\n end", "def recognize_detect_and_unskew_document_with_http_info(image_file, opts = {})\n if @api_client.config.debugging...
[ "0.6634254", "0.61188626", "0.56217086", "0.5557502", "0.5505193", "0.54923713", "0.5489433", "0.54034656", "0.5369795", "0.5303366", "0.52833045", "0.52772856", "0.5215921", "0.5203122", "0.5158877", "0.5149264", "0.5148406", "0.51152325", "0.50803614", "0.5076563", "0.50739...
0.51618785
14
Detect and unrotate a document image (advanced) Detect and unrotate an image of a document (e.g. that was scanned at an angle) using deep learning. Great for document scanning applications; once unskewed, this image is perfect for converting to PDF using the Convert API or optical character recognition using the OCR API.
def preprocessing_unrotate_advanced_with_http_info(image_file, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PreprocessingApi.preprocessing_unrotate_advanced ...' end # verify the required parameter 'image_file' is set if @api_client.config.client_side_validation && image_file.nil? fail ArgumentError, "Missing the required parameter 'image_file' when calling PreprocessingApi.preprocessing_unrotate_advanced" end # resource path local_var_path = '/ocr/preprocessing/image/unrotate/advanced' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) # form parameters form_params = {} form_params['imageFile'] = image_file # http body (model) post_body = nil auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'String') if @api_client.config.debugging @api_client.config.logger.debug "API called: PreprocessingApi#preprocessing_unrotate_advanced\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recognize_detect_and_unskew_document(image_file, opts = {})\n data, _status_code, _headers = recognize_detect_and_unskew_document_with_http_info(image_file, opts)\n data\n end", "def recognize_detect_and_unskew_document_with_http_info(image_file, opts = {})\n if @api_client.config.debugging...
[ "0.6633301", "0.61185", "0.5620179", "0.55576986", "0.5506062", "0.5493298", "0.5488623", "0.5403662", "0.53708833", "0.53043514", "0.5281883", "0.52762115", "0.5215337", "0.5203908", "0.51616627", "0.51587886", "0.5149557", "0.5148939", "0.5114118", "0.5080157", "0.507535", ...
0.48440546
37
Detect and unskew a photo of a document Detect and unskew a photo of a document (e.g. taken on a cell phone) into a perfectly square image. Great for document scanning applications; once unskewed, this image is perfect for converting to PDF using the Convert API or optical character recognition using the OCR API.
def preprocessing_unskew(image_file, opts = {}) data, _status_code, _headers = preprocessing_unskew_with_http_info(image_file, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recognize_detect_and_unskew_document(image_file, opts = {})\n data, _status_code, _headers = recognize_detect_and_unskew_document_with_http_info(image_file, opts)\n data\n end", "def recognize_detect_and_unskew_document_with_http_info(image_file, opts = {})\n if @api_client.config.debugging...
[ "0.6463487", "0.596406", "0.5716911", "0.5609173", "0.5600361", "0.55608743", "0.55219686", "0.5446535", "0.53948486", "0.52019495", "0.5163967", "0.5124965", "0.51209027", "0.50989497", "0.5086853", "0.50702876", "0.4986477", "0.49540937", "0.49487537", "0.49201196", "0.4886...
0.51649195
10
Detect and unskew a photo of a document Detect and unskew a photo of a document (e.g. taken on a cell phone) into a perfectly square image. Great for document scanning applications; once unskewed, this image is perfect for converting to PDF using the Convert API or optical character recognition using the OCR API.
def preprocessing_unskew_with_http_info(image_file, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PreprocessingApi.preprocessing_unskew ...' end # verify the required parameter 'image_file' is set if @api_client.config.client_side_validation && image_file.nil? fail ArgumentError, "Missing the required parameter 'image_file' when calling PreprocessingApi.preprocessing_unskew" end # resource path local_var_path = '/ocr/preprocessing/image/unskew' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) # form parameters form_params = {} form_params['imageFile'] = image_file # http body (model) post_body = nil auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'String') if @api_client.config.debugging @api_client.config.logger.debug "API called: PreprocessingApi#preprocessing_unskew\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recognize_detect_and_unskew_document(image_file, opts = {})\n data, _status_code, _headers = recognize_detect_and_unskew_document_with_http_info(image_file, opts)\n data\n end", "def recognize_detect_and_unskew_document_with_http_info(image_file, opts = {})\n if @api_client.config.debugging...
[ "0.64648074", "0.5964211", "0.5717935", "0.5609446", "0.56007886", "0.5557735", "0.5518511", "0.5445434", "0.5391624", "0.5199129", "0.51659375", "0.5163276", "0.51233906", "0.51185113", "0.5097995", "0.50681937", "0.49847692", "0.49519026", "0.49463594", "0.49191478", "0.488...
0.508696
15
Tabulation Min cost for a stair is the min for either of the last 2, plus itself O(N) time, O(N) space (table)
def min_cost_climbing_stairs(cost) cost = cost + [0] table = Array.new(cost.length) { nil } table[0] = cost[0] table[1] = cost[1] table.each_with_index do |_val, i| next if i < 2 table[i] = [table[i-1], table[i-2]].min table[i] += cost[i] end table.last end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min_cost(stairs)\n min_step_cost = [stairs[0], stairs[1]]\n idx = 2\n while idx < stairs.length\n min_step_cost[idx] = stairs[idx] + [min_step_cost[idx - 1], min_step_cost[idx - 2]].min\n idx += 1\n end\n p min_step_cost\n [min_step_cost[-2], min_step_cost[-1]].min\nend", "def min_cost_climbing_s...
[ "0.7375758", "0.73328644", "0.7282645", "0.7211329", "0.71643794", "0.70403475", "0.69406575", "0.6725482", "0.66565967", "0.65938365", "0.6552746", "0.6501378", "0.6259403", "0.6194432", "0.61776084", "0.6142893", "0.6129097", "0.61223733", "0.6067645", "0.6051536", "0.60426...
0.8278453
0
Tabulation with space optimization O(N) time, O(1) space
def min_cost_climbing_stairs(cost) cost = cost + [0] last = cost[1] last_last = cost[0] cost[2..-1].each do |cost| new_cost = cost + [last, last_last].min last_last = last last = new_cost end last end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def table\n words.scan\n bigrams.scan\n\n list = words.top_weighted(max)\n\n if sort\n list = list.sort_by{ |w| w.to_s }\n end\n\n index = {}\n list.each_with_index do |w, i|\n index[w.spelling] = i\n end\n\n tbl = []\n\n list....
[ "0.61604905", "0.61149704", "0.596614", "0.5892388", "0.58655864", "0.58407664", "0.5838778", "0.5828102", "0.5818131", "0.57730997", "0.5750076", "0.5703398", "0.5667486", "0.5655089", "0.56133693", "0.5580554", "0.5569902", "0.55595005", "0.55564255", "0.55481046", "0.55347...
0.0
-1
this part between def and end is called a method
def play_paper @computer_move = ["rock","paper","scissors"].sample if @computer_move == "paper" @outcome = "tie" elsif @computer_move == "scissors" @outcome = "lose" else @outcome = "win" end render("games/play_paper.html.erb") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def end; end", "def end; end", "def end; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def end_p...
[ "0.7925137", "0.7925137", "0.7925137", "0.7761054", "0.7761054", "0.7761054", "0.7761054", "0.7761054", "0.7761054", "0.7761054", "0.7761054", "0.7761054", "0.7761054", "0.7761054", "0.7761054", "0.7673119", "0.754368", "0.75311446", "0.75311446", "0.75311446", "0.75311446", ...
0.0
-1
Public: Build a list of 'file' objects (same as used when showing the loglist(s)) and return the items that are related to the current post (specified by the 'title' parameter). Params: title Title of article to compare with filelist to find current. pre Boolean indicating whether this is a finished or workinprogress (pre) log entry. Determines different filelist to process. Returns an array of hashes with a predetermined maximum length
def related_logs(title, pre=false) logs = begin if pre with_cache('log-pre-file-list') { log_list(LOG_PRE_META[:path], LOG_PRE_META[:regex], pre) } else with_cache('log-file-list') { log_list(LOG_META[:path], LOG_META[:regex]) } end end related_files = [] curr_file = logs.select{|l| l[:name] == title}.first logs.delete(curr_file) top_logs = logs.select{|l| l[:date] > curr_file[:date]}.reverse if curr_file top_logs.each do |l| related_files << l if related_files.count < 3 && title != l[:name] end else related_files = logs.take(3) end if related_files.count < 3 related_files.concat(logs.take(3 - related_files.count)).uniq! end related_files.sort{|a,b| b[:date] <=> a[:date]} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_by_title(title)\n if title.is_a?(Array)\n return self.root_collection.file_by_title(title)\n else\n return files(\"q\" => [\"title = ?\", title], \"maxResults\" => 1)[0]\n end\n end", "def formatted_file_list(title, source_files); end", "def list...
[ "0.5901373", "0.54093146", "0.53490376", "0.51821136", "0.5099016", "0.50472564", "0.5040822", "0.5007242", "0.5007242", "0.48155662", "0.48111278", "0.4796713", "0.47855008", "0.47633484", "0.47456014", "0.47180527", "0.46884465", "0.46787164", "0.46664047", "0.4666243", "0....
0.73172647
0
Feel free to google "how to generate a random number in ruby"
def roll randomValue = rand(6)+1 randomValue end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_number\r\n return randomNumber = 1 + rand(100)\r\n end", "def get_random_number()\n rand(0x7fffffff).to_s\nend", "def gen_num\n rand(1..100)\nend", "def random_number\n t = Time.now.to_f / (Time.now.to_f % Time.now.to_i)\n random_seed = t * 1103515245 + 12345;\n (random_seed / 655...
[ "0.8495249", "0.83665675", "0.8312836", "0.8223235", "0.8188632", "0.81023866", "0.8082494", "0.80452955", "0.80336106", "0.8030636", "0.8030636", "0.80123246", "0.79662156", "0.7955537", "0.7934739", "0.7909762", "0.78774667", "0.78719956", "0.78630906", "0.78546405", "0.781...
0.0
-1
return an HTML form for creating a new user
def new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n\t@user = User.new\n\t@title = \"Sign up\"\n end", "def new\n\t@title = \"Sign Up\"\n\t@user = User.new\n end", "def new\n\t\tmissing unless WAYGROUND['ALLOW_SIGNUP']\n\t\t@user = User.new(params[:user])\n\t\t@user.time_zone = Time.zone.name unless params[:user]\n\t\t@user.valid? if params[:user]\n\...
[ "0.7706145", "0.7576483", "0.74910504", "0.74815553", "0.7411804", "0.73993486", "0.73825485", "0.7295869", "0.72639287", "0.7241989", "0.7207495", "0.7204781", "0.7203938", "0.72020185", "0.7193657", "0.71522295", "0.71294606", "0.7122919", "0.7086613", "0.70711076", "0.7056...
0.0
-1
Hit this endpoint as soon as user logs in If user is already in the database, redirect to team page, otherwise go to edit page
def login_check if not is_logged_in session # should never get in here redirect_to :action => :index end sunet = session[:user_hash]["username"] if User.find_by_sunet(sunet) redirect_to :action => :index else # create new user gn = session[:user_hash]["gn"] || "" sn = session[:user_hash]["sn"] || "" phone = session[:user_hash]["phone_number"] || "" major = session[:user_hash]["org"] || "" @user = User.new(:sunet => sunet, :first_name => gn.titlecase, :last_name => sn.titlecase, :bio => "I dance for Basmati Raas!", :is_alumni => false, :is_undergrad => true, :phone => phone, :major => major) @user.save flash[:notice] = "Welcome! We started filling out your profile. Please upload a picture and update your information." redirect_to "/users/#{@user.id}/edit" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_belongs_to_team!\n if signed_in? && current_team.present?\n redirect_to root_app_url unless current_team_role\n end\n end", "def authorized_for_team\n team = Team.find(params[:id]);\n redirect_to root_path unless team.users_ids.include?(current_user.id) || \n ...
[ "0.7867253", "0.7324328", "0.7126531", "0.7037571", "0.6980072", "0.69788986", "0.6948538", "0.68844736", "0.6879058", "0.6777168", "0.6645534", "0.65735555", "0.65341973", "0.6511264", "0.64719826", "0.64637256", "0.64619684", "0.6449182", "0.64353603", "0.6433088", "0.64200...
0.0
-1
POST: create a new user
def create @user = User.new(params[:user]) if @user.valid? @user.save flash[:notice] = "Successfully created new member!" redirect_to :action => :show, :id => @user.id else flash[:alert] = "There was an error in validating the new member" render :action => :new end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_user(body)\n post 'create_user', body\n end", "def create\n user = User.new(user_params)\n if user.save\n render json: {status: \"Se creo el usuario\"}, status: :ok\n else\n render json: {status: \"Error al crear el usuario\", errors: user.errors }, status: :unprocessable_entity...
[ "0.81716645", "0.81304353", "0.80620456", "0.799887", "0.79771715", "0.7946712", "0.7925822", "0.79162335", "0.78986996", "0.78957283", "0.7887921", "0.7886165", "0.78803355", "0.7870509", "0.7867123", "0.78627205", "0.78584355", "0.7851147", "0.78419894", "0.7840443", "0.784...
0.0
-1
Show member of specific id
def show @user = User.find_by_id(params[:id]) respond_to do |format| format.html format.json { render json: @user.to_json(:methods => [:avatar_url]) } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_member\n @member = Member.find(params[:id])\n end", "def show\n #@member= Member.find(params[:member_id])\n end", "def show\n #@member= Member.find(params[:member_id])\n end", "def show\n #@member= Member.find(params[:member_id])\n end", "def show\n \t@member= Member.find(params[:...
[ "0.83190507", "0.8069731", "0.8069731", "0.8069731", "0.80090594", "0.77733344", "0.76382697", "0.7570597", "0.7547313", "0.74561846", "0.74422973", "0.74326307", "0.741494", "0.73638237", "0.7360886", "0.7304635", "0.72994685", "0.7287684", "0.7284234", "0.7277855", "0.72530...
0.0
-1
return an HTML form for editing a user
def edit @user = User.find_by_id(params[:id]) logged_in_user = session[:user_hash]["username"] if logged_in_user != @user.sunet and not User.is_power_user(logged_in_user) # permission denied flash[:error] = "Your privileges don't allow you to edit profiles other than your own." redirect_to "/users#/users/" end @photos = Photo.find_all_by_user_id(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit\n # return an HTML form for editing a specific user\n @user = User.find(params[:id])\n end", "def edit\n @user = User.find(params[:id])\n # just show me the form\nend", "def edit\n @user = User.find(params[:id])\n\t case params[:form]\n\t when \"email\"\n\t render 'email'\n\t when \"...
[ "0.81796855", "0.7678685", "0.75893253", "0.7582822", "0.7542097", "0.743943", "0.7439329", "0.7428165", "0.7335785", "0.7288829", "0.7288553", "0.7265764", "0.72639525", "0.72576153", "0.72407615", "0.7223522", "0.7203743", "0.7183108", "0.7176013", "0.716137", "0.71435434",...
0.0
-1
PUT: update a specific user
def update @user = User.find_by_id(params[:id]) if @user.update_attributes(params[:user]) flash[:notice] = "Updated member!" else flash[:alert] = "Unable to update member." end redirect_to "/users#/users/#{@user.id}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_user(user, options = {})\n put \"/users/#{user}\", options\n end", "def modify_user(user)\n query_api_object Model::User, '/rest/user', user.to_hash, 'PUT'\n end", "def modify_user(user)\n query_api_object User, \"/rest/user\", user.dump(), \"PUT\"\n end", "def update_user(...
[ "0.8188249", "0.79777175", "0.79269505", "0.7790269", "0.7656797", "0.7623427", "0.7560168", "0.75147706", "0.7496502", "0.74697775", "0.7469062", "0.7466979", "0.74541116", "0.74526423", "0.7443641", "0.7431003", "0.74265105", "0.7415451", "0.74102616", "0.74073523", "0.7396...
0.0
-1
DELETE: delete a specific user
def destroy User.destroy(params[:id]) flash[:notice] = "Deleted member!" redirect_to :action => :index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_user\n client.delete(user)\n end", "def delete_user\n end", "def delete_user(user)\n delete user_path(user)\n end", "def delete(user_id)\n self.class.delete(\"/#{@api_ver}/users/#{user_id}\", default_options_to_merge_with)\n end", "def delete_user(id)\n get_user...
[ "0.86632615", "0.8423136", "0.84053475", "0.82250786", "0.8192423", "0.815359", "0.8069401", "0.8058493", "0.8056387", "0.8056387", "0.8041427", "0.80394095", "0.8017781", "0.799115", "0.7967456", "0.7952666", "0.7934495", "0.79335874", "0.7903419", "0.78754306", "0.786016", ...
0.0
-1