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 |
|---|---|---|---|---|---|---|
Sleep very briefly while waiting for a thread to get somewhere. | def wait
sleep 0.0001
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait!\n sleep(@sleep)\n end",
"def wait\n @thread.join\n end",
"def wait\n @timer_thread.join\n end",
"def sleep(timeout = nil)\n unlock\n begin\n timeout ? Kernel.sleep(timeout) : Kernel.sleep\n ensure\n lock\n end\n end",
"def wait_for_launching\n ... | [
"0.752285",
"0.735789",
"0.72599554",
"0.7226387",
"0.7224303",
"0.72218126",
"0.711426",
"0.7085287",
"0.7074966",
"0.70265216",
"0.6997958",
"0.69432634",
"0.69357663",
"0.689117",
"0.6884353",
"0.6835352",
"0.68051076",
"0.67935306",
"0.67527944",
"0.6740226",
"0.6729858",... | 0.7014215 | 10 |
Returns a User object based on the session[:user_id] or current user logged in This is handy because now we can simply do in views and other places | def current_user
if (user_id = session[:user_id])
@current_user ||= User.find_by(id: user_id)
elsif (user_id == cookies.signed[:user_id])
user = User.find_by(id: user_id)
if user && user.authenticated?(:remember, cookies[:remember_token])
log_in user
@current_user = user
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_from_session\n if session[:user] && session[:user][:id]\n User.find_by_id(session[:user][:id])\n else\n nil\n end\n end",
"def getLoggedInUser\n if session[:user_id]\n return User.find(session[:user_id])\n else\n return nil\n end\n end",
"def get_user_from_sessi... | [
"0.8786022",
"0.85132444",
"0.8509263",
"0.8453662",
"0.8385991",
"0.8329632",
"0.8232911",
"0.81804353",
"0.81783277",
"0.8165464",
"0.81429446",
"0.81429446",
"0.8054015",
"0.8054015",
"0.8054015",
"0.7979989",
"0.79653233",
"0.7961896",
"0.79298615",
"0.79214513",
"0.79205... | 0.0 | -1 |
Cookies Helper Functions Set information to user column in database and set cookies | def remember(user)
user.remember
cookies.permanent.signed[:user_id] = user.id
cookies.permanent[:remember_token] = user.remember_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUser\n cookies[:user_id]=current_user.id\n cookies[:is_tech]=current_user.tech\n end",
"def set_cookies_for_user(resource)\n cookies[:c_user] = {value: resource.email, expires: 2.year.from_now}\n end",
"def set_cookie_value\n cookie_value = User.using_client_shard(client: @client).get_co... | [
"0.7626378",
"0.75939786",
"0.7583214",
"0.7407376",
"0.7341168",
"0.7291429",
"0.7278496",
"0.7266788",
"0.71814996",
"0.716623",
"0.710241",
"0.70695996",
"0.7039075",
"0.7015774",
"0.700301",
"0.6996353",
"0.69646674",
"0.6895003",
"0.68816763",
"0.6874724",
"0.68732566",
... | 0.6844489 | 24 |
Set information to user column in database to nil and set cookies | def forget(user)
user.forget
cookies.delete(:user_id)
cookies.delete(:remember_token)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_save\n cookies['global_properties_for_user'] = nil\n end",
"def empty_user_id\n session[:user]=nil\n end",
"def clear_login_data\r\n session[:edit_mode] = 0\r\n session[:user_id] = nil\r\n session[:user_name] = nil\r\n session[:user_roles] = nil\r\n cookies.delete :remember_me\r... | [
"0.703346",
"0.6932918",
"0.68617976",
"0.68456876",
"0.66832083",
"0.6646991",
"0.66064775",
"0.6541238",
"0.650826",
"0.6486057",
"0.64325225",
"0.6414825",
"0.6394765",
"0.6381007",
"0.6376435",
"0.63114256",
"0.6309163",
"0.62515765",
"0.62515765",
"0.62477744",
"0.624326... | 0.0 | -1 |
Returns true if a user is logged in. | def logged_in?
!current_user.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end",
"def logged_in?\n user._logged_in?\n end",
"def logged_in?\n if session[:username]\n if session[:logged_in?]\n return true\n end\n else\n r... | [
"0.88534236",
"0.8612448",
"0.858063",
"0.85630125",
"0.8455268",
"0.8425849",
"0.83985686",
"0.83868366",
"0.8340534",
"0.8332821",
"0.8332445",
"0.8274829",
"0.8260356",
"0.82453173",
"0.8199828",
"0.8196907",
"0.8188211",
"0.81823444",
"0.81823444",
"0.8166226",
"0.8165181... | 0.8034703 | 91 |
Authorization. Make sure the current user is authorized . | def verify_correct_user
@user = User.find(params[:id])
# current_user is a function defined in sessions_helper
if not @user == current_user
flash[:danger] = "Unauthorized Access."
redirect_to listings_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorize\n\t\tredirect_to '/login' unless current_user\n\tend",
"def authorize\n redirect_to '/login' unless current_user\n end",
"def authorize # we can call it anything\n redirect_to '/login' unless current_user # if there is a current user then it will never redirect\n end",
"def au... | [
"0.8298375",
"0.81941134",
"0.8175694",
"0.81504333",
"0.80591464",
"0.80298305",
"0.80232865",
"0.80232865",
"0.80147296",
"0.80037487",
"0.80037487",
"0.80037487",
"0.80037487",
"0.80037487",
"0.80037487",
"0.80037487",
"0.80037487",
"0.79876816",
"0.7981189",
"0.7949128",
... | 0.0 | -1 |
GET /filters GET /filters.json | def index
if ! params["template_id"].nil?
@template = Template.find(params["template_id"])
if ! @template.nil?
@filters= Filter.where("template = ?",params["template_id"])
end
end
if @filters.nil?
@filters = Filter.all
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_filters(**args)\n params = parameters(args) do\n optional_params :type\n end\n request(:get, 'filters', params)\n end",
"def usage_filters\n get('/1/reporting/filters').to_a\n end",
"def filters\n mentos(:get_all_filters)\n end",
"def filters\n ... | [
"0.7365225",
"0.7285142",
"0.7192367",
"0.717103",
"0.717103",
"0.71120006",
"0.7104523",
"0.7093628",
"0.7091617",
"0.7061836",
"0.69822854",
"0.6977896",
"0.68519837",
"0.6815959",
"0.674156",
"0.674156",
"0.6648203",
"0.6599663",
"0.657105",
"0.6556355",
"0.6556355",
"0.... | 0.0 | -1 |
GET /filters/1 GET /filters/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @filter = current_user.filters.find(params[:id])\n # @filters = current_user.filters.all\n respond_to do |format|\n format.html\n format.json { render json: @filter }\n end\n end",
"def show\n @filter = Filter.find(params[:id])\n\n respond_to do |format|\n format.html... | [
"0.72234565",
"0.7091263",
"0.7091263",
"0.7091263",
"0.7070181",
"0.6986461",
"0.68777716",
"0.6834525",
"0.68005466",
"0.6785621",
"0.67810506",
"0.67664194",
"0.6739388",
"0.6711453",
"0.65828454",
"0.65477353",
"0.6544896",
"0.6513746",
"0.64932764",
"0.6490309",
"0.64114... | 0.0 | -1 |
POST /filters POST /filters.json | def create
@filter = Filter.new(filter_params)
respond_to do |format|
if @filter.save
format.html { redirect_to filters_path(:template_id => @filter.template), notice: 'Filter was successfully created.' }
format.json { render action: 'show', status: :created, location: @filter }
else
format.html { render action: 'new' }
format.json { render json: @filter.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n Filter.create! :json_contents => params[:filter]\n\n render json: {\n success: true\n }\n end",
"def create\n render_json_auto @survey.add_filter(params[:filter]) and return\n end",
"def create_filter(**args)\n params = parameters(args) do\n required_params :name... | [
"0.7155857",
"0.69005346",
"0.6793477",
"0.67742306",
"0.66890144",
"0.6552783",
"0.6552783",
"0.6533314",
"0.6475099",
"0.63738143",
"0.6324382",
"0.6309093",
"0.62695175",
"0.6253303",
"0.6246593",
"0.62373185",
"0.62309164",
"0.62017816",
"0.6197038",
"0.61771685",
"0.6157... | 0.6039931 | 27 |
PATCH/PUT /filters/1 PATCH/PUT /filters/1.json | def update
respond_to do |format|
if @filter.update(filter_params)
format.html { redirect_to @filter, notice: 'Filter was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @filter.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render_json_auto @survey.update_filter(params[:id].to_i, params[:filter]) and return\n end",
"def update\n @filter = Filter.find(params[:id])\n\n respond_to do |format|\n if @filter.update_attributes(params[:filter])\n format.html { redirect_to filters_url, notice: 'Filter was ... | [
"0.6763415",
"0.6685207",
"0.65951186",
"0.65951186",
"0.65820664",
"0.65685034",
"0.6562206",
"0.6555122",
"0.65389484",
"0.6505399",
"0.64501154",
"0.63823295",
"0.63226646",
"0.6247337",
"0.62015194",
"0.61563593",
"0.61563593",
"0.6150148",
"0.6145155",
"0.61409765",
"0.6... | 0.6496467 | 10 |
DELETE /filters/1 DELETE /filters/1.json | def destroy
@filter.destroy
respond_to do |format|
format.html { redirect_to filters_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n if params[:id] != '-1'\n @filter = Filter.find(params[:id])\n else\n @filter = Filter.where( :name => params[:filter][:name], :group => params[:filter][:group], :pattern => params[:filter][:pattern] ).first\n end\n\n Auditlog( self.class.name, @filter )\n\n if @filter\n ... | [
"0.73684776",
"0.7281558",
"0.7281558",
"0.7281558",
"0.72813976",
"0.72464997",
"0.7172518",
"0.716912",
"0.71385443",
"0.7102319",
"0.7043395",
"0.7009226",
"0.6966969",
"0.6948915",
"0.68082577",
"0.68067676",
"0.67874295",
"0.6678135",
"0.6652824",
"0.66519946",
"0.663376... | 0.73082197 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_filter
@filter = Filter.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6164095",
"0.6046031",
"0.5945298",
"0.59179014",
"0.58890367",
"0.58341795",
"0.5776118",
"0.5700777",
"0.5700777",
"0.5656277",
"0.56218207",
"0.5423995",
"0.5411516",
"0.5411516",
"0.5411516",
"0.5395004",
"0.53783494",
"0.53593004",
"0.53412604",
"0.534078",
"0.5332865... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def filter_params
params.require(:filter).permit(:template, :name, :code)
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 |
before_filter :login_required, :only => :tags | def index
session[:notebook] = nil
@notebooks = Notebook.find(:all,
:conditions => "shared_public = true",
:order => 'id DESC', :limit => 20)
@history = History.find(:all,
:conditions => "user_id = #{@user.id}",
:order => 'id DESC', :limit => 20)
@notes = Note.find(:all,
:conditions => "user_id = #{@user.id}",
:order => 'id DESC', :limit => 12)
@base_url = '/first_test'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n authorize @tag\n end",
"def before_filter; end",
"def index\n authorize Tag\n @tags = Tag.order(name: :asc).page params[:page]\n end",
"def index\n authorize @user\n render :json => @user.tags\n end",
"def index\n @admin_tags = @login_author.tags\n end",
"def authorize!\n... | [
"0.6932324",
"0.68859917",
"0.68395454",
"0.675663",
"0.65660095",
"0.65554094",
"0.6471702",
"0.64479315",
"0.64479315",
"0.64462185",
"0.6334062",
"0.6331646",
"0.628215",
"0.62811995",
"0.6226257",
"0.62166196",
"0.6211756",
"0.6115669",
"0.61147785",
"0.6059778",
"0.60597... | 0.0 | -1 |
GET /itemimages GET /itemimages.json | def index
@itemimages = Itemimage.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def images\n IbmCloudRest.get \"#{@uri}/images\"\n end",
"def images() \n uri = URI.parse(\"http://\" + @location.host + \":9292/v2/images\")\n return get_request(uri, @token)\n end",
"def items\n @beverages = Beverage.available\n respond_to do |format|\n format.json { render :j... | [
"0.7458888",
"0.7457632",
"0.7439565",
"0.7418746",
"0.74000067",
"0.7398621",
"0.725824",
"0.7173749",
"0.7165167",
"0.70364606",
"0.7023799",
"0.7018019",
"0.69975233",
"0.69596237",
"0.69351095",
"0.6928637",
"0.6890854",
"0.6873433",
"0.6869076",
"0.684811",
"0.6822783",
... | 0.7311777 | 6 |
GET /itemimages/1 GET /itemimages/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @itemimages = Itemimage.all\n end",
"def get_images\n @command = :get_images\n # set a flag indicating whether or not the user wants to see all images,\n # including the hidden ones\n show_hidden = (@prev_args.peek(0) == \"-i\" || @prev_args.peek(0) == \"--hidden\")\n ... | [
"0.72392994",
"0.7144198",
"0.71352965",
"0.7039931",
"0.702637",
"0.69990146",
"0.6994838",
"0.69794136",
"0.69751906",
"0.6948799",
"0.6931003",
"0.6924425",
"0.68915945",
"0.6878259",
"0.6878259",
"0.68455535",
"0.6836407",
"0.68026173",
"0.6787596",
"0.67467666",
"0.67398... | 0.0 | -1 |
POST /itemimages POST /itemimages.json | def create
@itemimage = Itemimage.create(itemimage_params) #загружаем картинки через форму загрузки js файл - create.js
# @itemimage = Itemimage.new(itemimage_params)
# respond_to do |format|
# if @itemimage.save
# format.html { redirect_to @itemimage, notice: 'Itemimage was successfully created.' }
# format.json { render :show, status: :created, location: @itemimage }
# else
# format.html { render :new }
# format.json { render json: @itemimage.errors, status: :unprocessable_entity }
# end
# end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n @item.images.delete_all\n unless params.require(:item)[:images_id].nil?\n params.require(:item)[:images_id].each do |id|\n image = Image.find_by_id(id)\n (@item.images << ... | [
"0.7868236",
"0.69015795",
"0.6798811",
"0.675782",
"0.66260767",
"0.6601692",
"0.6563295",
"0.6459281",
"0.64389765",
"0.6404642",
"0.6392923",
"0.63706434",
"0.63582885",
"0.63577634",
"0.6356706",
"0.6323504",
"0.63083035",
"0.6307997",
"0.63008463",
"0.6299367",
"0.623331... | 0.5684559 | 86 |
PATCH/PUT /itemimages/1 PATCH/PUT /itemimages/1.json | def update
respond_to do |format|
if @itemimage.update(itemimage_params)
format.html { redirect_to @itemimage, notice: 'Itemimage was successfully updated.' }
format.json { render :show, status: :ok, location: @itemimage }
else
format.html { render :edit }
format.json { render json: @itemimage.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @item.update(item_params)\n @item.images.delete_all\n unless params.require(:item)[:images_id].nil?\n params.require(:item)[:images_id].each do |id|\n image = Image.find_by_id(id)\n (@item.images << image) unless image.ni... | [
"0.7734474",
"0.70096636",
"0.67980844",
"0.67126197",
"0.67076254",
"0.6535518",
"0.645766",
"0.6444741",
"0.64289975",
"0.6423209",
"0.63466936",
"0.63339967",
"0.62737036",
"0.62536466",
"0.62462026",
"0.6213627",
"0.62111",
"0.61922",
"0.61807954",
"0.6180218",
"0.6180218... | 0.6854792 | 2 |
DELETE /itemimages/1 DELETE /itemimages/1.json | def destroy
@itemimage.destroy
flash[:info] = "Картинка удалена"
if params[:from] == 'items'
redirect_to :back
else
respond_to do |format|
format.html { redirect_to itemimages_url, notice: 'Картинка удалена' }
format.json { head :no_content }
format.js
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @item.image.destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n item = FormImage.last\n id = item[:id]\n item.destroy\n ... | [
"0.77251196",
"0.7648291",
"0.720311",
"0.71517235",
"0.71440434",
"0.7121508",
"0.71205485",
"0.7118757",
"0.70751625",
"0.7025682",
"0.7025682",
"0.7025682",
"0.7025682",
"0.7025682",
"0.7025682",
"0.7025682",
"0.7024589",
"0.7024589",
"0.7024589",
"0.7024589",
"0.7024589",... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_itemimage
@itemimage = Itemimage.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6164095",
"0.6046031",
"0.5945298",
"0.59179014",
"0.58890367",
"0.58341795",
"0.5776118",
"0.5700777",
"0.5700777",
"0.5656277",
"0.56218207",
"0.5423995",
"0.5411516",
"0.5411516",
"0.5411516",
"0.5395004",
"0.53783494",
"0.53593004",
"0.53412604",
"0.534078",
"0.5332865... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def itemimage_params
params.require(:itemimage).permit(:item_id, :image, :position, :item_new)
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 |
Upload episode's audio to Google SpeechToText | def upload_audio_for_transcription
puts "IN UPLOAD AUDIO CONTROLLER FUNCTION"
@speakers_number = params[:transcription][:speakers]
@episode_id = params[:transcription][:ep_id]
if @episode_id === nil
puts "EPISODE DOESN'T EXIST"
@episode = Episode.new(episode_params)
if @episode.save
GetTranscriptionJob.perform_later(@episode.id, @speakers_number)
render json: { message: "Transcription has started" }
else
render_error
end
else
puts "EPISODE EXISTS"
GetTranscriptionJob.perform_later(@episode_id, @speakers_number)
render json: { message: "Transcription has started" }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transcribe_audio\n source_wav = get_wav_from_source\n\n transcript = google_transcribe(source_wav, options)\n\n base_file_name = File.basename(source.path) + '.json'\n temp_file = audio_monster.create_temp_file(base_file_name, false)\n temp_file.write transcript.to_json\n temp_file.fsync\n\n ... | [
"0.65908444",
"0.6281455",
"0.6177642",
"0.6173053",
"0.61463374",
"0.61450386",
"0.6142216",
"0.608378",
"0.60733443",
"0.6026024",
"0.6022179",
"0.60049117",
"0.599806",
"0.59959424",
"0.59622616",
"0.5960619",
"0.5842451",
"0.5837637",
"0.58002186",
"0.57651377",
"0.575740... | 0.67162216 | 0 |
Write a method that searches for all multiples of 3 or 5 that lie between 1 and some other number, and then computes the sum of those multiples. For instance, if the supplied number is 20, the result should be 98 (3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 + 20). You may assume that the number passed in is an integer greater than 1. Examples | def multisum(value)
multiples = []
value.each { |item| multiples << item if item % 5 == 0 or item % 3 == 0}
muliples.reduce(&:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_multiples_of_3_or_5\n (1..999).to_a.select { |n| n.multiple_of?(3) or n.multiple_of?(5) }.inject(&:+)\nend",
"def sum_multiples_of_3_and_5(range)\n range.select { |n| n % 3 == 0 || n % 5 == 0 }.inject(:+)\nend",
"def multiples_of_3_and_5(number)\n (1...number).select{|num| num % 3 == 0 || num % 5 ==... | [
"0.84194064",
"0.83700883",
"0.8349604",
"0.83417845",
"0.8158299",
"0.8132691",
"0.80632836",
"0.8041483",
"0.8039389",
"0.80359167",
"0.8007709",
"0.8005227",
"0.79825765",
"0.79766065",
"0.796402",
"0.796126",
"0.7956854",
"0.79303783",
"0.78863275",
"0.78714925",
"0.78603... | 0.0 | -1 |
true or false depending on the value of the array element passed to it. The method should return a count of the number of times the block returns true. You may not use Arraycount or Enumerablecount in your solution. input: array and a block output: an integer (count of trues) considerations: empty array or all falses should return 0 algo: init counter to 0 iterate over collection yield to block with each element if the block returns true increment counter return counter at end | def count(array)
counter = 0
return counter unless block_given?
array.each { |el| counter += 1 if yield(el) }
counter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count(collection)\n block_rtn_true_count = 0\n\n collection.each { |element| block_rtn_true_count += 1 if yield element }\n block_rtn_true_count\nend",
"def count(collection)\n block_rtn_true_count = 0\n\n for element in collection\n block_rtn_true_count += 1 if yield element\n end\n\n block_rtn_tr... | [
"0.7985326",
"0.79315",
"0.78049713",
"0.7783552",
"0.7737142",
"0.76449394",
"0.7542698",
"0.7364967",
"0.7278399",
"0.7245743",
"0.7211274",
"0.7209734",
"0.7201064",
"0.71872294",
"0.71605945",
"0.71367055",
"0.7136091",
"0.71258247",
"0.712435",
"0.70838",
"0.7077283",
... | 0.8040356 | 0 |
for compatibility with Thor, not really needed | def given_destination
dir
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def terpene; end",
"def probers; end",
"def weber; end",
"def trd; end",
"def schubert; end",
"def wrapper; end",
"def custom; end",
"def custom; end",
"def suivre; end",
"def internal; end",... | [
"0.7526269",
"0.6875213",
"0.6875213",
"0.6875213",
"0.6875213",
"0.67367154",
"0.6632624",
"0.6490185",
"0.6455723",
"0.6441316",
"0.63125664",
"0.6307953",
"0.6307953",
"0.61475575",
"0.6117456",
"0.6085154",
"0.6085154",
"0.60700387",
"0.60565376",
"0.5974491",
"0.59549844... | 0.0 | -1 |
demeter issue but does it matter enough? | def say_status(status, color)
base.shell.say_status(status, dir, color) if verbose?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deter\n \n end",
"def malts; end",
"def offences_by; end",
"def too_complex; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def formation; end",
"def probers; end",
"def dec_d\n end",
"def sub_d\n end",
"def silly_adjective; end",
... | [
"0.6067178",
"0.5792473",
"0.57636136",
"0.5650245",
"0.5528863",
"0.5528863",
"0.5528863",
"0.5528863",
"0.55255675",
"0.5475204",
"0.54583573",
"0.5440933",
"0.54243505",
"0.5399036",
"0.538318",
"0.5374345",
"0.5335483",
"0.5335483",
"0.53271025",
"0.53271025",
"0.53271025... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_api_v1_recent
@api_v1_recent = Api::V1::Recent.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def api_v1_recent_params
params.fetch(:api_v1_recent, {})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.contacts_message.message.subject | def send_a_mail(name, title, body)
@name = name
@body = body
@title = title
#mail to: "window@i.ua"
mail subject: "Сообщение от сайта Никиты с темой #{@title}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message_subject=(value)\n @message_subject = value\n end",
"def subject\n self['subject'] || msg['subject']\n end",
"def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end",
"def subject (recipient)\n subject_variables = alert_v... | [
"0.7933248",
"0.7466332",
"0.74276423",
"0.7365913",
"0.7164695",
"0.7154973",
"0.7138647",
"0.6874244",
"0.6833607",
"0.6689031",
"0.6501538",
"0.6486588",
"0.6462719",
"0.6444831",
"0.6419678",
"0.6418831",
"0.6405125",
"0.63402253",
"0.633885",
"0.6337677",
"0.6334262",
... | 0.0 | -1 |
Eg: pascal(6) gives: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 | def p_triangle(n)
(0..n).each{|i|
list = [1]
element = 1
k = 1
(0..i-1).step(1){|index|
element = element * (i-k+1)/k
list.push element
k += 1
}
yield(list)
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pascal(i)\n if i == 0\n return [1]\n else\n row = [1,1]\n while row.length <= i\n sums = (0..row.length-2).map {|index| row[index] + row[index+1]}\n row = [1] + sums + [1]\n end\n return row\n end\nend",
"def pascal(row)\n if row == 0 || row < 0\n return [1]\n end\n\n previo... | [
"0.8085254",
"0.8044962",
"0.804187",
"0.79580134",
"0.7893469",
"0.7594327",
"0.7511992",
"0.7475559",
"0.74112076",
"0.73898727",
"0.6893215",
"0.67022085",
"0.66955894",
"0.6664796",
"0.664448",
"0.6584083",
"0.6577467",
"0.63949025",
"0.6367125",
"0.6341323",
"0.615603",
... | 0.0 | -1 |
Method to create a list that takes string input: string of items separated by spaces (example: "carrots apples cereal pizza") steps: create empty hash split string by spaces in an array iterate through array making every element a key in the hash assign a beginning value of 1 for each key print the list to the console using other defined method output: hash HINT: methods can accept other methods as arguments methods can be called within other methods | def create_list(string)
list = {}
string = string.split
string.each { |item|
list[item] = 1
}
printhash(list)
list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createlist(str)\r\n# steps:\r\n# break the string into an array\r\n items = str.split\r\n item_list = {}\r\n\r\n\t# iterate through array and build hash\r\n items.each do |item|\r\n\r\n\t\t# iterate through array and build hash\r\n\t\t# set default quantity to 1\r\n \titem_list[item] = 1\r\n e... | [
"0.8005978",
"0.7720211",
"0.7709913",
"0.75388104",
"0.7528431",
"0.75269675",
"0.7524087",
"0.7519314",
"0.74729747",
"0.7445157",
"0.7442967",
"0.7439614",
"0.73813874",
"0.73753244",
"0.73350424",
"0.7314092",
"0.7307285",
"0.72769445",
"0.7241983",
"0.7241565",
"0.723526... | 0.7932652 | 1 |
Method to add an item to a list input: hash 'list', item name (as string) and optional quantity (as int) steps: add item and quantity to hash output: hash | def add_item(list, item, qty)
list[item] = qty
list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def additem(list, item, number = 1)\n# input: hash, item name and optional quantity\n# steps: push an item into the hash\n list.store(item, number)\nend",
"def add_item(list_name, item, quantity=1)\r\n# input: list, item name, and optional quantity\r\n# steps: add item and its quantity to the hash\r\n list_nam... | [
"0.8735345",
"0.86463195",
"0.8589476",
"0.82232606",
"0.82232606",
"0.82205784",
"0.8124447",
"0.811477",
"0.81135875",
"0.8107185",
"0.81071043",
"0.81071043",
"0.8092409",
"0.80863494",
"0.80628663",
"0.8051973",
"0.8035168",
"0.803075",
"0.8020786",
"0.79962534",
"0.79872... | 0.7910309 | 25 |
Method to remove an item from the list input: hash and Item (key) to be removed steps: identify input with element in hash & remove it output: updated hash | def remove_item(list, item)
list.delete(item)
list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_item(input_hash, item)\n# input: list, item name, and optional quantity\n# steps: use input item to delete key\n input_hash.delete(item)\n# output: hash data structure of key/value pairs\nreturn input_hash\nend",
"def remove_item(item_to_remove)\n $list_hash.delete_if{|current_item, quantity|item_to... | [
"0.8677116",
"0.8285321",
"0.8264915",
"0.8253945",
"0.8252437",
"0.8251671",
"0.82350564",
"0.82224745",
"0.8197905",
"0.8197905",
"0.8186008",
"0.8171494",
"0.81203824",
"0.8028302",
"0.8028302",
"0.7988194",
"0.7969076",
"0.79088545",
"0.7895558",
"0.7866471",
"0.78573465"... | 0.7070174 | 67 |
Method to update the quantity of an item input: Hash and Item (key) to be updated steps: Identify input with element in hash and update quantity, keeping in mind addition or subtraction output: Updated hash | def update_quantity(list, item, qty)
list[item] = qty
list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_quantity(hash, item, quantity)\n\thash[item] = quantity\n\treturn hash\nend",
"def update_item_quantity(hash_of_items, item, quantity)\n hash_of_items[item] = quantity\n hash_of_items\nend",
"def update_quantity(input_hash, item, qty)\n# steps: use input item as key and input quantity as value\n# ... | [
"0.8350342",
"0.8343345",
"0.8327826",
"0.82741004",
"0.82337606",
"0.814062",
"0.8081351",
"0.8031433",
"0.8009186",
"0.8005786",
"0.79592896",
"0.79592896",
"0.7948282",
"0.79429513",
"0.791511",
"0.7831273",
"0.76920974",
"0.7648797",
"0.76111364",
"0.7584503",
"0.74845046... | 0.72217447 | 36 |
Method to print a list and make it look pretty input: Hash steps: Iterate through hash adding labels and provide formatting output: nil | def printhash(hash)
puts "-----------------------"
hash.each { |item, qty|
puts "#{item},\n qty: #{qty}"
puts ""
}
puts "-----------------------"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_list(list_name)\r\n# input: hash name\r\n# steps: add dashes and spacing\r\np \"List:\"\r\nlist_name.each do |key, value|\r\n p \"#{key}: #{value}\"\r\nend\r\n# output: pretty hash listed\r\nend",
"def pretty_list(list)\n puts \"Grocery List:\"\n list.each do |key, value|\n puts \"#{value} #{key}(s)... | [
"0.73229736",
"0.72074354",
"0.71474653",
"0.7129469",
"0.70493615",
"0.7033433",
"0.69813156",
"0.69087785",
"0.6906094",
"0.6848802",
"0.683827",
"0.68107796",
"0.68107796",
"0.679854",
"0.67677283",
"0.6716549",
"0.6698786",
"0.6696353",
"0.6685223",
"0.66678274",
"0.66615... | 0.0 | -1 |
Send a test email to the brother | def test_email
@brother.post_notification(
"Email testing. ",
"This email serves solely to ascertain that ADP Dashboard emails can reach your email address. ",
root_url
)
redirect_to root_url, flash: { notice: "Test email sent to #{@brother.email}. " }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_test_email\n @email = \"hanks@pobox.com\"\n RegistrationMailer.test(@email)\n end",
"def test\n @greeting = \"Hi\"\n\n mail(to: \"louis.fourrier@gmail.com\", subject: 'Welcome to the test suite of mail market')\n end",
"def test(email)\n mail(to: email, subject: \"Test\")\n end",
"... | [
"0.7937741",
"0.7879584",
"0.7854967",
"0.78411245",
"0.7824819",
"0.77319956",
"0.76855046",
"0.760867",
"0.7540761",
"0.7461263",
"0.741253",
"0.73315084",
"0.7272049",
"0.718379",
"0.7155603",
"0.715553",
"0.7085543",
"0.7049558",
"0.70429385",
"0.7042357",
"0.70115674",
... | 0.8210097 | 0 |
Returns the path of the associated file | def path
@file.path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path\n @file\n end",
"def get_file_path\n @path\n end",
"def path\n @file.path\n end",
"def path\n @file\n end",
"def file_path\n @file_path ||= lookup_file_path\n end",
"def path\n self.file.to_s\n end",
"def file_path\n\t\tself.class.file_path\n\ten... | [
"0.7929071",
"0.79280895",
"0.7921155",
"0.7855618",
"0.7853816",
"0.7843442",
"0.77170515",
"0.77046233",
"0.76084226",
"0.75906605",
"0.7588236",
"0.7588236",
"0.7588236",
"0.7580751",
"0.7557125",
"0.75568026",
"0.7555471",
"0.7555471",
"0.7555471",
"0.7518053",
"0.7511581... | 0.8073222 | 0 |
Writes the changes to the file specified in +output+. Set +:timeout => 30.seconds+ to change the timeout value. Default is one minute. | def write(output, opts = {})
output_path = parse_input(output, false)
FileUtils.copy_file(path, output_path) unless requires_output_file?
command = build_command(output_path)
run(command, opts)
GraphicsMagick::Image.new(output_path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_to_disk(output)\n path = \"./output.txt\"\n time = output[:time].strftime(\"%H:%M:%S:%N\")\n output_string = output[:value].to_s + \", \" + time + \"\\n\"\n File.open(path, 'a') { |file| file.write(output_string) }\n end",
"def write_file(out_file, output)\n File.open(out_file, 'w') ... | [
"0.6525673",
"0.6409679",
"0.62950295",
"0.61782444",
"0.6077943",
"0.60116845",
"0.5971725",
"0.5947035",
"0.5922776",
"0.57828873",
"0.57682353",
"0.5755666",
"0.5696071",
"0.5690862",
"0.5664221",
"0.56342554",
"0.56342554",
"0.5576554",
"0.55746925",
"0.55710006",
"0.5570... | 0.51711845 | 50 |
Writes the changes to the current file. Set +:timeout => 30.seconds+ to change the timeout value. Default is one minute. | def write!(opts = {})
if requires_output_file?
raise NoMethodError, "You cannot use Image#write(output) with "\
"the #{current_utility} command"
end
command = build_command(path)
run(command, opts)
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_timeout= sec\n @lock.write_timeout = sec\n end",
"def def_write_timeout\n 10\n end",
"def write_timeout; end",
"def write_timeout; end",
"def write_timeout; end",
"def write_timeout\n @lock.write_timeout\n end",
"def write_file\n\n # file_edited is false when there was no m... | [
"0.6370513",
"0.6029539",
"0.5918113",
"0.5918113",
"0.5918113",
"0.5872217",
"0.5861692",
"0.58557075",
"0.5846471",
"0.5767204",
"0.57268804",
"0.57098603",
"0.5699554",
"0.56788725",
"0.5643097",
"0.5610525",
"0.5601726",
"0.5601726",
"0.55872226",
"0.55802566",
"0.5577164... | 0.0 | -1 |
NOTE: Change/Configure redirect path after sign_out (via Devise) | def after_sign_out_path_for(resource_or_scope)
store_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_sign_out_path_for(_resource_or_scope)\n root_path\n # new_user_session_path\n end",
"def after_sign_out_path_for(resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource)\n new_user_session_path\n end",
"def after_sign_out_path_for(resource)\n new_user_se... | [
"0.8132277",
"0.8078114",
"0.8078114",
"0.8078114",
"0.8078114",
"0.8078114",
"0.8068921",
"0.80655515",
"0.8045104",
"0.80408734",
"0.8015245",
"0.800457",
"0.79902315",
"0.7987901",
"0.79749614",
"0.79749614",
"0.7958409",
"0.7958409",
"0.7956779",
"0.7938983",
"0.793368",
... | 0.0 | -1 |
In Prawn, text/image can be inserted by drawing them within a grid. A grid contains its topleft coordinates and its bottomright coordinates. In the initialize(), each page was basically divided into a 85 X 110 grid. This basically sets up the page coordinates by 0.1 inches since it is by default an A4 document. The function below basically takes the x, y as inches converts them to grid arrays. It also takes width and height in inches and calculate the coordinates for the bottomright corner of the grid. | def get_grids(x, y, width, height)
x = (x*10)-5
y = (y*10)-5
end_x= x+(width*10)-1
end_y= y+(height*10) -1
return [[y, x], [end_y, end_x]]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_grid(x_max,y_max,step)\r\n n_x = (x_max/step).round()\r\n n_y = (y_max/step).round()\r\n n_x_cur = 1\r\n n_y_cur = 1\r\n\r\n # Draw a grid with lines using 'step' spacing. \r\n while n_x_cur <= n_x do\r\n line(n_x_cur*step, step, n_x_cur*step, n_y*step, :stroke=>\"gray\" ) \r\... | [
"0.58458084",
"0.57992077",
"0.57796013",
"0.5697283",
"0.5688735",
"0.5632062",
"0.55877596",
"0.55758154",
"0.5497958",
"0.5474915",
"0.54611224",
"0.5443279",
"0.54430366",
"0.5416359",
"0.539618",
"0.5392738",
"0.5391967",
"0.5387032",
"0.5375743",
"0.5365242",
"0.536321"... | 0.59078574 | 1 |
set_text() create a grid at the coordinates specified by grids. It also sets the font, font_size, alignment of the text in parameter, data, inside the created grid. "fill", by default, is false so that there is no border or background color to the grid created. The "top_padding" is also false by default, so that there is no unintended top_padding to the text within the grid. "fill" and "top_padding" are used as part of the office only form to create the grid. | def set_text(grids, data, fill = false, top_padding = false, pad = 7)
grid(grids[0], grids[1]).bounding_box() do
font data[:font]
font_size data[:font_size]
if top_padding
move_down pad
end
if fill
stroke_bounds
text "#{Prawn::Text::NBSP * 1}#{data[:text]}", inline_format: true, align: data[:align]
if data[:text]==""
stroke do
fill_color 'DDDDDD'
fill_and_stroke_rectangle [0,bounds.height], bounds.width, bounds.height
fill_color '000000'
end
end
else
text data[:text], inline_format: true, align: data[:align]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_grid\n # variables for grid display\n @grid = \" A B C \\n\" \\\n \"1 #{@a1} | #{@b1} | #{@c1} \\n\" \\\n \" ---+---+--- \\n\" \\\n \"2 #{@a2} | #{@b2} | #{@c2} \\n\" \\\n \" ---+---+--- \\n\" \\\n \"3 #{@a3} | #{@b3} | #{@c3} \\n\"\n end",
"def set_text(text... | [
"0.5970205",
"0.56168526",
"0.54585946",
"0.53924876",
"0.52754223",
"0.5232772",
"0.51702005",
"0.5162827",
"0.5146563",
"0.5128384",
"0.5128384",
"0.5127006",
"0.512532",
"0.51175356",
"0.50829244",
"0.50783634",
"0.5074407",
"0.5072965",
"0.5048576",
"0.5035951",
"0.498061... | 0.83022165 | 1 |
draws a horizontal according to the fraction of 7.5 inches (because margin for the document is 0.5 inches on all sides) | def draw_line(grids, length)
grid(grids[0], grids[1]).bounding_box() do
stroke_horizontal_line 0, 470*length, at: 5
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sx\n #==========================================================================\n # We take the maximum possible size for the page number display and\n # devise a starting X coordinate based on that.\n #==========================================================================\n self.x + \n... | [
"0.6283881",
"0.615879",
"0.59483665",
"0.5905693",
"0.5870146",
"0.5869017",
"0.58117646",
"0.5739962",
"0.572444",
"0.5712299",
"0.5699494",
"0.56598604",
"0.5645212",
"0.5645212",
"0.5645212",
"0.56425786",
"0.5619404",
"0.5609096",
"0.5588031",
"0.55733734",
"0.5547786",
... | 0.0 | -1 |
reads forms data, which an array of strings, and extract for a "tablerow" and gets the max number of columns needed in the form table | def get_table_data(form_data)
table_data = []
i = -1
max = 1
form_data.each_with_index do |value, index|
if index!=0
type_data = @parser.get_type(value)
if type_data[:type] == "tablerow"
(table_data[i][:table]).push(type_data[:data])
if type_data[:data].size > max
max = type_data[:data].size
end
else
i = i+1
table_data[i] = {label: value, table: [], index: [index-1, index]}
end
end
end
return [table_data, max]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_fields\n @form_fields.size\n end",
"def find_fields rowname\n row = row_by_name(rowname)\n fields = (row ? row.fields : [])\n # fill fields with nil to match header length\n # say header=5 fields=2 fill=2 (skip rowname)\n fields.fill(nil,fields.size,header.size-1-fields.s... | [
"0.5652515",
"0.5537327",
"0.5429151",
"0.541703",
"0.5394851",
"0.53707033",
"0.5347126",
"0.5318003",
"0.5316742",
"0.5308554",
"0.5269601",
"0.5260024",
"0.52556324",
"0.5250446",
"0.5240815",
"0.5240815",
"0.52362895",
"0.5224511",
"0.5206284",
"0.5205175",
"0.5170993",
... | 0.78237754 | 0 |
gets the y coordinate of the paragraph on the page by num_lines | def get_y_by_line(num_lines)
if page_count == 1
return (num_lines*0.16)+0.4
else
return ((num_lines - (((page_count-2)*66)+59))*0.16)+0.4
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paragraph_xy(x, y, text, options={})\n cur_page.paragraph_xy(x, y, text, options)\n end",
"def line_num_to_coord(n)\n\t\t(n + 1) * font_metrics.height\n\tend",
"def coord_to_line_num(y)\n\t\ty / font_metrics.height - 1\n\tend",
"def gety\n (@lines[0...@str_idx].map(&:ymax).reduce(:+) || 0) +... | [
"0.69286245",
"0.6903354",
"0.64483553",
"0.64153033",
"0.64153033",
"0.6344221",
"0.6168731",
"0.6166192",
"0.6011637",
"0.60098696",
"0.60060996",
"0.60060996",
"0.60060996",
"0.5915118",
"0.5915118",
"0.5902773",
"0.5900886",
"0.5894974",
"0.58920777",
"0.5889395",
"0.5883... | 0.74101937 | 0 |
Print Bash source code to hook into `complete` to `$stdout`. | def setup
bin = File.basename $0
name = bin.underscore
erb_src_path = ::Thor::ROOT.join 'support',
'completion',
'complete.inc.bash.erb'
erb_src = erb_src_path.read
bash_src = binding.erb erb_src
puts bash_src
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def complete(message, output)\n end",
"def minimal_progress_callback(state)\n case state\n when :start then print '|'\n when :step then print '.'\n when :end then puts\n end\n\n $stdout.flush\n end",
"def complete\n insert_completion @completer.current_completion\n ... | [
"0.5676583",
"0.5569359",
"0.5531174",
"0.51801103",
"0.5155758",
"0.5155758",
"0.5155758",
"0.5155758",
"0.5155758",
"0.5155758",
"0.51438576",
"0.5090053",
"0.5086273",
"0.50735855",
"0.5009567",
"0.50011337",
"0.49937692",
"0.49830174",
"0.49149364",
"0.49130046",
"0.48922... | 0.61824614 | 0 |
show what users you are followings... | def following
@following = current_user.following.order("username").page(params[:page]).per(10)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def following_usernames\n url = [PUBLIC_BASE_URL, 'user/show', self.login, 'following'].join('/')\n JSON.parse(open(url).read)['users']\n end",
"def following\n @following||= get(\"/user/show/#{login}/following\")['users'].map { |u| User.new(connection, :login => u) }\n end",
"def followin... | [
"0.768183",
"0.7251917",
"0.7098407",
"0.70430976",
"0.7033746",
"0.70093983",
"0.7003718",
"0.6973329",
"0.6970792",
"0.6911697",
"0.69008005",
"0.68979555",
"0.68913776",
"0.6880729",
"0.6862236",
"0.685679",
"0.6848402",
"0.6830528",
"0.6824617",
"0.6808606",
"0.68006843",... | 0.7077539 | 3 |
show users who are following you... | def followers
@followers = current_user.followers.order("username").page(params[:page]).per(10)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def following_usernames\n url = [PUBLIC_BASE_URL, 'user/show', self.login, 'following'].join('/')\n JSON.parse(open(url).read)['users']\n end",
"def following\n @following||= get(\"/user/show/#{login}/following\")['users'].map { |u| User.new(connection, :login => u) }\n end",
"def followin... | [
"0.7858031",
"0.76255995",
"0.7622169",
"0.75398964",
"0.746091",
"0.73883057",
"0.7350136",
"0.7301879",
"0.72883743",
"0.72716653",
"0.7243383",
"0.7240379",
"0.72328484",
"0.7213749",
"0.71859586",
"0.71559685",
"0.71559685",
"0.7143476",
"0.714232",
"0.714232",
"0.714232"... | 0.0 | -1 |
def update course = Course.find_by_id(params[:id]) course.attributes = course_params course.save! redirect_to courses_path end def destroy Course.find_by_id(params[:id]).destroy redirect_to courses_path end | def user_params
params.require(:invite).permit(:email)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @course = Course.find(params[:id])\n\n if @course.update_attributes(course_params)\n flash[:notice] = \"Course updated!\"\n redirect_to course_url(@course)\n else\n render :action => :edit\n end\n end",
"def update\n @course = Course.find(params[:id])\n \n if (!p... | [
"0.8404323",
"0.82994837",
"0.8275218",
"0.82745373",
"0.8269943",
"0.8261256",
"0.8255961",
"0.82520914",
"0.82504547",
"0.82466537",
"0.82425284",
"0.82425284",
"0.82391596",
"0.82366234",
"0.8230801",
"0.8230801",
"0.8230801",
"0.8230801",
"0.8230801",
"0.8230801",
"0.8230... | 0.0 | -1 |
GET /analyses/1 GET /analyses/1.xml | def show
@analysis = Analysis.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @analysis }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @analyses = Analysis.includes(:user).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @analyses }\n end\n end",
"def analyses\n @project = Project.find(params[:id])\n @analyses = Analysis.all\n\n respond_to do |format|\n fo... | [
"0.6772849",
"0.64917743",
"0.6428765",
"0.63721323",
"0.6165484",
"0.60558903",
"0.6026885",
"0.5982841",
"0.5974675",
"0.5955185",
"0.5901697",
"0.5901697",
"0.5855717",
"0.5834792",
"0.5808997",
"0.58059824",
"0.57817113",
"0.5759111",
"0.57446694",
"0.57157654",
"0.570546... | 0.6779023 | 0 |
GET /analyses/new GET /analyses/new.xml | def new
@analysis = Analysis.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @analysis }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end",
"def new\n @analysis = Analysis.new\n @analysis.timestamp = DateTime.now\n @analysis.user = @current_user\n\n respond_to do |format|\n format.html # new.html.er... | [
"0.69392866",
"0.6789266",
"0.66893834",
"0.6675688",
"0.6631906",
"0.6558937",
"0.6550335",
"0.6550335",
"0.65308917",
"0.65308553",
"0.6506059",
"0.6504691",
"0.6504691",
"0.6504691",
"0.6498454",
"0.64920515",
"0.6475338",
"0.64432937",
"0.64432937",
"0.6434692",
"0.642770... | 0.74322903 | 0 |
POST /analyses POST /analyses.xml | def create
@analysis = Analysis.new(params[:analysis])
respond_to do |format|
if @analysis.save
flash[:notice] = 'Analysis was successfully created.'
format.html { redirect_to(@analysis) }
format.xml { render :xml => @analysis, :status => :created, :location => @analysis }
else
format.html { render :action => "new" }
format.xml { render :xml => @analysis.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def analyse\n begin\n response = resource[\"/analyse/#{app}\"].post(nil)\n rescue RestClient::InternalServerError\n display \"An error has occurred.\"\n end\n display response.to_s\n end",
"def analyses\n @project = Project.find(params[:id])\n @analyses = Analysis.all\n\n respond_... | [
"0.6425571",
"0.59371984",
"0.57764775",
"0.5743223",
"0.5729018",
"0.5696673",
"0.5617375",
"0.5617175",
"0.55814236",
"0.55634046",
"0.55474305",
"0.54355496",
"0.54304826",
"0.53618896",
"0.5320707",
"0.5267444",
"0.5258678",
"0.5241338",
"0.52239823",
"0.51933265",
"0.516... | 0.6268223 | 1 |
PUT /analyses/1 PUT /analyses/1.xml | def update
@analysis = Analysis.find(params[:id])
respond_to do |format|
if @analysis.update_attributes(params[:analysis])
flash[:notice] = 'Analysis was successfully updated.'
format.html { redirect_to(@analysis) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @analysis.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def upd... | [
"0.6105952",
"0.59916246",
"0.5940907",
"0.59295595",
"0.588455",
"0.57596916",
"0.5639209",
"0.56328565",
"0.56250495",
"0.56088066",
"0.5598953",
"0.5542237",
"0.55339074",
"0.5524765",
"0.546356",
"0.54633325",
"0.5454383",
"0.5442759",
"0.5377749",
"0.5375399",
"0.5357950... | 0.63127905 | 0 |
DELETE /analyses/1 DELETE /analyses/1.xml | def destroy
@analysis = Analysis.find(params[:id])
@analysis.destroy
respond_to do |format|
format.html { redirect_to(analyses_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_analysis(analysis_id); rest_delete(\"#{link('analyses')}/#{analysis_id}\"); nil; end",
"def destroy\n @analysis = Analysis.find(params[:id])\n @analysis.destroy\n\n respond_to do |format|\n format.html { redirect_to analyses_url }\n format.json { head :no_content }\n end\n end",... | [
"0.7660205",
"0.66775215",
"0.6524135",
"0.6513297",
"0.6455363",
"0.6352466",
"0.63412607",
"0.63316983",
"0.6323436",
"0.6323436",
"0.63023746",
"0.6282524",
"0.62748927",
"0.62522566",
"0.62409776",
"0.62383294",
"0.6204521",
"0.61705935",
"0.6169934",
"0.61601245",
"0.614... | 0.7237264 | 1 |
Returns the folder, if any, that this item is located in. | def folder
query = Builder::XmlMarkup.new.Query do |xml|
xml.Where do |xml|
xml.Eq do |xml|
xml.FieldRef(:Name => "FileRef")
xml.Value(::File.dirname(url).sub(/\A\//, ""), :Type => "Text")
end
xml.Eq do |xml|
xml.FieldRef(:Name => "FSObjType")
xml.Value(1, :Type => "Text")
end
end
end
@list.items(:folder => :all, :query => query).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFolder\r\n\t\t\t\t\treturn @folder\r\n\t\t\t\tend",
"def folder\n @folders[@folder_name]\n end",
"def folder\n connection.directories.get(folder_name)\n end",
"def folder\n model.folder\n end",
"def folder\n @attributes[:folder]\n end",
"def folder\n mods_ng_xml.... | [
"0.771551",
"0.76546943",
"0.7363135",
"0.7285556",
"0.72730404",
"0.72681826",
"0.72648233",
"0.71772796",
"0.71586424",
"0.7124299",
"0.7112678",
"0.7095446",
"0.7021988",
"0.69882625",
"0.69081354",
"0.6867199",
"0.6847285",
"0.6770661",
"0.6770661",
"0.67124707",
"0.67082... | 0.70756567 | 12 |
Returns the parent of this item. | def parent
folder || @list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent\n return @parent\n end",
"def parent\n tree.parent_for(parent_id).first\n end",
"def parent\n\n h.parent_id ?\n Ruote::Exp::FlowExpression.fetch(@context, h.parent_id) :\n nil\n end",
"def parent\n if parent_id.blank? then nil else unsco... | [
"0.80635566",
"0.793164",
"0.78293824",
"0.7824523",
"0.7664971",
"0.76544684",
"0.76544684",
"0.76544684",
"0.76544684",
"0.76009125",
"0.7590537",
"0.7587209",
"0.7509505",
"0.74179596",
"0.7383196",
"0.73757476",
"0.7361064",
"0.73341835",
"0.7332719",
"0.73322594",
"0.733... | 0.7046775 | 47 |
The URL of this item | def url
# URL(@list.url).join(attributes["ServerUrl"]).to_s
attributes["ServerUrl"]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_url(item)\n item.url\n end",
"def item_url(item)\n item.url\n end",
"def url\n item_path(object)\n end",
"def url\n @url.to_s\n end",
"def url\n item_hash.deep_find([:listing_details, :view_item_url])\n end",
"def url\n @attributes[:url]\n end",
"def url... | [
"0.85932523",
"0.85932523",
"0.8416693",
"0.8232581",
"0.80338997",
"0.7999243",
"0.7999243",
"0.7954824",
"0.7954824",
"0.79539776",
"0.79224974",
"0.789453",
"0.779038",
"0.7766667",
"0.7766667",
"0.7758178",
"0.7710354",
"0.76893026",
"0.76893026",
"0.76893026",
"0.7689302... | 0.76178753 | 25 |
Returns a list of the URLs of the attachments of this item. Note that for items in a document library, this returns an empty list | def attachment_urls
@list.when_list do
result = call("Lists", "get_attachment_collection", "listName" => @list.id, "listItemID" => @id)
return result.xpath("//sp:Attachment", NS).map { |att| att.text }
end
@list.when_document_library { raise TypeError, "a document library does not support attachments" }
@list.raise_on_unknown_type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attachment_uris\n Array.wrap(attachments).uniq.delete_if(&:empty?)\n end",
"def attachments\n parts.attachments\n end",
"def attachments\n mail&.attachments || []\n end",
"def attachments\n return @attachments\n end",
"def attachments\n ... | [
"0.73623776",
"0.7333392",
"0.72295773",
"0.72190833",
"0.72190833",
"0.72190833",
"0.7084423",
"0.70817184",
"0.70405227",
"0.6965385",
"0.6965385",
"0.69435817",
"0.6885137",
"0.68736243",
"0.6856562",
"0.68476707",
"0.6824771",
"0.6800987",
"0.6794557",
"0.6609665",
"0.655... | 0.8440667 | 0 |
Yields each attachment as a ActiveSP::File object. | def each_attachment
attachment_urls.each { |url| yield ActiveSP::File.new(self, url, true) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle\n attachments.each do |attachment|\n handle_attachment attachment\n end\n end",
"def attachment\n mail.attachments.map do |attachment|\n blob = ActiveStorage::Blob.create_after_upload!(\n io: StringIO.new(attachment.decoded),\n filename: attachment... | [
"0.6408003",
"0.6160053",
"0.6111426",
"0.60513467",
"0.6014009",
"0.6012748",
"0.5995339",
"0.5995046",
"0.59663886",
"0.59526294",
"0.59239733",
"0.5904078",
"0.58884555",
"0.5883644",
"0.5883644",
"0.5883644",
"0.58651596",
"0.58052665",
"0.5774973",
"0.5766491",
"0.576422... | 0.8507082 | 0 |
Returns the content type of this item | def content_type
ContentType.new(@site, @list, attributes["ContentTypeId"])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_content_type\n self.content_type\n end",
"def content_type\n @resource.content_type\n end",
"def content_type\n @content_type || object.content_type\n end",
"def content_type\n return @content_type\n end",
"def content_type\n cont... | [
"0.8419225",
"0.82399523",
"0.8103237",
"0.8049948",
"0.80344784",
"0.79754966",
"0.78767174",
"0.7739248",
"0.7739044",
"0.76506984",
"0.7483886",
"0.74371713",
"0.742692",
"0.73864996",
"0.7369302",
"0.73488635",
"0.7304005",
"0.7259388",
"0.7246385",
"0.71304303",
"0.71290... | 0.79360926 | 6 |
GET /powder_types GET /powder_types.json | def index
@powder_types = PowderType.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end",
"def get_lesson_types\n get \"lessonTypes.json\"\n end",
"def index\n types = @user.tried_beer_ratings.last.beer_types.map do |type|\n {name: type.name, description: type.beg_description}\n end\n render j... | [
"0.68819445",
"0.66947824",
"0.64733344",
"0.64331305",
"0.6361216",
"0.6335951",
"0.6332069",
"0.63229144",
"0.6240877",
"0.6198508",
"0.6193715",
"0.61533326",
"0.60503626",
"0.6048162",
"0.603429",
"0.601078",
"0.5989886",
"0.595392",
"0.5937564",
"0.5924754",
"0.59174347"... | 0.74135834 | 0 |
GET /powder_types/1 GET /powder_types/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @powder_types = PowderType.all\n end",
"def set_powder_type\n @powder_type = PowderType.find(params[:id])\n end",
"def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end",
"def create\n @powder_type = PowderType.new(powder_type_params)\n\n respond_to ... | [
"0.7292787",
"0.6539536",
"0.65082324",
"0.64359987",
"0.6319022",
"0.6293111",
"0.62561506",
"0.6237303",
"0.6212432",
"0.6168964",
"0.6136393",
"0.6094419",
"0.60336566",
"0.60332173",
"0.59914964",
"0.59822655",
"0.5969332",
"0.5954606",
"0.59483284",
"0.59429127",
"0.5936... | 0.0 | -1 |
POST /powder_types POST /powder_types.json | def create
@powder_type = PowderType.new(powder_type_params)
respond_to do |format|
if @powder_type.save
format.html { redirect_to @powder_type, notice: 'Powder type was successfully created.' }
format.json { render :show, status: :created, location: @powder_type }
else
format.html { render :new }
format.json { render json: @powder_type.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def powder_type_params\n params.require(:powder_type).permit(:name)\n end",
"def index\n @powder_types = PowderType.all\n end",
"def set_powder_type\n @powder_type = PowderType.find(params[:id])\n end",
"def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end",
... | [
"0.70705366",
"0.63616943",
"0.61782724",
"0.6115715",
"0.60138613",
"0.59946555",
"0.5941116",
"0.5919691",
"0.5919691",
"0.59067214",
"0.58862746",
"0.58862746",
"0.5810867",
"0.5770871",
"0.5714389",
"0.57093304",
"0.56911665",
"0.5636707",
"0.5632121",
"0.5631127",
"0.562... | 0.7219083 | 0 |
PATCH/PUT /powder_types/1 PATCH/PUT /powder_types/1.json | def update
respond_to do |format|
if @powder_type.update(powder_type_params)
format.html { redirect_to @powder_type, notice: 'Powder type was successfully updated.' }
format.json { render :show, status: :ok, location: @powder_type }
else
format.html { render :edit }
format.json { render json: @powder_type.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @power_rack_type.update(power_rack_type_params)\n format.html { redirect_to @power_rack_type, notice: \"Power rack type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @power_rack_type }\n else\n format.ht... | [
"0.64318657",
"0.64292175",
"0.6375794",
"0.6371024",
"0.63696635",
"0.6364143",
"0.63560766",
"0.62483406",
"0.61996984",
"0.61977565",
"0.6182283",
"0.6149517",
"0.614341",
"0.612934",
"0.61221445",
"0.6120205",
"0.6107569",
"0.61062014",
"0.61052155",
"0.6101157",
"0.60789... | 0.7533385 | 0 |
DELETE /powder_types/1 DELETE /powder_types/1.json | def destroy
@powder_type.destroy
respond_to do |format|
format.html { redirect_to powder_types_url, notice: 'Powder type was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @jewelry_type = JewelryType.find(params[:id])\n @jewelry_type.destroy\n\n respond_to do |format|\n format.html { redirect_to jewelry_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @dishtype.destroy\n respond_to do |format|\n format.html { redir... | [
"0.695513",
"0.69059044",
"0.68505234",
"0.68429965",
"0.68023187",
"0.67592853",
"0.6755317",
"0.67161447",
"0.66943306",
"0.66921407",
"0.6684755",
"0.66747487",
"0.66715217",
"0.6660847",
"0.66496605",
"0.6647351",
"0.66430414",
"0.66427475",
"0.66395",
"0.66391844",
"0.66... | 0.7723053 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_powder_type
@powder_type = PowderType.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 powder_type_params
params.require(:powder_type).permit(:name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981269",
"0.6783559",
"0.6746007",
"0.67423046",
"0.6735905",
"0.6593568",
"0.6504213",
"0.649792",
"0.6482664",
"0.6478558",
"0.64566684",
"0.64392304",
"0.6380194",
"0.6376366",
"0.636562",
"0.63208145",
"0.63006365",
"0.63001287",
"0.6292953",
"0.62927175",
"0.62911004... | 0.0 | -1 |
import_data: upload_preprocessing: header: file_origination_type: message: paypal: "custom message text..." mailchimp: "custom message..." | def header_message_text
I18n.t(".header.file_origination_type.message.#{file_origination_type.type_sym}",
scope: i18n_scope,
# fallback
default: I18n.t('.header.message', file_origination_type: file_origination_type.name, scope: i18n_scope)
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_type_import_body(uploaded_file)\n { 'fileUpload' => UploadIO.new(uploaded_file, uploaded_file.content_type, uploaded_file.original_filename) }\n end",
"def import_statement\n if params[:file_upload] && params[:file_upload][:file]\n csv_text = params[:file_upload][:file].read\n ... | [
"0.6205935",
"0.6088891",
"0.59662473",
"0.58731705",
"0.5861962",
"0.5853406",
"0.58532834",
"0.5852467",
"0.5813956",
"0.57193226",
"0.5703528",
"0.567965",
"0.5667047",
"0.56581134",
"0.5647306",
"0.5622486",
"0.56105375",
"0.5594939",
"0.5568658",
"0.555835",
"0.55536133"... | 0.0 | -1 |
install redis3.2.11 1. check 2. copy package file 3. build source code | def install_redis(ips)
print "==== Begin install redis on follow server(s). " + ips.join(', ') + " ====\n"
ips.each { |ip|
have_redis_32 = `ssh redis@#{ip} "stat redis-3.2.11"`
if have_redis_32 == ""
# install redis
print "Install redis-3.2.11 ...\n"
system "scp ~/redis-3.2.11.tar.gz redis@#{ip}:."
if $?.to_i != 0
abort "Copy redis-3.2.11.tar.gz to remote host failed!"
end
system "ssh redis@#{ip} 'tar -zxf redis-3.2.11.tar.gz && cd redis-3.2.11 && make'"
if $?.to_i != 0
abort "Build redis-3.2.11 failed!"
end
print "Redis install complete!\n"
else
print "Redis-3.2.11 already installed!\n"
end
}
print "\n==== All install completed! ====\n\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_installation\n #start logging\n set_log_file @options[:log]\n \n download_and_decompress(@options[:prefix], [REDIS_URL, SQLITE3_URL, NGINX_URL])\n \n install_redis if @options[:redis]\n install_sqlite\n configure_nginx @options\n\n install_all_gems\n install_rhoconnect\n ... | [
"0.7222129",
"0.66213834",
"0.66213834",
"0.6618064",
"0.64675254",
"0.6438933",
"0.6397723",
"0.62967217",
"0.627654",
"0.6229145",
"0.62284404",
"0.61819977",
"0.61756265",
"0.6143271",
"0.61428714",
"0.614215",
"0.6139282",
"0.61263704",
"0.61142606",
"0.61139446",
"0.6112... | 0.7143574 | 1 |
Assert options are not in conflict | def assert_no_conflict
if length and (minimum or maximum)
raise ":length option is XOR to (:minimum or :maximum)"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_valid_options\n valid_options = {\n skip_gemfile: false,\n skip_bundle: false,\n skip_git: false,\n skip_system_test: false,\n # skip_test: false,\n # skip_test_unit: false,\n edge: false\n }\n valid_options.each do |key, expected|\n next unless options.key?(key)... | [
"0.7934469",
"0.7927344",
"0.79174644",
"0.7911735",
"0.71878695",
"0.6962977",
"0.67977214",
"0.67625356",
"0.6759148",
"0.66293454",
"0.6616687",
"0.6591614",
"0.6583588",
"0.6548775",
"0.65206206",
"0.65206206",
"0.65206206",
"0.65206206",
"0.65206206",
"0.65206206",
"0.65... | 0.6375794 | 31 |
Assert options are not empty | def assert_not_empty
if options.empty?
raise ":length, :maxmimum or :minimum must be given as option"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_options_empty!(options)\n unless options.empty?\n raise ConfigurationError, \"unknown options #{options.inspect} for #{self}\"\n end\n end",
"def test_option_required\n\n # All options are optional by default\n assert(!Option.new(nil, nil).required)\n assert(!Option.new(\"... | [
"0.77065283",
"0.74596435",
"0.74060845",
"0.7375208",
"0.7365307",
"0.73295337",
"0.72583115",
"0.7228087",
"0.7188636",
"0.6883076",
"0.6808192",
"0.679949",
"0.6748979",
"0.67111397",
"0.66981596",
"0.6673912",
"0.663537",
"0.66256225",
"0.6620605",
"0.6619281",
"0.6596080... | 0.8034163 | 0 |
Scraper Objects can be created from either a full URL (string), or a Hash. Currently, this initializer isn't intended to be called from libcraigslist API users, though if you know what you're doing feel free to try this out. A (string) url can be passed in a ' scheme or a 'file://' scheme. When constructing from a hash, the keys in the hash will be used to set the object's corresponding values. This is useful to create an object without actually making an html request, this is used to setup an object before it eagerloads any values not already passed in by the constructor hash. Though optional, if you're going to be setting this object up for eagerloadnig, be sure to pass in a :url key in your hash, Otherwise this will fail to eager load. | def initialize(init_via = nil)
if init_via.nil?
# Do nothing - possibly not a great idea, but we'll allow it
elsif init_via.kind_of? String
@url = init_via
elsif init_via.kind_of? Hash
init_via.each_pair{|k,v| instance_variable_set "@#{k}", v}
else
raise BadConstructionError, ("Unrecognized parameter passed to %s.new %s}" % [self.class.to_s, init_via.class.inspect])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(url_or_obj, html = '')\n # Init from URL String and HTML String.\n if url_or_obj.is_a?(String)\n url = url_or_obj\n assert_type(url, Wgit::Url)\n\n @url = url\n @html = html || ''\n @doc = init_nokogiri\n @score = 0.0\n\n process_url_and_htm... | [
"0.71776164",
"0.69076663",
"0.68354017",
"0.6819023",
"0.67598724",
"0.6703565",
"0.6699014",
"0.6686823",
"0.66791457",
"0.66639733",
"0.6653403",
"0.6612369",
"0.65667236",
"0.65358746",
"0.65243715",
"0.6490533",
"0.6485627",
"0.648017",
"0.6455439",
"0.6421856",
"0.64218... | 0.0 | -1 |
Indicates whether the resource has yet been retrieved from its associated url. This is useful to distinguish whether the instance was instantiated for the purpose of an eagerload, but hasn't yet been fetched. | def downloaded?; !@html_source.nil?; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetched?\n @fetched\n end",
"def need_to_fetch?\n @need_to_fetch = true if @need_to_fetch.nil?\n @need_to_fetch\n end",
"def retrieved?\n @retrieved\n end",
"def loaded?\n self.response_data.present?\n end",
"def is_fetched\n @status == Status::FETCHED\n end... | [
"0.6948728",
"0.6784541",
"0.67241454",
"0.67137086",
"0.6699746",
"0.6669078",
"0.6613518",
"0.6613518",
"0.65512896",
"0.6519973",
"0.6489211",
"0.64803404",
"0.64775723",
"0.63661",
"0.6359417",
"0.63543296",
"0.63465846",
"0.6343007",
"0.6334126",
"0.6333673",
"0.63263357... | 0.0 | -1 |
A URI object corresponding to this Scraped URL | def uri
@uri ||= URI.parse @url if @url
@uri
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uri\n @_uri ||= URI(@url)\n end",
"def uri\n @_uri ||= URI(@url)\n end",
"def uri\n @uri ||= URI(url)\n end",
"def uri\n @uri ||= URI.parse(url)\n end",
"def url\n uri\n end",
"def url\n uri\n end",
"def url\n uri.to_s\n end",
... | [
"0.7954139",
"0.7954139",
"0.78322953",
"0.7751324",
"0.7713539",
"0.7713539",
"0.75786567",
"0.75646836",
"0.7540713",
"0.74514616",
"0.74136627",
"0.7384851",
"0.7367896",
"0.7367896",
"0.73563594",
"0.73563594",
"0.73001623",
"0.7298705",
"0.7298705",
"0.7279082",
"0.72790... | 0.78730094 | 2 |
Returns text with all html tags removed. | def strip_html(str)
str.gsub HTML_TAG, "" if str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_html_tags(text)\n return text.gsub!(/(<[^>]*>)|\\n|\\t/s) {\" \"}\n end",
"def text\n html.gsub(REGEX_TAGS, \"\")\n end",
"def strip_tags(html)\n return html if html.blank?\n if html.index(\"<\")\n text = \"\"\n tokenizer = ::HTML::Tokenizer.new(html)\n ... | [
"0.8641585",
"0.83864087",
"0.8270129",
"0.82437706",
"0.8151394",
"0.8151394",
"0.8151394",
"0.8128579",
"0.8085585",
"0.79210424",
"0.7902105",
"0.7827597",
"0.7755981",
"0.7733356",
"0.7596208",
"0.75726014",
"0.75726014",
"0.7526872",
"0.75231665",
"0.74633527",
"0.743414... | 0.74993265 | 19 |
Easy way to fail noisily: | def parse_error!; raise ParseError, "Error while parsing %s:\n %s" % [self.class.to_s, html]; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fail\n # no-op\n end",
"def fail\n end",
"def do_failure; end",
"def fail\n\t\t# throw up this code and feed plezi your own lines :)\n\t\traise \"Plezi raising hell!\"\n\tend",
"def fail!\n @__result.fail!\n throw :fail\n end",
"def failure!\n end",
"def fail!\n @success = f... | [
"0.8287497",
"0.7809673",
"0.7737834",
"0.7543467",
"0.75300884",
"0.7410049",
"0.7371298",
"0.7371298",
"0.7371084",
"0.73119664",
"0.72517896",
"0.7236896",
"0.7226419",
"0.72108686",
"0.71715194",
"0.7169749",
"0.71122545",
"0.7081328",
"0.703822",
"0.703822",
"0.703822",
... | 0.0 | -1 |
Returns text with all html entities converted to respective ascii character. | def he_decode(text); self.class.he_decode text; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_html_entities\n unpack('U*').map! {|c| \"&##{c};\"}.join\n end",
"def convert_entity(text)\n text = Iconv.new('iso-8859-15', 'utf-8').iconv(text) \n \n feed = text.inspect[1...-1]\n\n feed.gsub!(/\\\\([0-7]+)|(.)/m) do\n if $2\n $&\n else\n '&#%s;' %... | [
"0.7662929",
"0.7646996",
"0.7280278",
"0.7112097",
"0.7112097",
"0.7110469",
"0.6991957",
"0.69715583",
"0.6966198",
"0.69051677",
"0.6853995",
"0.6737035",
"0.67221403",
"0.6684916",
"0.6675067",
"0.66521543",
"0.6649336",
"0.6643164",
"0.6574212",
"0.6559693",
"0.653454",
... | 0.0 | -1 |
Derives a full url, using the current object's url and the provided href | def url_from_href(href) #:nodoc:
scheme, host, path = $1, $2, $3 if URL_PARTS.match href
scheme = uri.scheme if scheme.nil? or scheme.empty? and uri.respond_to? :scheme
host = uri.host if host.nil? or host.empty? and uri.respond_to? :host
path = (
(/\/$/.match(uri.path)) ?
'%s%s' % [uri.path,path] :
'%s/%s' % [File.dirname(uri.path),path]
) unless /^\//.match path
'%s://%s%s' % [scheme, host, path]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url(href)\n a href, :href => href\n end",
"def absolute_url(href)\n Addressable::URI.join(self.class::DOMAIN, href).to_s\n end",
"def href\n @href ||= raw\n .fetch(\"_links\",{})\n .fetch(\"self\",{})\n .fetch(\"href\",nil)\n end",
"def url_for(o... | [
"0.7331412",
"0.6854611",
"0.6842081",
"0.6771461",
"0.67542684",
"0.6734541",
"0.66811615",
"0.6677204",
"0.66127604",
"0.6587276",
"0.65658337",
"0.65125424",
"0.6511494",
"0.6475982",
"0.6460172",
"0.6435356",
"0.64226025",
"0.6412037",
"0.63852584",
"0.63819396",
"0.63633... | 0.7152325 | 1 |
Returns a string, of the current URI's source code | def html_source
@html_source ||= fetch_uri uri if uri
@html_source
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getURI()\n return @uri.to_s\n end",
"def code\n path\n end",
"def view_source\n File.read(@script)\n end",
"def source\n @source ||= raw_source.split(\"---\\n\")[2]\n end",
"def source\n @source ||= raw_source.split(\"---\\n\")[2]\n end",
"def source_file\n ... | [
"0.66146487",
"0.64806575",
"0.6386445",
"0.6371204",
"0.6371204",
"0.63710475",
"0.6346726",
"0.6299783",
"0.6285436",
"0.6285436",
"0.6285436",
"0.6244561",
"0.6244561",
"0.62150747",
"0.61869097",
"0.615802",
"0.6105973",
"0.6064033",
"0.6051755",
"0.6029925",
"0.6015661",... | 0.59645444 | 25 |
Returns an Nokogiri parse, of the current URI | def html
@html ||= Nokogiri::HTML html_source, nil, HTML_ENCODING if html_source
@html
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(uri); end",
"def uri\n @uri ||= URI.parse @url if @url\n @uri\n end",
"def uri\n @uri ||= URI.parse(url)\n end",
"def parse_content(uri)\n Nokogiri::HTML request(uri)\n end",
"def uri\n @uri ||= URI(url)\n end",
"def parse_uri(uri)\n html = URI(normalize_uri(... | [
"0.6857382",
"0.68382186",
"0.67221713",
"0.6247589",
"0.6119459",
"0.60918486",
"0.60248446",
"0.598272",
"0.5976308",
"0.5976308",
"0.5921151",
"0.5921151",
"0.58915484",
"0.58739406",
"0.5854966",
"0.58510566",
"0.5849439",
"0.5848376",
"0.5830157",
"0.5810323",
"0.5800502... | 0.0 | -1 |
Write your code here! | def game_hash
{
:home => {
:team_name => "Brooklyn Nets",
:colors => ["Black", "White"],
:players => [
{:player_name => "Alan Anderson",
:number => 0,
:shoe => 16,
:points => 22,
:rebounds => 12,
:assists => 12,
:steals => 3,
:blocks => 1,
:slam_dunks => 1
},
{:player_name => "Reggie Evans",
:number => 30,
:shoe => 14,
:points => 12,
:rebounds => 12,
:assists => 12,
:steals => 12,
:blocks => 12,
:slam_dunks => 7
},
{:player_name => "Brook Lopez",
:number => 11,
:shoe => 17,
:points => 17,
:rebounds => 19,
:assists => 10,
:steals => 3,
:blocks => 1,
:slam_dunks => 15
},
{:player_name => "Mason Plumlee",
:number => 1,
:shoe => 19,
:points => 26,
:rebounds => 11,
:assists => 6,
:steals => 3,
:blocks => 8,
:slam_dunks => 5
},
{:player_name => "Jason Terry",
:number => 31,
:shoe => 15,
:points => 19,
:rebounds => 2,
:assists => 2,
:steals => 4,
:blocks => 11,
:slam_dunks => 1
}
]
},
:away => {
:team_name => "Charlotte Hornets",
:colors => ["Turquoise", "Purple"],
:players => [
{:player_name => "Jeff Adrien",
:number => 4,
:shoe => 18,
:points => 10,
:rebounds => 1,
:assists => 1,
:steals => 2,
:blocks => 7,
:slam_dunks => 2
},
{:player_name => "Bismack Biyombo",
:number => 0,
:shoe => 16,
:points => 12,
:rebounds => 4,
:assists => 7,
:steals => 22,
:blocks => 15,
:slam_dunks => 10
},
{:player_name => "DeSagna Diop",
:number => 2,
:shoe => 14,
:points => 24,
:rebounds => 12,
:assists => 12,
:steals => 4,
:blocks => 5,
:slam_dunks => 5
},
{:player_name => "Ben Gordon",
:number => 8,
:shoe => 15,
:points => 33,
:rebounds => 3,
:assists => 2,
:steals => 1,
:blocks => 1,
:slam_dunks => 0
},
{:player_name => "Kemba Walker",
:number => 33,
:shoe => 15,
:points => 6,
:rebounds => 12,
:assists => 12,
:steals => 7,
:blocks => 5,
:slam_dunks => 12
}
]
}
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def how_it_works\r\n end",
"def code_point; end",
"def code_like_crazy\r\n puts \"I'm crushing some code!\"\r\n end",
"def method\n\t\t# code code\n\tend",
"def do... | [
"0.74495405",
"0.74495405",
"0.74495405",
"0.74495405",
"0.74495405",
"0.74495405",
"0.74495405",
"0.6596653",
"0.65341944",
"0.6443439",
"0.64351565",
"0.6343929",
"0.63352334",
"0.63352334",
"0.63352334",
"0.63352334",
"0.63352334",
"0.63352334",
"0.63352334",
"0.63352334",
... | 0.0 | -1 |
return two numbers from user input | def user_num
loop do
prompt(MESSAGES['number_request'])
num1 = Kernel.gets().chomp()
num2 = Kernel.gets().chomp()
if number?(num1) && number?(num2)
return num1, num2
else
prompt(MESSAGES['invalid_numbers'])
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def two_inputs\n puts \"Enter the first number\"\n first = gets.chomp.to_f\n puts \"Enter the second number\"\n second = gets.chomp.to_f\n return first, second\nend",
"def two_numbers\n puts \"Enter the first number.\"\n first_number = gets.chomp.to_f\n puts \"Enter the second number.\"\n second_number ... | [
"0.83768874",
"0.8280382",
"0.78953314",
"0.78103083",
"0.7731249",
"0.7731249",
"0.7613768",
"0.75754213",
"0.75754213",
"0.7575143",
"0.7314077",
"0.7305594",
"0.72806793",
"0.7051506",
"0.7040426",
"0.6894967",
"0.6864975",
"0.6836372",
"0.68029267",
"0.679668",
"0.6771487... | 0.8084529 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_project
@project = Project.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(
:overview, :featured_artist_name, :featured_artist_image_title, :synopsis, :materials,
:materials_suggestion, :books_media, :teachers_pay_teachers_link, :photocopy, :first_photocopy_header, :first_photocopy_url, :first_photocopy,
:second_photocopy, :second_photocopy_header, :second_photocopy_url, :third_photocopy, :third_photocopy_header,
:fourth_photocopy, :fourth_photocopy_header, :fifth_photocopy, :fifth_photocopy_header,
:sixth_photocopy, :sixth_photocopy_header, :photocopy_copyright, :common_core, :national_core,
:art_elements, :art_principles, :status, :core_content, :cross_curricular, :inspiration_image, :featured_artist_image,
:featured_artist_description, :engage_ny, :next_gen_sci,
sections_attributes: [:id, :order, :content]
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6979893",
"0.6781746",
"0.6746611",
"0.6742344",
"0.6735229",
"0.6592651",
"0.65027124",
"0.6498011",
"0.648163",
"0.647716",
"0.64556813",
"0.64386255",
"0.63784456",
"0.63756156",
"0.636574",
"0.6319542",
"0.63004524",
"0.6299559",
"0.62925464",
"0.62923217",
"0.6289894"... | 0.0 | -1 |
we want to say that a user instance belongs to something called a current_cart where current_cart is really an instance of Cart class for this to work, we need to have a current_cart_id on the user instance, so we generate migration | def create_current_cart
new_cart = self.carts.create # instantiate and save to DB new cart already belonging to user instance
self.current_cart_id = new_cart.id
self.save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cart\n super || Cart.create(user_id: self.id)\n end",
"def create_cart\n cart = Cart.new(user: self)\n cart.save\n end",
"def current_cart\n Cart.find_or_create_by(user: self, status: 0)\n end",
"def find_carts\n if current_cart != nil\n current_cart\n else\n Cart.create(us... | [
"0.6629738",
"0.65978086",
"0.64538467",
"0.63150656",
"0.6119139",
"0.60878384",
"0.6079224",
"0.58978343",
"0.589661",
"0.58524644",
"0.58465046",
"0.58267754",
"0.5782655",
"0.57715774",
"0.5735823",
"0.570942",
"0.5697607",
"0.56894565",
"0.5672091",
"0.5606148",
"0.55857... | 0.7103119 | 0 |
Send an activation email | def send_activation_email
UserMailer.account_activation(self).deliver_now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_activation_email\n ensure_activation_token_set\n UserMailer.account_activation(self, activation_token).deliver_later unless activated?\n end",
"def send_activation_email\n UserMailer.account_activation(self, activation_token).deliver_later\n end",
"def send_activation_email\n\t\tUserMailer.... | [
"0.86806804",
"0.8517354",
"0.84509254",
"0.8428694",
"0.84236044",
"0.8394186",
"0.83880407",
"0.8329578",
"0.83177215",
"0.82850856",
"0.8265149",
"0.8247958",
"0.82402223",
"0.8213157",
"0.8199101",
"0.8187544",
"0.81859267",
"0.81859267",
"0.8164154",
"0.8156599",
"0.8127... | 0.8317239 | 18 |
Send a password reset email | def send_password_reset_email
UserMailer.password_reset(self).deliver_now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_password_reset_email\n\t\tUserMailer.password_reset(id, self.reset_token).deliver_later\n \tend",
"def password_reset(user)\n mail_to user, password_reset_subject\n end",
"def password_reset\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def password_reset\n @greeting =... | [
"0.8647015",
"0.8522901",
"0.84881383",
"0.84881383",
"0.84881383",
"0.84538054",
"0.84455585",
"0.8442971",
"0.84251934",
"0.842367",
"0.841993",
"0.8419344",
"0.84176767",
"0.84164304",
"0.8409017",
"0.8406042",
"0.8406042",
"0.84050757",
"0.8400752",
"0.83967125",
"0.83967... | 0.0 | -1 |
Set password reset token | def set_reset_token
token = SecureRandom.urlsafe_base64
update_columns(reset_token: token, reset_sent_at: Time.zone.now)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_reset_password_token(token); end",
"def use_password_reset(token, new_password)\n put(\"/v1/password_resets/#{token}\", password: new_password)\n end",
"def set_password_reset\n self.make_password_reset_code\n end",
"def set_password_reset\n\t\tself.code = SecureRandom.urlsafe_base64\n\t... | [
"0.81237876",
"0.7953774",
"0.7848345",
"0.77726305",
"0.776301",
"0.77537584",
"0.77493846",
"0.7737957",
"0.7733033",
"0.7733033",
"0.7733033",
"0.7733033",
"0.7733033",
"0.7733033",
"0.7733033",
"0.773247",
"0.773247",
"0.7682614",
"0.7679417",
"0.76614803",
"0.76453525",
... | 0.7726081 | 17 |
Check correctness of given token | def authenticated?(column, token)
self[column] == token ? true : false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_token\n end",
"def valid_token?(token)\n exists?(:token => token)\n end",
"def validate token\r\n token =~ /[A-Za-z0-9]/\r\n end",
"def match_token(token)\n return true\n end",
"def token?(token)\n return false\n end",
"def valid?\n @token.valid?\n end",
"... | [
"0.82704127",
"0.8031142",
"0.79471827",
"0.766586",
"0.76347196",
"0.74696237",
"0.7397013",
"0.73790604",
"0.7321483",
"0.7300686",
"0.727617",
"0.727617",
"0.72411776",
"0.7165257",
"0.7144136",
"0.7136685",
"0.71012306",
"0.7100686",
"0.70838773",
"0.70741093",
"0.7069418... | 0.0 | -1 |
True if current user is following the other user | def following?(user)
following.include?(user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n ... | [
"0.85584617",
"0.8498403",
"0.8498403",
"0.8498403",
"0.8496552",
"0.8496552",
"0.8496552",
"0.8496552",
"0.84476835",
"0.843115",
"0.8400324",
"0.8395232",
"0.8395232",
"0.8395232",
"0.8395232",
"0.8395232",
"0.8395232",
"0.8395232",
"0.8395232",
"0.8395232",
"0.8395232",
... | 0.0 | -1 |
Return all microposts of current user and following users | def posts
following_ids = "SELECT followed_id FROM relationships
WHERE follower_id = :user_id"
Micropost.where("user_id IN (#{following_ids})
OR user_id = :user_id", user_id: id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def microposts \n @microposts = Micropost.where(user_id: current_user.followed_ids).order('created_at desc').all\n end",
"def feed\n #get all the user_ids the current_user are following\n following_ids = \"SELECT followed_id FROM relationships WHERE follower_id = :user_id\"\n\n #and then get all o... | [
"0.84509706",
"0.7714601",
"0.76625526",
"0.76625526",
"0.76625526",
"0.76625526",
"0.76625526",
"0.76625526",
"0.76625526",
"0.76625526",
"0.75696623",
"0.75696623",
"0.7558699",
"0.7517302",
"0.7480118",
"0.7460062",
"0.7456852",
"0.74489224",
"0.74432075",
"0.74371976",
"0... | 0.7337561 | 25 |
Validate size of the avatar | def avatar_size
if avatar.size > 5.megabytes
errors.add(:avatar, "should be less than 5MB")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def avatar_size\n if avatar.size > 5.megabytes\n errors.add(:avatar, \"should be less than 5MB\")\n end\n end",
"def avatar_size_validation\n\t\terrors[:avatar] << \"should be less than 5.0 MB\" if avatar.size > 5.0.megabytes\n\tend",
"def avatar_image_size\n errors.add(:avatar, 'should be l... | [
"0.8723641",
"0.87002194",
"0.86046624",
"0.84016955",
"0.81626076",
"0.8058546",
"0.80402905",
"0.7652096",
"0.7535511",
"0.75282896",
"0.7523537",
"0.75055224",
"0.74716926",
"0.7458601",
"0.74475783",
"0.7436078",
"0.74337",
"0.7377386",
"0.7373392",
"0.73673767",
"0.73632... | 0.8491002 | 5 |
GET /beacons GET /beacons.json | def index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def beacons\n response = request(:get, \"/beacon\")\n response_to_array(response, \"beacons\", KontaktIo::Resource::Beacon)\n end",
"def index\n @beacons = Beacon.filter(params)\n end",
"def index\n @beacons = @local.beacons.order :id\n @beacon = @local.beacons.build\n end",
"def show... | [
"0.7949965",
"0.7193661",
"0.6574756",
"0.63969475",
"0.5765501",
"0.57412636",
"0.5577298",
"0.55471295",
"0.5540525",
"0.5478239",
"0.54575163",
"0.5450813",
"0.5449088",
"0.5435481",
"0.5435194",
"0.54207486",
"0.5417795",
"0.5350018",
"0.53224003",
"0.5286656",
"0.5284362... | 0.0 | -1 |
GET /beacons/1 GET /beacons/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def beacons\n response = request(:get, \"/beacon\")\n response_to_array(response, \"beacons\", KontaktIo::Resource::Beacon)\n end",
"def index\n @beacons = Beacon.filter(params)\n end",
"def show\n @beacon = Beacon.find(params[:id])\n\n respond_to do |format|\n format.html # show.ht... | [
"0.73972666",
"0.6781352",
"0.6658611",
"0.6573958",
"0.59277546",
"0.5894682",
"0.5876333",
"0.5732796",
"0.56043154",
"0.5576484",
"0.5555633",
"0.5542092",
"0.5506389",
"0.5477931",
"0.54540944",
"0.5424354",
"0.54221725",
"0.5414956",
"0.54049945",
"0.54049945",
"0.540452... | 0.0 | -1 |
POST /beacons POST /beacons.json | def create
#beacon.owner_id = params[:id]
@beacon = Beacon.new(beacon_params)
@beacon.owner_id = $owner.id
respond_to do |format|
#temporal
if params[:activate_gimbal]
status_code = Beacon.gimbal_create_beacon(@beacon)
if status_code == "200"
if @beacon.save
format.html { redirect_to @beacon, notice: 'Beacon was successfully created.' }
format.json { render :template => "owners/show", status: :created, location: @beacon }
else
format.html { render :new }
format.json { render json: @beacon.errors, status: :unprocessable_entity }
end
elsif status_code == "422"
@beacon.errors.add(:factory_id, "Beacon already activated")
format.html { render :new }
format.json { render json: @beacon.errors, status: :unprocessable_entity }
else
@beacon.errors.add(:factory_id, "Invalid Id")
format.html { render :new }
format.json { render json: @beacon.errors, status: :unprocessable_entity }
#render json: {status: "Invalid Beacon"}, status: 404
end
else
if @beacon.save
format.html { redirect_to @beacon, notice: 'Beacon was successfully created.' }
format.json { render :template => "owners/show", status: :created, location: @beacon }
else
format.html { render :new }
format.json { render json: @beacon.errors, status: :unprocessable_entity }
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @beacon = Beacon.new(params[:beacon])\n\n respond_to do |format|\n if @beacon.save\n format.html { redirect_to @beacon, notice: 'Beacon was successfully created.' }\n format.json { render json: @beacon, status: :created, location: @beacon }\n else\n format.html { r... | [
"0.67750245",
"0.6494365",
"0.621108",
"0.6177578",
"0.6095913",
"0.5827834",
"0.57616925",
"0.57121044",
"0.56953675",
"0.5692302",
"0.56070703",
"0.5591909",
"0.54145",
"0.5383675",
"0.53774554",
"0.5339809",
"0.5336639",
"0.5242555",
"0.51948744",
"0.5186133",
"0.5167707",... | 0.5569754 | 12 |
PATCH/PUT /beacons/1 PATCH/PUT /beacons/1.json | def update
respond_to do |format|
if @beacon.update(beacon_params)
Beacon.gimbal_update_beacon(@beacon)
format.html { redirect_to @beacon, notice: 'Beacon was successfully updated.' }
format.json { render :template => "owners/show", status: :ok, location: @beacon }
else
format.html { render :edit }
format.json { render json: @beacon.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @beacon = Beacon.find(params[:id])\n\n respond_to do |format|\n if @beacon.update_attributes(params[:beacon])\n format.html { redirect_to @beacon, notice: 'Beacon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: ... | [
"0.6659635",
"0.6629492",
"0.594788",
"0.5892712",
"0.58209485",
"0.58152115",
"0.5725124",
"0.57093096",
"0.56321836",
"0.5629328",
"0.55783314",
"0.556753",
"0.55658096",
"0.55569655",
"0.55441135",
"0.5523978",
"0.5499616",
"0.548218",
"0.54729754",
"0.54538953",
"0.544992... | 0.5723691 | 7 |
DELETE /beacons/1 DELETE /beacons/1.json | def destroy
@beacon.destroy
respond_to do |format|
Beacon.gimbal_delete_beacon(@beacon)
format.html { redirect_to owner_path(@beacon.owner), notice: 'Beacon was successfully deactivated.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @beacon = Beacon.find(params[:id])\n @beacon.destroy\n\n respond_to do |format|\n format.html { redirect_to beacons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @beacon.destroy\n DateUpdate.new().save\n respond_to do |format|\n format.ht... | [
"0.74951106",
"0.68532497",
"0.67471033",
"0.6370973",
"0.63429356",
"0.6332982",
"0.628903",
"0.6275819",
"0.6273216",
"0.6154853",
"0.6126426",
"0.61042124",
"0.60527426",
"0.6029466",
"0.59900993",
"0.597333",
"0.59629214",
"0.58933985",
"0.58915484",
"0.5883959",
"0.58669... | 0.67001647 | 3 |
Use callbacks to share common setup or constraints between actions. | def set_beacon
@beacon = Beacon.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 beacon_params
params.require(:beacon).permit(:name, :factory_id, :description, :latitude, :longitude, :owner_id, activate_gimbal: [])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981269",
"0.6783559",
"0.6746007",
"0.67423046",
"0.6735905",
"0.6593568",
"0.6504213",
"0.649792",
"0.6482664",
"0.6478558",
"0.64566684",
"0.64392304",
"0.6380194",
"0.6376366",
"0.636562",
"0.63208145",
"0.63006365",
"0.63001287",
"0.6292953",
"0.62927175",
"0.62911004... | 0.0 | -1 |
Given a hash of settings, processes and connects to an IRC server. | def initialize(settings)
@settings = settings
@botname = settings["botname"]
@server = settings["server"]
@port = settings["port"]
@channel = settings["channel"]
@socket = TCPSocket.open(@server, @port)
connect # to IRC channel
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start\n @quit = nil\n @socket = self.connect()\n self.on_message(/^PING/) { |event|\n self.send_raw_line(\"PING \"+event[:matchdata].post_match)\n }\n self.on_server_message(353) { |event|\n }\n self.on_server_message(376) do |event|\n if @password and !@authenticated then\n ... | [
"0.61990106",
"0.5973141",
"0.59553176",
"0.5784713",
"0.57420677",
"0.5697881",
"0.5679598",
"0.5587547",
"0.5558169",
"0.5529845",
"0.5501101",
"0.54975635",
"0.5475789",
"0.54669577",
"0.5397013",
"0.53765786",
"0.5373161",
"0.53515047",
"0.5335843",
"0.5334323",
"0.532811... | 0.66687065 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.