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 |
|---|---|---|---|---|---|---|
Checks the number of parameters in the given method. | def examine_context(ctx)
@max_allowed_params = value(MAX_ALLOWED_PARAMS_KEY, ctx, DEFAULT_MAX_ALLOWED_PARAMS)
num_params = ctx.exp.arg_names.length
return [] if num_params <= @max_allowed_params
smell = SmellWarning.new(SMELL_CLASS, ctx.full_name, [ctx.exp.line],
"has #{num_par... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_arguments_count(input_params)\n return if input_params.count >= declared_params.count\n raise ArgumentError, \"#{declared_params.count} parameters expected.\"\n end",
"def acceptable_argument_count\n parameters = @object.method(@method).parameters\n min_args = parameters.select{ |a... | [
"0.73268956",
"0.6971698",
"0.6959385",
"0.67857915",
"0.67684084",
"0.67091495",
"0.6694818",
"0.6630791",
"0.65810245",
"0.6559625",
"0.6551332",
"0.6443914",
"0.6334756",
"0.6323206",
"0.63135165",
"0.62619144",
"0.62471783",
"0.62385625",
"0.62341255",
"0.61937433",
"0.61... | 0.0 | -1 |
Render inline css Source: | def inline_css(name)
sprockets["#{name}.css"].to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inline_stylesheet source\n \"<style type='text/css'>\" +\n File.read(\"#{RAILS_ROOT}/public/stylesheets/#{source}\") +\n \"</style>\"\n end",
"def css_render\n css_list.join(\"\\n\")\n end",
"def css; end",
"def css; end",
"def css; end",
"def css_code\n '<style type=\"te... | [
"0.73388714",
"0.7177927",
"0.7145281",
"0.7145281",
"0.7145281",
"0.69604695",
"0.6903996",
"0.68207973",
"0.68207973",
"0.68207973",
"0.68207973",
"0.67115486",
"0.65801316",
"0.6567717",
"0.65592366",
"0.65117866",
"0.6504101",
"0.64504164",
"0.642595",
"0.6414162",
"0.639... | 0.64273715 | 18 |
Converts any volume unit to fluid ounces | def convert_to_fl_oz(amount, unit)
case unit
when 'gallon' then amount * 128
when 'quart' then amount * 32
when 'pint' then amount * 16
when 'cup' then amount * 8
when 'fl_oz' then amount
when 'Tbsp' then amount * 0.5
when 'tsp' then amount * 0.1666666666667
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_volume_cuft\n self.volume_cuft = (self.length_ins/12) * (self.width_ins/12) * (self.height_ins/12)\n end",
"def unit \n\t\t\tunitq = self.dup\n\t\t\tmagnitude = self.abs\n\t\t\tunitq[0] /= magnitude\n\t\t\tunitq[1] /= magnitude\n\t\t\tunitq[2] /= magnitude\n\t\t\tunitq[3] /= magnitude\n\t\t\treturn u... | [
"0.63185173",
"0.62543666",
"0.619648",
"0.61569655",
"0.6132664",
"0.61048853",
"0.6023394",
"0.5948282",
"0.57917583",
"0.5787916",
"0.5677867",
"0.56621045",
"0.5655582",
"0.56539744",
"0.565364",
"0.5649837",
"0.56407523",
"0.5622799",
"0.56084067",
"0.56078565",
"0.55997... | 0.5966355 | 7 |
< for display, saves 2 lines | def initialize(name) # All tech has a name, no?
@name = name
@labs = []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n \"\\t#{@line}: #{first_line}\"\n end",
"def show_line\n say \"=\" * 25\nend",
"def show\n\t puts \"\t#{@spaces[0]} #{@spaces[1]} #{@spaces[2]}\"\n\t puts \"\t#{@spaces[3]} #{@spaces[4]} #{@spaces[5]}\"\n\t puts \"\t#{@spaces[6]} #{@spaces[7]} #{@spaces[8]}\"\n\tend",
"def hline_top\n\t... | [
"0.6524168",
"0.6281164",
"0.620696",
"0.6149297",
"0.6138587",
"0.6100393",
"0.6074554",
"0.6027136",
"0.6015493",
"0.60114795",
"0.6003745",
"0.59653664",
"0.59642315",
"0.59380025",
"0.5906678",
"0.58989495",
"0.58560777",
"0.5827698",
"0.5815967",
"0.58006495",
"0.5786588... | 0.0 | -1 |
Executes a command in the Heroku Toolbelt | def heroku(command)
system("GEM_HOME='' BUNDLE_GEMFILE='' GEM_PATH='' RUBYOPT='' /usr/local/heroku/bin/heroku #{command}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heroku(command)\n s = system(\"GEM_HOME='' BUNDLE_GEMFILE='' GEM_PATH='' RUBYOPT='' /usr/local/heroku/bin/heroku #{command}\")\nend",
"def heroku(cmd)\n Bundler.with_clean_env { system(\"heroku #{cmd}\") }\nend",
"def run(cmd_type, command = nil, options = {}, &block)\n command = cmd_type.to_... | [
"0.77212226",
"0.72314775",
"0.69322175",
"0.6915362",
"0.68885267",
"0.68885267",
"0.67473763",
"0.64000255",
"0.6346544",
"0.6271409",
"0.62036175",
"0.6161484",
"0.6151011",
"0.6119241",
"0.6067952",
"0.6039589",
"0.60343295",
"0.6012852",
"0.6012852",
"0.5965465",
"0.5927... | 0.7632713 | 1 |
GET /ches GET /ches.json | def index
@ches = Ch.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @chargers = Charger.all\n render json: @chargers\n end",
"def index\n @user_catches = getUserCatches()\n @keepers = getKeepers()\n\n @type_totals = getTypeTotals()\n logger.debug \"user_catches=\" + @user_catches.to_s\n\n @fish_types = FishType.all if @fish_type.nil?\n @users... | [
"0.6391525",
"0.6302974",
"0.6247824",
"0.62257326",
"0.62257326",
"0.6216089",
"0.6168992",
"0.6163543",
"0.60941756",
"0.6071223",
"0.606733",
"0.606733",
"0.6050587",
"0.60294646",
"0.6027431",
"0.6020038",
"0.5995045",
"0.5990741",
"0.59866554",
"0.5961891",
"0.5956739",
... | 0.5781259 | 46 |
GET /ches/1 GET /ches/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @he = He.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @he }\n end\n end",
"def show\n @cheer = Cheer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @c... | [
"0.6355792",
"0.6195883",
"0.61624986",
"0.6125565",
"0.6115646",
"0.6105024",
"0.60832334",
"0.6082654",
"0.6069918",
"0.6069918",
"0.605923",
"0.60553277",
"0.605386",
"0.60398036",
"0.6012151",
"0.5993252",
"0.5975535",
"0.5966247",
"0.59573203",
"0.59573203",
"0.5927208",... | 0.0 | -1 |
POST /ches POST /ches.json | def create
@ch = Ch.new(ch_params)
respond_to do |format|
if @ch.save
# format.html { redirect_to @ch, notice: 'Ch was successfully created.' }
format.js# { redirect_to @ch, notice: 'Ch was successfully created.' }
# format.json# { render :show, status: :created, location: @ch }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end",
"def create\n render json: Post.create(params[\"post\"])\n end",
"def create\n @cheque = Cheque.new(params[:cheque])\n\n respond_to do |form... | [
"0.580525",
"0.5652079",
"0.5647341",
"0.5640353",
"0.56358874",
"0.55906767",
"0.5568264",
"0.5546088",
"0.55171293",
"0.55073017",
"0.55027014",
"0.5501485",
"0.5481896",
"0.5471889",
"0.5470683",
"0.5464687",
"0.5436024",
"0.54274267",
"0.5426603",
"0.54229856",
"0.5419781... | 0.0 | -1 |
PATCH/PUT /ches/1 PATCH/PUT /ches/1.json | def update
respond_to do |format|
if @ch.update(ch_params)
format.html { redirect_to @ch, notice: 'Ch was successfully updated.' }
format.json { render :show, status: :ok, location: @ch }
else
format.html { render :edit }
format.json { render json: @ch.errors, status: :un... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def patch!\n request! :patch\n end",
"def update # PATCH\n rai... | [
"0.6837156",
"0.67145294",
"0.66698986",
"0.6571805",
"0.64935595",
"0.644392",
"0.6434816",
"0.642178",
"0.6314157",
"0.62710685",
"0.62710685",
"0.62637913",
"0.6223215",
"0.6181328",
"0.61676913",
"0.6158628",
"0.6150577",
"0.6123661",
"0.6122252",
"0.61221886",
"0.6122188... | 0.0 | -1 |
DELETE /ches/1 DELETE /ches/1.json | def destroy
@ch.destroy
respond_to do |format|
format.html { redirect_to ches_url, notice: 'Ch was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def delete(path)\n RestCli... | [
"0.7354419",
"0.7047876",
"0.70007014",
"0.6952419",
"0.68707776",
"0.6869762",
"0.6826888",
"0.6826266",
"0.6811647",
"0.68045557",
"0.6798212",
"0.67636836",
"0.6760846",
"0.6760846",
"0.6760846",
"0.6760846",
"0.6747369",
"0.6741525",
"0.67351866",
"0.67297924",
"0.6729792... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_ch
@ch = Ch.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 ch_params
params.require(:ch).permit(: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.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /flickr_accounts GET /flickr_accounts.json | def index
@flickr_accounts = FlickrAccount.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_accounts()\n http_get(accounts_url)\n end",
"def accounts\n get('/accounts')['accounts']\n end",
"def set_flickr_account\n @flickr_account = FlickrAccount.find(params[:id])\n end",
"def social_accounts_for_a_project\n uri = \"#{@api_url}/#{@project_id}/accounts?access_token... | [
"0.6776277",
"0.66489214",
"0.66225606",
"0.66021496",
"0.6461425",
"0.6384925",
"0.6365791",
"0.6320858",
"0.62570953",
"0.62461966",
"0.6241318",
"0.62353927",
"0.61798775",
"0.6128891",
"0.6116205",
"0.60819024",
"0.6067792",
"0.6064186",
"0.60636634",
"0.60282004",
"0.598... | 0.7629078 | 0 |
GET /flickr_accounts/1 GET /flickr_accounts/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @flickr_accounts = FlickrAccount.all\n end",
"def set_flickr_account\n @flickr_account = FlickrAccount.find(params[:id])\n end",
"def get_account\n as_json(get_results('/account'))\n end",
"def get_accounts()\n http_get(accounts_url)\n end",
"def get_flickr_pics (photose... | [
"0.7354691",
"0.6772144",
"0.63543683",
"0.63428825",
"0.6262356",
"0.6249365",
"0.62468874",
"0.6238941",
"0.61278594",
"0.611957",
"0.61042225",
"0.6096055",
"0.60798055",
"0.6052219",
"0.5967909",
"0.5954868",
"0.5938985",
"0.5938434",
"0.59004855",
"0.5883806",
"0.58812",... | 0.0 | -1 |
POST /flickr_accounts POST /flickr_accounts.json | def create
@flickr_account = FlickrAccount.new(flickr_account_params)
if @flickr_account.save
redirect_to flickr_accounts_path
else
render :new
end
# respond_to do |format|
# if @flickr_account.save
# format.html { redirect_to @flickr_account, notice: 'Flickr account was ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n megam_rest.post_accounts(to_hash)\n end",
"def save\n Account.create!(account_params.map do |data|\n {\n type: :facebook,\n user: current_user,\n name: data[:name],\n data: data\n }\n end)\n\n render json: success\n end",
"def set_flickr_acco... | [
"0.66967624",
"0.62125397",
"0.6038969",
"0.6014178",
"0.5993962",
"0.58316964",
"0.58119494",
"0.57744527",
"0.5771591",
"0.5614921",
"0.5611416",
"0.5591132",
"0.5576551",
"0.5562358",
"0.55380666",
"0.5530687",
"0.55035764",
"0.54898775",
"0.5480192",
"0.5462454",
"0.54462... | 0.6866553 | 0 |
PATCH/PUT /flickr_accounts/1 PATCH/PUT /flickr_accounts/1.json | def update
# respond_to do |format|
# if @flickr_account.update(flickr_account_params)
# format.html { redirect_to @flickr_account, notice: 'Flickr account was successfully updated.' }
# format.json { render :show, status: :ok, location: @flickr_account }
# else
# format.html { r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def set_flickr_account\n @flickr_account = F... | [
"0.6163037",
"0.6163037",
"0.6143675",
"0.6103595",
"0.6045521",
"0.6026423",
"0.6009034",
"0.59985757",
"0.59904814",
"0.59378904",
"0.59052396",
"0.59001744",
"0.58787555",
"0.58690876",
"0.58534294",
"0.58274466",
"0.57986957",
"0.5784053",
"0.5784053",
"0.5772434",
"0.573... | 0.7124585 | 0 |
DELETE /flickr_accounts/1 DELETE /flickr_accounts/1.json | def destroy
# @flickr_account.destroy
# respond_to do |format|
# format.html { redirect_to flickr_accounts_url, notice: 'Flickr account was successfully destroyed.' }
# format.json { head :no_content }
# end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete photo_id\n @flickr.photos.delete(photo_id: photo_id)\n end",
"def delete_account\n @user = current_user\n if @user.flickr_account.destroy\n flash[:notice] = 'You are not connected to flickr anymore $green'\n else \n flash[:notice] = 'Something went wrong. Please try again $r... | [
"0.67956614",
"0.6630035",
"0.66133296",
"0.6531147",
"0.6523471",
"0.6443541",
"0.6432054",
"0.6431538",
"0.6367408",
"0.6355235",
"0.6355235",
"0.6355235",
"0.6355235",
"0.6354484",
"0.63486004",
"0.63327396",
"0.63327396",
"0.6329291",
"0.63243115",
"0.6323775",
"0.6323775... | 0.77141327 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_flickr_account
@flickr_account = FlickrAccount.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 flickr_account_params
params.require(:flickr_account).permit(:username)
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 |
Writes a lot of crap to stdout and stderr | def start(boxname="mmsbox", method="simple_fork")
raise "Box with #{boxname} is already running" unless @proc[boxname].nil?
if method == "simple_fork"
@proc[boxname] = MbuniProc.new(nil,nil,nil,
fork { exec "#{@path}/bin/#{boxname} #{@config}" }
)
elsif method == "custom_pope... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def without_stderr; end",
"def stdouts; end",
"def stderr(command, data)\n # called when the process writes to STDERR\n end",
"def stderr; end",
"def stderr; end",
"def stderr; end",
"def stderr; end",
"def streams_after(out_,err_)\n $stdout = out_\n $stderr = err_\nend",
"def all_output\n ... | [
"0.6732157",
"0.67065907",
"0.66776115",
"0.65869904",
"0.65869904",
"0.65869904",
"0.65869904",
"0.6583778",
"0.64355755",
"0.639698",
"0.639698",
"0.639698",
"0.62969524",
"0.6253272",
"0.62522674",
"0.62485886",
"0.6241416",
"0.6241416",
"0.6241416",
"0.6241416",
"0.624141... | 0.0 | -1 |
This is a special version of popen which captures stdout, stdin and stdout and the PID of the executing process | def custom_popen(*cmd)
pw = IO::pipe # pipe[0] for read, pipe[1] for write
pr = IO::pipe
pe = IO::pipe
pid_pipe = IO::pipe # pipe for communicating the process id of the started process
executing_proc_pid = nil
pid = fork{
# child
executing_proc_pid = fork{
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_popen2(cmd)\n stdin_reader, stdin_writer = IO.pipe\n stdout_reader, stdout_writer = IO.pipe\n\n pid = fork {\n stdin_writer.close\n $stdin.reopen(stdin_reader)\n\n stdout_reader.close\n $stdout.reopen(stdout_writer)\n\n exec(cmd)\n }\n\n stdin_reader.close\n stdout_writer.close\n\n yie... | [
"0.6945913",
"0.6926403",
"0.6560002",
"0.65075195",
"0.63351536",
"0.6281145",
"0.6250021",
"0.6241206",
"0.62267417",
"0.6038773",
"0.6036861",
"0.60131353",
"0.59852",
"0.59559953",
"0.5927879",
"0.58659935",
"0.58659935",
"0.58659935",
"0.5864546",
"0.5846288",
"0.5798707... | 0.7112495 | 0 |
supports default parameters values | def nothing(p1=1,p2=2,p3=3)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supports_default_values?\n true\n end",
"def required_defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults;... | [
"0.7779235",
"0.77535194",
"0.77522457",
"0.77522457",
"0.77522457",
"0.77522457",
"0.77522457",
"0.77522457",
"0.77522457",
"0.77522457",
"0.77522457",
"0.77522457",
"0.7709063",
"0.7709063",
"0.756093",
"0.7439553",
"0.74073225",
"0.73950726",
"0.723264",
"0.72222656",
"0.7... | 0.0 | -1 |
tell me the biggest renvoyer le plus grand entre 3 chiffres | def who_is_bigger(a, b, c)
if (a == nil or b == nil or c == nil)
return "nil detected"
else
if (a > b and a > c )
return "a is bigger"
elsif (b > a and b > c )
return "b is bigger"
else
return "c is bigger"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end",
"def franchise_with_highest_profit\n company = get_company\n no_franchises(company)\n big_earner = company.franchises.max_by { |franchise| franchise.profit }\n puts \"Franchise #{big_earner.id} has the highest profit, ... | [
"0.64992267",
"0.64488393",
"0.6439659",
"0.6297523",
"0.6264678",
"0.6111586",
"0.6091082",
"0.6048619",
"0.6039138",
"0.6015173",
"0.60057515",
"0.6004748",
"0.5990877",
"0.59683",
"0.5959214",
"0.595757",
"0.5947033",
"0.59277046",
"0.59276193",
"0.5884559",
"0.58829105",
... | 0.0 | -1 |
does crazy things on strings :Reverse, upcase then removes all L, T and A. | def reverse_upcase_noLTA(p1)
p1.reverse.upcase.delete "LTA"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_upcase_noLTA(string)\n string = string.downcase\n string = string.delete \"a\"\n string = string.delete \"l\"\n string = string.delete \"t\"\n string = string.upcase\n string = string.reverse\n return string\nend",
"def reverse_upcase_noLTA(string)\n\tstring.reverse.upcase.tr('A'... | [
"0.822985",
"0.8116307",
"0.8110973",
"0.8029478",
"0.80043536",
"0.79709655",
"0.77776587",
"0.76370937",
"0.76366425",
"0.74138504",
"0.7260429",
"0.7232456",
"0.7211708",
"0.71999097",
"0.7154291",
"0.71219426",
"0.71135026",
"0.70961386",
"0.70859414",
"0.70524883",
"0.70... | 0.7668304 | 7 |
finds 42 : array_42 takes an array as parameter and returns: true if there's a 42 in the array items false otherwise | def array_42(array)
a = false
array.each {|i| if i == 42 then a = true end}
return a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array_42(a)\n\ta.any?{|x| x == 42}\nend",
"def array_42(z)\n if z.include? 42\n return true\n else\n return false\n end\n\nend",
"def array_42(arr)\n arr.map{|x| x== 42}.count{|x| x == true} == 1 ? true : false\nend",
"def exists?(number, array)\n array.include?... | [
"0.8160264",
"0.7756425",
"0.755894",
"0.73001885",
"0.70582676",
"0.6964451",
"0.689427",
"0.6845245",
"0.6833183",
"0.6805238",
"0.67821777",
"0.67721444",
"0.67507297",
"0.67411923",
"0.6711384",
"0.6670097",
"0.66320175",
"0.66298974",
"0.6609166",
"0.6603252",
"0.6581573... | 0.7682839 | 2 |
does crazy things on arrays : The magic_array function takes an array of number or an array of array of number as parameter and return the same array : flattened (i.e. no more arrays in array) reversed with each number multiplicated by 2 with each multiple of 3 removed with each number duplicate removed (any number sho... | def magic_array(array)
array.flatten.reverse.map! {|i| i = i*2}.delete_if {|i| i.modulo(3) == 0}.uniq.sort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def magic_array(ma)\nma.flatten.sort.map{|n|n*2}.uniq.delete_if{|n|n%3==0}\nend",
"def magic_array(a)\n a.flatten.sort.map{|x| x*2}.reject{|x| x%3==0}.uniq\n end",
"def magic_array(arr)\n arr.flatten.sort.uniq.map{|x| x*2}\nend",
"def magic_array(long)\n\tless_long = long.flatten\n\treversed = less_long... | [
"0.8331963",
"0.8118887",
"0.7783273",
"0.7496129",
"0.74763614",
"0.67675245",
"0.64840126",
"0.6378727",
"0.6306332",
"0.6258576",
"0.6254475",
"0.6165096",
"0.6147559",
"0.6125871",
"0.6123693",
"0.61127734",
"0.6112463",
"0.60992086",
"0.6096679",
"0.6093359",
"0.60905343... | 0.8487766 | 0 |
Test that data structure is made correctly | def test_format
data = analyse_log(@filename,@keywords, @start, Time.parse("31.12.3000"), @output_file)
data_hist = prepare_data(data, @keywords, @start, 3600)
assert_equal(true, data_hist.keys[0].class == String)
assert_equal(true, data_hist[@keywords[0]].keys[0].class == Time)
assert_equal(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_initialize_objects\n\t# assert_equal @w.nodes, 0\n\t# assert_equal @w.validWordList, 0\n\tassert_kind_of Graph, @w \n\tassert_kind_of Node, @n\n end",
"def test_construct_map\n create_single_locations\n val = construct_the_map\n assert_equal val.size, 7 # pass\n end",
"def test_trivial\n ... | [
"0.65104234",
"0.63730216",
"0.63249815",
"0.61823374",
"0.611165",
"0.6097847",
"0.6084529",
"0.6073607",
"0.6031902",
"0.60246754",
"0.59982497",
"0.59356844",
"0.5931726",
"0.5930787",
"0.5921885",
"0.59156555",
"0.58674955",
"0.5853445",
"0.5841735",
"0.58274615",
"0.5818... | 0.0 | -1 |
method below). Let's review how the splat operator works: The splat operator is used to create methods that have a variable parameter list i.e., they can take any number of parameters. This parameter list is, in fact, a list, and what the splat operator does is it converts that list into an array. (This is according to... | def translate(string)
output = Array.new
# turn our string into an array
words = string.split(' ')
# run each element in the array through our single-world translator method
words.each do |single_word|
output << translate_single_word(single_word)
end
return output.join(" ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def splat_mth(*mult_arg)\n p mult_arg #it's array :) !\n p mult_arg.class\n p mult_arg.object_id\n mult_arg.map {|arg| }\n end",
"def __splat(x) end",
"def roster_splat(*players)\n # Gets treated as an array\n puts players\nend",
"def method_with_splat_parameter(*names)\n end",
"def method_w... | [
"0.80446965",
"0.78312504",
"0.72756314",
"0.6953247",
"0.68313026",
"0.6747671",
"0.6747671",
"0.6741617",
"0.6656025",
"0.6627306",
"0.6626141",
"0.65842354",
"0.65366507",
"0.6451319",
"0.64242405",
"0.6413034",
"0.64074194",
"0.64009",
"0.6341768",
"0.63211316",
"0.631469... | 0.0 | -1 |
can maybe remove this? | def routing_fraction_to_percentage(fraction)
"#{(fraction * 100).to_i}%"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def private; end",
"def remove!; end",
"def cleanup\n super\n end",
"def celebration; end",
"def cleanup\n super\n end",
"def placebo?; false end",
"def delelte\n\n end",
"def fi... | [
"0.6930688",
"0.6930688",
"0.6930688",
"0.6930688",
"0.6925786",
"0.65174705",
"0.6447831",
"0.639615",
"0.6348028",
"0.6294986",
"0.62202114",
"0.61737627",
"0.61397004",
"0.61397004",
"0.60979104",
"0.608522",
"0.6022501",
"0.59868556",
"0.59837806",
"0.59837806",
"0.598378... | 0.0 | -1 |
0111 1100 with bit of 1 would return index of 2 0111 0011 with bit of 0 would return index of 2 | def last_non_trailing(bit, n)
bits = count_trailing_bits(bit, n)
return nil unless bits
complement_bits = count_trailing_bits(complement(bit), n, bits)
return nil unless complement_bits
bits + complement_bits
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pattern_indexes\n self.bits ||= 0\n array = bits.to_s(2).rjust(self.step_count, '0').chars.each_with_index.map do |value, index|\n index if value == '1'\n end\n array.compact\n end",
"def bit_at_position(i)\n reg = regs.find { |reg| reg_contains_position?(reg, i) }\n if reg\n ... | [
"0.70988",
"0.6930983",
"0.6872229",
"0.67634785",
"0.6759612",
"0.670406",
"0.66382736",
"0.6523926",
"0.6456194",
"0.6429997",
"0.63993186",
"0.6375294",
"0.6370808",
"0.63482577",
"0.63168657",
"0.62618595",
"0.6240477",
"0.617995",
"0.617995",
"0.61487263",
"0.6103801",
... | 0.0 | -1 |
1 > 0 0 > 1 | def complement(bit)
bit.succ % 2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AND(x,y); \tif x==1 && y==1 \tthen 1 else 0 end; end",
"def >=(p0) end",
"def >=(p0) end",
"def >=(p0) end",
"def test_bool_comparison() \n assert_equal(true, @@parser.test_run(\"\n bool chief():\n return 15 < 10^2 and 20 != 15*3\n end\"))\n\n assert_equal(false, ... | [
"0.68845797",
"0.6681568",
"0.6681568",
"0.6681568",
"0.6445873",
"0.6403389",
"0.63838816",
"0.62224865",
"0.62165505",
"0.61382884",
"0.6125198",
"0.61182415",
"0.61098206",
"0.6108412",
"0.6105042",
"0.61028147",
"0.6076946",
"0.6076946",
"0.6076946",
"0.6061469",
"0.60393... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_episode
@episode = Episode.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 |
Execute the right command depending on the :command parameter passed in +options+. If the command does not exit, throw an error. | def run(options)
raise ArgumentError, 'Please give a name to the project.' unless options[:name]
case options[:command]
when 'new'
project_details = define_project(options)
project_command = Mvnizer::Command::ProjectFactory.create(project_details.type)
project_command.run(pro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_option_or_command(options, command, args)\n options[:execute] ? eval_execute_option(options[:execute]) :\n execute_command(command, args)\n end",
"def run_command(command, options = {})\n status = run(command, options)\n fail \"#{command} failed\" unless status\nend",
"def ru... | [
"0.7303946",
"0.7101694",
"0.7101694",
"0.69247967",
"0.6789272",
"0.67156017",
"0.6634948",
"0.6525825",
"0.6492968",
"0.64752483",
"0.64611644",
"0.6424441",
"0.6402135",
"0.6398663",
"0.6346378",
"0.63411754",
"0.6326523",
"0.63187397",
"0.6297001",
"0.6294885",
"0.6277559... | 0.0 | -1 |
Returns the float associated with the given string if it is a currency. If the given string is not a currency, this returns nil. | def getCurrencyValue(entry)
# if entry is formatted as currency
if isEntryCurrency?(entry)
# ignore the initial $
entry = entry[1..]
# get rid of commas
entry.gsub!(/,/, "")
# convert to a number and return. We will convert ever... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def float_or_nil(str)\n return nil if IGNORE_LIST.include?(str)\n return nil if str == -1\n Float(str || '')\n rescue ArgumentError\n nil\n end",
"def to_float(string)\n string.to_f\n rescue\n 0.0\n end",
"def checkCurrency(string_variable)\n # returns string_variable a... | [
"0.7168318",
"0.7000558",
"0.667799",
"0.6604937",
"0.6387225",
"0.6341188",
"0.63182855",
"0.62951326",
"0.62250614",
"0.61820513",
"0.6181934",
"0.61327237",
"0.61095124",
"0.60725164",
"0.60678107",
"0.60370904",
"0.60061556",
"0.59182566",
"0.59127975",
"0.5879886",
"0.58... | 0.647746 | 4 |
merges sections by prefering other's attributes FIXME: needs specing | def +(other)
fail "Unmergable sections:\n1) #{self.inspect}\n2) #{other.inspect}\nReason: values must differ." unless self.value == other.value
@attrs.each do |a|
case a
when Attribute
other.attrs << a unless other.attrs.map(&:name).include?(a.name)
when Section... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(with); end",
"def merge_attributes\n attrs = self.attributes.dup.reject{ |k,v| ignored_merge_attributes.include?(k) }\n attrs.merge!(address_attributes) # we want addresses to be shown in the UI\n sorted = attrs.sort do |a,b|\n (ordered_merge_attributes.index(a.first) || 1000) <=>... | [
"0.64014214",
"0.6200959",
"0.61221826",
"0.6073041",
"0.6031088",
"0.5989343",
"0.5943767",
"0.5878308",
"0.584094",
"0.57912856",
"0.5758747",
"0.57207125",
"0.5687047",
"0.5637179",
"0.560761",
"0.5605013",
"0.55937785",
"0.5565393",
"0.5541474",
"0.5535425",
"0.55179334",... | 0.6673078 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_nodetest
@node_test = Nodetest.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 trusted parameter "white list" through. | def nodetest_params
params.require(:nodetest).permit!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7122858",
"0.70540553",
"0.69476545",
"0.6902004",
"0.6735809",
"0.671776",
"0.668886",
"0.66776645",
"0.66611695",
"0.6555913",
"0.6527077",
"0.64584446",
"0.64516115",
"0.64500964",
"0.64474493",
"0.6435065",
"0.6413185",
"0.6413185",
"0.6391701",
"0.6380101",
"0.6380101... | 0.0 | -1 |
get a copy of the db from remote host | def get_backup
tar_file = get_tempfile
safe_run "tar -cf #{tar_file} #{tar_dir}"
tar_file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_database(from, to, from_host=\"localhost\")\n oh = OrderedHash.new\n oh[:copydb] = 1\n oh[:fromhost] = from_host\n oh[:fromdb] = from\n oh[:todb] = to\n self[\"admin\"].command(oh)\n end",
"def copy_database\n options = {\n :query => { 'ZOHO_ACTION' =... | [
"0.72718006",
"0.7223119",
"0.6435807",
"0.639212",
"0.634865",
"0.6223213",
"0.6178505",
"0.60673386",
"0.6047757",
"0.60119694",
"0.6010364",
"0.5994275",
"0.59720045",
"0.59632635",
"0.5943177",
"0.59012204",
"0.5879574",
"0.5877699",
"0.5876134",
"0.5868596",
"0.58518296"... | 0.0 | -1 |
get a zipped copy of the db from remote host | def get_gzipped_backup
tar_file = get_tempfile
safe_run "tar -czf #{tar_file} #{tar_dir}"
tar_file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_gzipped_backup\n safe_run \"ssh #{user}@#{host} gzip -c #{remote_path} > #{local_path}\"\n local_path\n end",
"def zip_dump\n\t system(\"mongodump --host localhost --db #{@mongo_database} --out #{@base_path}\")\n\t Dir[@base_path + '*.zip'].select { |e| File.delete(e) }\n\t Zip::File.open... | [
"0.67106456",
"0.6460594",
"0.62325513",
"0.61934775",
"0.610401",
"0.6000042",
"0.59972733",
"0.5969691",
"0.59509355",
"0.58878964",
"0.5878682",
"0.5867056",
"0.5853542",
"0.58366483",
"0.58193576",
"0.58115554",
"0.5695404",
"0.5691284",
"0.5689631",
"0.56643236",
"0.5634... | 0.545991 | 28 |
GET /facility_items GET /facility_items.json | def index
@facility_items = FacilityItem.where("true").order(:facility_name).page params[:page]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if facility_params[:facility_id]\n @facility_items = FacilityItem.where(facility_id: @facility.id).order(:name).page params[:page]\n else \n @facility_items = [] \n for value in @template.template_facility_item do\n @facility_items.push(FacilityItem.find(value.facility_it... | [
"0.6908514",
"0.6566139",
"0.64723986",
"0.64697",
"0.64472127",
"0.643034",
"0.6387884",
"0.63350093",
"0.6324776",
"0.6298998",
"0.62669265",
"0.6260958",
"0.6191614",
"0.61812186",
"0.61637247",
"0.61539084",
"0.6118062",
"0.6109231",
"0.60649705",
"0.60556024",
"0.604473"... | 0.6690664 | 1 |
GET /facility_items/1 GET /facility_items/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_facility_item\n @facility_item = FacilityItem.find(params[:id])\n end",
"def set_facility_item\n @facility_item = FacilityItem.find(params[:id]) \n end",
"def index\n if facility_params[:facility_id]\n @facility_items = FacilityItem.where(facility_id: @facility.id).order(:name... | [
"0.68201524",
"0.6728097",
"0.6720837",
"0.6673039",
"0.6627221",
"0.64779985",
"0.64721787",
"0.6467768",
"0.6401196",
"0.6343353",
"0.6338596",
"0.622633",
"0.6197486",
"0.617875",
"0.61400723",
"0.61322236",
"0.6103467",
"0.608422",
"0.6084042",
"0.60323477",
"0.60050935",... | 0.0 | -1 |
POST /facility_items POST /facility_items.json | def create
@facility_item = FacilityItem.new(facility_item_params)
respond_to do |format|
if @facility_item.save
format.html { redirect_to @facility_item, notice: 'Facility item was successfully created.' }
format.json { render :show, status: :created, location: @facility_item }
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @facility_item = FacilityItem.new(facility_item_params)\n\n respond_to do |format|\n if @facility_item.save\n format.html { redirect_to '/facilities/'+@facility_item.facility_id.to_s+'/facility_items', notice: 'Facility item was successfully created.' }\n format.json { render ... | [
"0.7530436",
"0.72076565",
"0.6937627",
"0.6723996",
"0.6638696",
"0.6614608",
"0.66044796",
"0.65928334",
"0.6577001",
"0.6502905",
"0.64931077",
"0.6305512",
"0.61998236",
"0.6138269",
"0.6123877",
"0.6118823",
"0.61153483",
"0.6102799",
"0.61004335",
"0.60927486",
"0.60864... | 0.7639089 | 0 |
PATCH/PUT /facility_items/1 PATCH/PUT /facility_items/1.json | def update
respond_to do |format|
if @facility_item.update(facility_item_params)
format.html { redirect_to @facility_item, notice: 'Facility item was successfully updated.' }
format.json { render :show, status: :ok, location: @facility_item }
else
format.html { render :edit }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @facility_item.update(facility_item_params)\n format.html { redirect_to facility_facility_items_path(@facility_item.facility_id), notice: 'Facility item was successfully updated.' }\n format.json { render :show, status: :ok, location: @facility_item }\... | [
"0.7439538",
"0.7114478",
"0.7021754",
"0.6973534",
"0.6972735",
"0.6950552",
"0.69238806",
"0.6923682",
"0.6654412",
"0.65743184",
"0.6570628",
"0.65443194",
"0.6532439",
"0.651008",
"0.6402472",
"0.639943",
"0.6386934",
"0.6349682",
"0.6348803",
"0.63340867",
"0.6306759",
... | 0.7419252 | 1 |
DELETE /facility_items/1 DELETE /facility_items/1.json | def destroy
@facility_item.destroy
respond_to do |format|
format.html { redirect_to facility_items_url, notice: 'Facility item was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @facility_item.destroy\n respond_to do |format|\n format.html { redirect_to facility_facility_items_path(facility_params), notice: 'Facility item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @facility = Facility.find(params[:i... | [
"0.7655816",
"0.73253876",
"0.73086375",
"0.7104393",
"0.7102174",
"0.70010686",
"0.69382125",
"0.69306666",
"0.69006467",
"0.6890064",
"0.68247855",
"0.6793187",
"0.6783173",
"0.6767782",
"0.6740683",
"0.67321223",
"0.67216706",
"0.66904354",
"0.6689707",
"0.6678089",
"0.665... | 0.76135737 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_facility_item
@facility_item = FacilityItem.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.61637366",
"0.60446453",
"0.59452957",
"0.591511",
"0.58885515",
"0.5834122",
"0.57761765",
"0.5702554",
"0.5702554",
"0.5652102",
"0.5619581",
"0.5423898",
"0.5409782",
"0.5409782",
"0.5409782",
"0.5394745",
"0.53780794",
"0.5356209",
"0.5338898",
"0.53381324",
"0.5328622... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def facility_item_params
params.require(:facility_item).permit(:facility_name, :available_quantity, :meeting_room_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
wrap values which can be nil into maybe and then match to avoid nil errors | def add(value)
@sum ||= 0
match value,
None >> @sum,
Some.(~any) >-> int { @sum += int }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def missings_to_nil(values)\n values.collect{|v| is_missing?(v) ? nil : v}\n end",
"def or_nil\n get_or_else(nil)\n end",
"def maybe(*args, **opts, &block)\n extract_type_spec(*args, nullable: true) do |*predicates, type_spec:, type_rule:|\n append_macro(Macros::Maybe) d... | [
"0.5950411",
"0.5765343",
"0.5734313",
"0.56238383",
"0.5546334",
"0.55024797",
"0.5483861",
"0.546333",
"0.546333",
"0.5429069",
"0.53822875",
"0.53822875",
"0.53822875",
"0.53822875",
"0.53822875",
"0.5369995",
"0.5368835",
"0.5368835",
"0.5368835",
"0.5368835",
"0.5353917"... | 0.0 | -1 |
display popup selected date range | def show_popup
@pop_up_manager = Spree::PopUpManager.find(params[:id])
if request.xhr?
if @pop_up_manager.show_daily == true
cookies[:active_popup] = session[:active_popup] = true
else
start_date = @pop_up_manager.start_date
end_date = @pop_up... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dateselection\nend",
"def select_custom_date_filter(from_date, to_date)\n date_option_custom.click\n custom_date_from.text = from_date\n custom_date_to.text = to_date\n end",
"def show\n @begin_date = Date.today - 5\n @end_date = Date.today + 5\n end",
"def reporthelp_start_time( form )\... | [
"0.6623924",
"0.63970107",
"0.6284262",
"0.6208174",
"0.6147926",
"0.6049865",
"0.5903949",
"0.58392566",
"0.5820125",
"0.581356",
"0.58009446",
"0.57831097",
"0.5773008",
"0.57005906",
"0.5687396",
"0.56592786",
"0.56587034",
"0.5617456",
"0.5566251",
"0.5555173",
"0.5551245... | 0.0 | -1 |
puts "this is a debug message" | def solution(a)
return 0 if a.uniq.size != a.size
max = a.size
sum = (1 + max) * max / 2
array_sum = a.inject(0, &:+)
sum == array_sum ? 1 : 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debug(msg)\n #puts msg\n end",
"def debug(s)\n\t#puts \"DEBUG: #{s}\"\nend",
"def print_debug(msg)\n puts msg if (@debug) \n STDOUT.flush\n end",
"def debug(message)\n puts message if debug?\n end",
"def debug(s) if $DEBUG then $stderr.print(\"#{s}\\n\") end end",
"def debug_ms... | [
"0.8404423",
"0.8266837",
"0.82102925",
"0.8136153",
"0.8106155",
"0.8065727",
"0.8002759",
"0.79972893",
"0.7974082",
"0.7974082",
"0.7974082",
"0.792677",
"0.7856124",
"0.78472453",
"0.78355575",
"0.7820573",
"0.7820573",
"0.77906436",
"0.77715087",
"0.7740855",
"0.7739872"... | 0.0 | -1 |
Initialize the request to api, should be used in children classes only | def call(*, &blk)
socket.print "#{format(self.class.const_get(:TEMPLATE), combined_options)}\r\n"
pull_socket(&blk)
return result_accumulator unless block_given?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize base_url, api_key\n\t\t\t\t\t@connection = Freshdesk::Api::Client::Request.new base_url, api_key\n\t\t\t\tend",
"def initialize\n @api_user = \"\"\n @api_key = \"\"\n end",
"def post_init\n @request = Request.new\n @response = Response.new\n end",
"def initialize(api... | [
"0.7823221",
"0.7229663",
"0.7228181",
"0.7166057",
"0.7159453",
"0.71229446",
"0.70804787",
"0.7078406",
"0.70059055",
"0.69910705",
"0.698945",
"0.6977771",
"0.6966062",
"0.69285816",
"0.6910492",
"0.6847841",
"0.6827392",
"0.68182236",
"0.67984337",
"0.67605996",
"0.674965... | 0.0 | -1 |
This should contain expected class of the returning message. Might be overwritten in child class | def expected_messages_class
self.class.name.sub("Lookups", "Messages").constantize
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expect_message(type); end",
"def message; Message.new; end",
"def message_class\n return Scene_Battle::Message\n end",
"def to_message\n fail NotImplementedError\n end",
"def message_class\n Yuki::Message\n end",
"def message\n @message || super\n end",
"def message\n ... | [
"0.7179703",
"0.6744682",
"0.6650263",
"0.66481745",
"0.6565897",
"0.64626825",
"0.6453455",
"0.64412063",
"0.6376764",
"0.6376764",
"0.6376764",
"0.6376764",
"0.6376764",
"0.6376764",
"0.63290435",
"0.6311117",
"0.627904",
"0.627904",
"0.62737465",
"0.62347186",
"0.62238055"... | 0.6789119 | 1 |
Tests for the default values when ExceptionNotifiable is included in a controller | def test_default_http_status_codes
assert(BasicController.http_status_codes == HTTP_STATUS_CODES, "Default http_status_codes is incorrect")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dispatch_default_exception(klass, request, response, e)\n controller = klass.build(request, response, e.class::STATUS)\n if e.is_a? ControllerExceptions::Redirection\n controller.headers.merge!('Location' => e.message)\n controller.instance_variable_set(\"@_body\", %{ }) #fix\n ... | [
"0.58751726",
"0.58636385",
"0.58636385",
"0.5789949",
"0.5653128",
"0.55968535",
"0.5573087",
"0.54218596",
"0.54075843",
"0.5399033",
"0.5399033",
"0.5371232",
"0.5369816",
"0.5360617",
"0.5350108",
"0.5319065",
"0.5276399",
"0.52698547",
"0.52653503",
"0.5264609",
"0.52560... | 0.49508914 | 79 |
Generate a link to an image in the S3 bucket | def getLogoData(data)
data && data['asset_id'] && data['width'] && data['height'] or return nil
return { url: "/assets/#{data['asset_id']}", width: data['width'], height: data['height'] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imgurl\n return url unless fake_url?\n # The more complicated case: we have an IR with image data, but no URL.\n # So we lookup the corresponding URL on AWS. If it exists, we return that;\n # Otherwise, we CREATE it on AWS first, then return it.\n #\n # Does the resource exist? If so, we just... | [
"0.82557416",
"0.7796186",
"0.740115",
"0.7377623",
"0.72793156",
"0.72579455",
"0.7239507",
"0.7205346",
"0.7171922",
"0.7152218",
"0.7107362",
"0.7063616",
"0.70591897",
"0.7052005",
"0.70423025",
"0.7026606",
"0.6943128",
"0.6928842",
"0.6893491",
"0.6866286",
"0.68516576"... | 0.0 | -1 |
Add a URL to each nav bar item | def getNavBar(unitID, pageName, navItems)
if navItems
navItems.each { |navItem|
if navItem['slug']
navItem['url'] = "/uc/#{unitID}#{navItem['slug']=="" ? "" : "/"+navItem['slug']}"
end
}
navItems.unshift({ id: 0, type: "home", name: "Unit Home", url: "/uc/#{unitID}" })
return navIt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nav_items\n [\n {\n url: root_path,\n title: \"Home\"\n },\n {\n url: about_me_path,\n title: \"About Me\"\n },\n {\n url: contact_path,\n title: \"Contact\"\n },\n {\n url: tech_news_path,\n title: \"Rails News\"\n ... | [
"0.7061633",
"0.6789654",
"0.6443296",
"0.6431617",
"0.63335776",
"0.62810594",
"0.62396413",
"0.62377983",
"0.6231396",
"0.62284994",
"0.62132555",
"0.62034315",
"0.6189186",
"0.6165258",
"0.61300206",
"0.60662365",
"0.6043991",
"0.60309684",
"0.6029809",
"0.59971374",
"0.59... | 0.6479925 | 2 |
Generate the last part of the breadcrumb for a static page within a unit | def getPageBreadcrumb(unit, pageName)
(!pageName || pageName == "home" || pageName == "campus_landing") and return []
pageName == "search" and return [{ name: "Search", id: unit.id + ":" + pageName}]
pageName == "profile" and return [{ name: "Profile", id: unit.id + ":" + pageName}]
pageName == "sidebar" and re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_breadcrumb\n end",
"def breadcrumbs\n breadcrumbs = link_to this_webapp.webapp_name, root_path, :class => 'first-breadcrumb'\n unless @breadcrumb.nil?\n breadcrumbs += content_tag(:label, \" > \")\n if @breadcrumb.kind_of? Picture\n picture = @breadcrumb\n @breadcrumb =... | [
"0.64884925",
"0.64713144",
"0.6470853",
"0.640594",
"0.640171",
"0.6315557",
"0.6289883",
"0.6289883",
"0.62805516",
"0.62773037",
"0.62586904",
"0.6146591",
"0.61463636",
"0.604957",
"0.6041256",
"0.6034665",
"0.60077864",
"0.60077864",
"0.599243",
"0.5989021",
"0.59852535"... | 0.6657726 | 0 |
Generate breadcrumb and header content for Unitbranded pages | def getUnitHeader(unit, pageName=nil, attrs=nil)
if !attrs then attrs = JSON.parse(unit[:attrs]) end
r = UnitHier.where(unit_id: unit.id).where(ancestor_unit: $activeCampuses.keys).first
campusID = (unit.type=='campus') ? unit.id : r ? r.ancestor_unit : 'root'
header = {
:campusID => campusID,
:campusNa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def individual_breadcrumb\n add_breadcrumb \"Clients\", clients_path, :title => \"Clients\" \n add_breadcrumb \"Power Of Attorney\", '', :title => \"Power Of Attorney\" \n add_breadcrumb \"Principal Create\", '', :title => \"Principal Create\"\n end",
"def breadcrumb_with_autohier(*args)\n # Thi... | [
"0.6806732",
"0.66057044",
"0.65819997",
"0.6553603",
"0.6511547",
"0.6495453",
"0.6456045",
"0.64555365",
"0.6412341",
"0.6397377",
"0.6390433",
"0.6385055",
"0.63629675",
"0.63593864",
"0.6289404",
"0.624614",
"0.6236997",
"0.6199193",
"0.6192281",
"0.6146599",
"0.6112809",... | 0.0 | -1 |
Get ORUspecific data for Department Landing Page | def getORULandingPageData(id)
# addPage()
children = $hierByAncestor[id]
return {
:series => children ? children.select { |u| u.unit.type == 'series' }.map { |u| seriesPreview(u) } : [],
:journals => children ? children.select { |u| u.unit.type == 'journal' }.map { |u| {unit_id: u.unit_id, name: u.unit.n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def department\n @department ||= @data[:cmudepartment].last\n end",
"def get_department_outype\n path = \"/d2l/api/lp/#{$lp_ver}/outypes/department\"\n _get(path)\n # returns OrgUnitType JSON data block\nend",
"def organisation_data_for_show_method\n @location = @user.location\n @count... | [
"0.6351933",
"0.634018",
"0.6282584",
"0.6263901",
"0.6243959",
"0.62017155",
"0.61891556",
"0.6154866",
"0.61155283",
"0.6108637",
"0.60769665",
"0.6044919",
"0.60250187",
"0.60056245",
"0.5984907",
"0.5926598",
"0.5917869",
"0.5917869",
"0.5917869",
"0.5900851",
"0.5875386"... | 0.58189183 | 21 |
Get data for Campus Landing Page | def getCampusLandingPageData(unit, attrs)
return {
:pub_count => ($statsCampusPubs.keys.include? unit.id) ? $statsCampusPubs[unit.id] : 0,
:view_count => 0,
:opened_count => 0,
:journal_count => ($statsCampusJournals.keys.include? unit.id) ? $statsCampusJournals[unit.id] : 0,
:unit_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @campuses = Campus.all\n end",
"def index\n @campsites = Campsite.all\n end",
"def index\n @campsites = Campsite.all\n end",
"def index\n @campingsites = Campingsite.all\n end",
"def index\n @camps = Camp.active.chronological.paginate(page: params[:page]).per_page(10)\n @u... | [
"0.69561905",
"0.6953235",
"0.6953235",
"0.6789851",
"0.6709516",
"0.66408324",
"0.6597581",
"0.64995944",
"0.6490238",
"0.64849406",
"0.64630735",
"0.63775855",
"0.6285137",
"0.61803836",
"0.6129322",
"0.612639",
"0.61263204",
"0.6125091",
"0.6103626",
"0.6067645",
"0.605949... | 0.65293777 | 7 |
Preview of Series for a Department Landing Page | def seriesPreview(u)
items = UnitItem.filter(:unit_id => u.unit_id, :is_direct => true)
count = items.count
preview = items.limit(3).map(:item_id)
itemData = readItemData(preview)
{
:unit_id => u.unit_id,
:name => u.unit.name,
:count => count,
:items => itemResultData(preview, itemData)
}
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def submission_preview\n # load a random study, or use selected study\n @studies = Study.where(public: true).pluck(:name, :id)\n end",
"def show\n @serial_works = @series.serial_works.find(:all, :include => :work, :conditions => ['works.posted = ?', true], :order => :position).select{|sw| sw.work.visib... | [
"0.64027655",
"0.62493",
"0.60682404",
"0.5959332",
"0.5928181",
"0.5914645",
"0.5910541",
"0.5910541",
"0.5910071",
"0.5883508",
"0.58300704",
"0.58155763",
"0.57527316",
"0.5736098",
"0.5725417",
"0.57236314",
"0.57035094",
"0.5684713",
"0.5684713",
"0.5666853",
"0.5663574"... | 0.6201234 | 2 |
Get recent items (with author info) for a unit, by most recent eschol_date | def getRecentItems(unit)
items = Item.join(:unit_items, :item_id => :id).where(unit_id: unit.id)
.where(Sequel.lit("attrs->\"$.suppress_content\" is null"))
.reverse(:eschol_date).limit(5)
return items.map { |item|
{ id: item.id, title: item.title, authors: getItemAuthors(item.id) }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def most_recent_recipe\n recipes.sort_by do |i| \n i.date\n end.last\n end",
"def authors_top\n\t\t\t@db.js('musicthoughts.top_authors($1)', [20])\n\t\tend",
"def recent_item\n raise MsdApi::Exception::InvalidParameter.new(_('errors.missing_param', key: :date)) unless params[:date]\n\n... | [
"0.56707156",
"0.56666803",
"0.55680346",
"0.5535638",
"0.549315",
"0.54838085",
"0.5454201",
"0.545385",
"0.54419273",
"0.5429123",
"0.5428824",
"0.54213077",
"0.5343198",
"0.52986926",
"0.52909523",
"0.52649343",
"0.526475",
"0.5253439",
"0.5236696",
"0.5236447",
"0.5220996... | 0.69658273 | 0 |
Traverse the nav bar, including subfolders, yielding each item in turn to the supplied block. | def travNav(navBar, &block)
navBar.each { |nav|
block.yield(nav)
if nav['type'] == 'folder'
travNav(nav['sub_nav'], &block)
end
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bootstrap_nav(*args, &block)\n levels = { :primary => 1, :secondary => 2, :tertiary => 3 }\n options = args.extract_options!\n level = levels[options[:level]] || (options[:level] || 1).to_i\n\n\n # If there are no arguments, use the current page\n args.unshift page if args.empty? && !p... | [
"0.6650002",
"0.6526568",
"0.65144163",
"0.6413888",
"0.6250708",
"0.6249965",
"0.61853987",
"0.60712755",
"0.5941075",
"0.592345",
"0.59190845",
"0.58274376",
"0.5810377",
"0.580561",
"0.5765988",
"0.57558376",
"0.57232195",
"0.5702313",
"0.5700346",
"0.5696164",
"0.5694098"... | 0.78703076 | 0 |
Possible EC2 states: states = %w( pending running shuttingdown terminated stopping stopped ) | def insync?(is)
# an empty array is analogous to no should values
return true if @should.empty?
# only support a single should
should = @should.first
# use Symbol to match should
is = "shuttingdown" if is == "shutting-down"
is = is.to_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def states\n [\n ['0', 'EMERGENCY_SHUTDOWN',\n 'State machine has a bug, cannot be trusted']\n ]\n end",
"def vm_state(state)\n case state\n when 'poweredOn'\n 'RUNNING'\n when 'suspended'\n 'POWEROFF'\n when 'poweredOff'\n 'POWER... | [
"0.7332059",
"0.67412794",
"0.64987713",
"0.6453575",
"0.6450251",
"0.6374322",
"0.6136548",
"0.60620064",
"0.60194343",
"0.6011941",
"0.6006354",
"0.60026526",
"0.59875304",
"0.5925065",
"0.5924569",
"0.5916143",
"0.58931345",
"0.5889349",
"0.584709",
"0.58040965",
"0.577572... | 0.0 | -1 |
Downcases Username/Emails Provided by Params to Prevent Repeat Usernames Due to Caps | def username
params[:username].downcase
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def downcase!\n self.username.downcase!\n self.email.downcase!\n end",
"def downcase_email_username\n self.email = email.downcase\n self.username = username.downcase\n end",
"def format_username\n \t_email_base = self.email[/[^@]+/]\n \tself.username ||= _email_base.camelize.underscor... | [
"0.72925663",
"0.7233208",
"0.71101785",
"0.70375264",
"0.7037082",
"0.7037082",
"0.6908436",
"0.69041234",
"0.68614",
"0.67897636",
"0.67662686",
"0.67662686",
"0.67662686",
"0.67662686",
"0.67568505",
"0.67487293",
"0.6746017",
"0.6741996",
"0.67381763",
"0.6730172",
"0.672... | 0.66892046 | 31 |
For Displaying all The Shop Profiles | def index
@shops = current_user.shop_profiles
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @shop_profiles = ShopProfile.all\n end",
"def index\n @professional_profiles = ProfessionalProfile.all\n end",
"def index\n @promotions = current_shop_owner.promotions.all\n end",
"def index\n @proccs = Procc.all\n end",
"def index\n @profanes = Profane.all\n end",
"def sh... | [
"0.70421696",
"0.65438896",
"0.643277",
"0.6274076",
"0.6222612",
"0.6157539",
"0.61419964",
"0.6141957",
"0.6112224",
"0.6061302",
"0.6055706",
"0.60032475",
"0.59595627",
"0.5955043",
"0.5943252",
"0.59336287",
"0.5824984",
"0.5816122",
"0.57842875",
"0.57842875",
"0.577777... | 0.69859815 | 1 |
For Displaying all the Shop Products for a particular Shop Profile | def show
@shop_profile = ShopProfile.find(params[:id])
@items = @shop_profile.shop_products.where(shop_profile_id: @shop_profile.id)
.paginate(page: params[:page], per_page: 6).search(params[:search])
if !params[:category_id].nil?
@items = @shop_profile.shop_products.where(category_id: params[:category_id])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @shop_profiles = ShopProfile.all\n end",
"def index\n\t\t@shops = current_user.shop_profiles\n\tend",
"def shop_products\n products.shop_products\n end",
"def index\n @products = current_user.products.all\n end",
"def index\n @products = current_user.products\n end",
"def inde... | [
"0.760567",
"0.7407571",
"0.6582207",
"0.65487456",
"0.65304255",
"0.6521858",
"0.6498808",
"0.647377",
"0.6451767",
"0.64466614",
"0.64156866",
"0.64089644",
"0.6393801",
"0.6338596",
"0.6328616",
"0.6328505",
"0.63187605",
"0.631062",
"0.62999624",
"0.62958145",
"0.6264457"... | 0.8070445 | 0 |
For Creating a New Shop Profile for a Shopkeeper | def create
authorize ShopProfile
@shop = ShopProfile.new(shop_params)
@shop.build_address(address_params_shopkeeper)
if @shop.valid? and ! current_user.user_profile.nil?
current_user.shop_profiles << @shop
flash[:success] = 'Shop Details added'
redirect_to root_path
elsif current_user.user_profile.ni... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @profile = current_user.profile || Profile.new\n @profile.user_id = current_user.id\n @profile.status = :start\n @profile.save(validate: false)\n session[:profile_id] = @profile.id\n redirect_to vendor_setup_store_index_path\n end",
"def create_profile!\n bundle_id = Sigh.con... | [
"0.74843675",
"0.72974294",
"0.69844735",
"0.6946472",
"0.6910242",
"0.6909806",
"0.68356186",
"0.68322736",
"0.6830035",
"0.6820872",
"0.68167704",
"0.6811026",
"0.68055683",
"0.6772831",
"0.6762305",
"0.67601204",
"0.6744072",
"0.67392904",
"0.6732139",
"0.67272365",
"0.671... | 0.78790224 | 0 |
For Updating a Shop Profile Details | def update
@shop = current_user.shop_profiles.find(params[:id])
authorize @shop
if @shop.update_attributes(shop_params) and @shop.address.update_attributes(address_params_shopkeeper)
flash[:success] = 'Updated Successfully'
redirect_to shop_profiles_path
else
flash[:danger] = 'Shop Details not Updated... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n\t\t# Updating the details according the that particular profile\n\t\t@profile.update_attributes(profile_params)\n\t\t# Redirect to the particular surgeon profile show page\n\t\tredirect_to profile_path(@profile)\n\tend",
"def update_profile\n @profile = @account.employee\n \n if... | [
"0.7538919",
"0.75251615",
"0.7493007",
"0.7369756",
"0.7299349",
"0.7240679",
"0.71428186",
"0.7133239",
"0.7107589",
"0.70974326",
"0.7091699",
"0.70606875",
"0.7047986",
"0.7009914",
"0.7000479",
"0.6980883",
"0.6963947",
"0.6961477",
"0.69480884",
"0.6916052",
"0.69102186... | 0.7961084 | 0 |
For Displaying all the Shop Profiles of all Shopkeepers for Admin | def shop_index
authorize ShopProfile
respond_to do |format|
format.html
format.json {render json: ShopProfileDatatable.new(view_context)}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\t\t@shops = current_user.shop_profiles\n\tend",
"def index\n @shop_profiles = ShopProfile.all\n end",
"def index\n @promotions = current_shop_owner.promotions.all\n end",
"def index\n @professional_profiles = ProfessionalProfile.all\n end",
"def index\n @shop_admins = ShopAdmin.a... | [
"0.7175174",
"0.7106073",
"0.67872",
"0.6508945",
"0.65019244",
"0.64320713",
"0.6283395",
"0.6249125",
"0.6203545",
"0.61802864",
"0.61369646",
"0.61181664",
"0.61077285",
"0.61004853",
"0.60818034",
"0.60370815",
"0.59947675",
"0.59621936",
"0.5961465",
"0.5948527",
"0.5940... | 0.5663388 | 60 |
Changing Status of a Shop Profile to Approved or Disapproved | def change_status
authorize ShopProfile
@shop = ShopProfile.find(params[:shop_profile_id])
#Calling method approve_shop from Model
ShopProfile.approve_shop(@shop, flash)
redirect_to request.referrer || root_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def approve\n @profile.approved = true\n @profile.save!\n redirect_to profiles_path(status: 'prohibited')\n end",
"def approve!\n self.update_attribute(:status, ConfigCenter::User::APPROVED)\n end",
"def prohibit\n @profile.approved = false\n @profile.save!\n redirect_to profiles_path(st... | [
"0.73740405",
"0.71982944",
"0.7121713",
"0.70578563",
"0.6901096",
"0.6889874",
"0.67824244",
"0.67653364",
"0.6623727",
"0.6538617",
"0.6535128",
"0.6463564",
"0.6462462",
"0.64054704",
"0.63577175",
"0.634895",
"0.6343886",
"0.6298567",
"0.6297889",
"0.62971133",
"0.629437... | 0.7957978 | 0 |
returns next wednesday from current date | def next_wednesday
date = self
while !date.wednesday?
date = date.next
end
date
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_weekday(weekday = 2)\n date = Date.today\n unless date.strftime(\"%w\") == weekday.to_s\n date += 1 + ((weekday -1 -date.wday) % 7)\n end\n date\n end",
"def next_weekday\n if next_day.on_weekend?\n next_week(:monday, same_time: true)\n else\n next_day\n en... | [
"0.787096",
"0.78274405",
"0.78274405",
"0.77540743",
"0.7439524",
"0.73969996",
"0.73674405",
"0.7300648",
"0.7283888",
"0.72757596",
"0.72629964",
"0.7194018",
"0.71866417",
"0.7171831",
"0.7162202",
"0.7143157",
"0.70982337",
"0.7096239",
"0.7072825",
"0.7052127",
"0.70347... | 0.8511923 | 0 |
This method is there to ensure minimal requirements are met (directories are accessible, table exists, connected to server, ...) | def prepare
namespace = @config[:namespace] || 'merb-cache'
host = @config[:host] || '127.0.0.1:11211'
@memcache = MemCache.new(host, {:namespace => namespace})
@tracking_key = "_#{namespace}_keys" unless @config[:no_tracking]
raise NotReady unless @memcache.active?
true
rescue NameError
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_physical_databases!\n @ensure_physical_databases ||= create_physical_databases\n end",
"def verify_required_data_files!\n unless File.exists?(\"#{@working_directory}/drupal-filesystem.tar.gz\") && File.exists?(\"#{@working_directory}/drupal-db.sql.gz\")\n raise StandardError.new(\"Cann... | [
"0.6237331",
"0.61747175",
"0.6008947",
"0.5968245",
"0.5923211",
"0.5805888",
"0.5781957",
"0.5766757",
"0.574381",
"0.5735627",
"0.56539434",
"0.5649535",
"0.5649384",
"0.564261",
"0.563672",
"0.56263757",
"0.5620631",
"0.5614224",
"0.560949",
"0.5598401",
"0.5588257",
"0... | 0.0 | -1 |
Checks whether a cache entry exists ==== Parameter key:: The key identifying the cache entry ==== Returns true if the cache entry exists, false otherwise | def cached?(key)
not @memcache.get(key).nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_key?(key)\n @cache.has_key?(key)\n end",
"def exist?(key)\n File.exist?(cache_path(key))\n end",
"def exist(key)\n check_return_code(\n Lib.memcached_exist(@struct, key),\n key\n )\n end",
"def include?(key)\n File.exist?(cache_path(key))\n end",
"def ex... | [
"0.84940356",
"0.8457097",
"0.8288326",
"0.7914319",
"0.778418",
"0.76788914",
"0.7676091",
"0.7578737",
"0.75765264",
"0.7541226",
"0.7532098",
"0.750672",
"0.74855816",
"0.74125814",
"0.7369414",
"0.7360646",
"0.7345717",
"0.7333525",
"0.73078674",
"0.7284089",
"0.7272287",... | 0.74226606 | 13 |
Store data to memcache using the specified key ==== Parameters key:: The key identifying the cache entry data:: The data to be put in cache from_now:: The number of minutes (from now) the cache should persist | def cache_set(key, data, from_now = nil)
_expire = from_now ? from_now.minutes.from_now.to_i : 0
@memcache.set(key, data, _expire)
cache_start_tracking(key)
Merb.logger.info("cache: set (#{key})")
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_set(key, data, from_now = nil)\n cache_file = @config[:cache_directory] / \"#{key}.cache\"\n cache_directory = File.dirname(cache_file)\n FileUtils.mkdir_p(cache_directory)\n _expire = from_now ? from_now.minutes.from_now : nil\n cache_write(cache_file, Marshal.dump([data, _expire]))\n ... | [
"0.7734826",
"0.7644012",
"0.72194594",
"0.679156",
"0.67078197",
"0.6538201",
"0.65369654",
"0.649038",
"0.64066094",
"0.6400164",
"0.64001536",
"0.6334162",
"0.6283211",
"0.6273677",
"0.6272086",
"0.6251098",
"0.6229982",
"0.62237704",
"0.62216747",
"0.62216306",
"0.6197455... | 0.7843338 | 0 |
Fetch data from memcache using the specified key The entry is deleted if it has expired ==== Parameter key:: The key identifying the cache entry ==== Returns data:: nil is returned whether the entry expired or was not found | def cache_get(key)
data = @memcache.get(key)
Merb.logger.info("cache: #{data.nil? ? "miss" : "hit"} (#{key})")
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_get(key)\n if @cache.key?(key)\n _data, _expire = *cache_read(key)\n if _expire.nil? || Time.now < _expire\n Merb.logger.info(\"cache: hit (#{key})\")\n return _data\n end\n @mutex.synchronize do @cache.delete(key) end\n end\n Merb.logger.info(\"cache: miss (#{k... | [
"0.7940819",
"0.77572185",
"0.7600439",
"0.730381",
"0.727864",
"0.7180364",
"0.7180364",
"0.71039504",
"0.70910084",
"0.69935817",
"0.6896069",
"0.6851046",
"0.6850593",
"0.68477136",
"0.6779603",
"0.6746968",
"0.6730111",
"0.6697182",
"0.66674095",
"0.66514593",
"0.66059864... | 0.75299907 | 3 |
Expire the cache entry identified by the given key ==== Parameter key:: The key identifying the cache entry | def expire(key)
@memcache.delete(key)
cache_stop_tracking(key)
Merb.logger.info("cache: expired (#{key})")
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expire_cache(key)\n end",
"def expire_cache!(key)\n raise 'The expire_cache method must be implemented'\n end",
"def expire_cached(key:)\n Stockpile::CachedValueExpirer.expire_cached(key: key)\n end",
"def expire(key)\n @mutex.synchronize do\n @cache.delete(key)\n end\n Merb.... | [
"0.8650605",
"0.81345445",
"0.8124842",
"0.7945606",
"0.78019726",
"0.77956474",
"0.767175",
"0.76361096",
"0.74848175",
"0.73043",
"0.7248697",
"0.72268957",
"0.71131635",
"0.70753336",
"0.7050648",
"0.70168084",
"0.699746",
"0.69944173",
"0.6994411",
"0.6937676",
"0.6841984... | 0.7805009 | 4 |
Expire the cache entries matching the given key ==== Parameter key:: The key matching the cache entries ==== Additional info In memcache this requires to keep track of all keys (on by default). If you don't need this, set :no_tracking => true in the config. | def expire_match(key)
if @tracking_key
for _key in get_tracked_keys
expire(_key) if /#{key}/ =~ _key
end
else
Merb.logger.info("cache: expire_match is not supported with memcache (set :no_tracking => false in your config")
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expire_cache(key)\n end",
"def expire_cached(key:)\n Stockpile::CachedValueExpirer.expire_cached(key: key)\n end",
"def expire_cache!(key)\n raise 'The expire_cache method must be implemented'\n end",
"def expire(key)\n @memcache.delete(key)\n cache_stop_tracking(key)\n Merb.logge... | [
"0.7690933",
"0.743312",
"0.7368731",
"0.73639005",
"0.71412426",
"0.7056961",
"0.7027988",
"0.69537395",
"0.6872803",
"0.68672925",
"0.68589056",
"0.6831445",
"0.6762894",
"0.6760081",
"0.64866287",
"0.6430128",
"0.63304",
"0.63207585",
"0.62576133",
"0.62451077",
"0.6230127... | 0.751995 | 1 |
Expire all the cache entries | def expire_all
@memcache.flush_all
stop_tracking_keys
Merb.logger.info("cache: expired all")
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expire_all\n adapter.expire_all\n logger.info('', '', :expired, cache_name)\n end",
"def _expire_cache(*keys)\n Rails.cache.delete( _cache_key(keys) )\n end",
"def expire_all\n @mutex.synchronize do\n @cache.clear\n end\n Merb.logger.info(\"cache: expired all\")\n true... | [
"0.8378065",
"0.8030422",
"0.79589206",
"0.78239626",
"0.7619838",
"0.7587595",
"0.75658965",
"0.7474238",
"0.7286092",
"0.727475",
"0.72594327",
"0.7259049",
"0.72533965",
"0.72397685",
"0.7165339",
"0.7160963",
"0.71405685",
"0.71076477",
"0.7081477",
"0.70809096",
"0.70736... | 0.7906578 | 3 |
Gives info on the current cache store ==== Returns The type of the current cache store | def cache_store_type
"memcache"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type\n @config[:caching][:type]\n end",
"def cache_store_type\n \"dummy\"\n end",
"def retrieve_store_class(store)\n # require_relative cannot be used here because the class might be\n # provided by another gem, like redis-activesupport for example.\n require \"ac... | [
"0.7330008",
"0.7032524",
"0.69761693",
"0.6729079",
"0.66565555",
"0.6566218",
"0.6535954",
"0.6385915",
"0.635425",
"0.6250811",
"0.6250811",
"0.6225362",
"0.6225362",
"0.620501",
"0.61576974",
"0.6132443",
"0.6070084",
"0.6056202",
"0.6039879",
"0.6037328",
"0.6023099",
... | 0.73608345 | 0 |
Store the tracked keys in memcache (used by expire_match) ==== Parameter keys:: The keys to keep track of | def set_tracked_keys(keys)
@memcache.set(@tracking_key, keys)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expire_cache_keys *keys\r\n keys.each { |k| @cache.delete k.to_sym }\r\n end",
"def _expire_cache(*keys)\n Rails.cache.delete( _cache_key(keys) )\n end",
"def cache_delete(*keys)\n if keys\n keys.each do |key|\n record = @store[:key => namespaced(key)]\n ... | [
"0.67881894",
"0.6468192",
"0.6461815",
"0.645246",
"0.64341456",
"0.6167566",
"0.5959207",
"0.5951273",
"0.5951273",
"0.5942901",
"0.5911913",
"0.5887257",
"0.5858332",
"0.58387387",
"0.58237934",
"0.5716165",
"0.56794083",
"0.5675588",
"0.56434715",
"0.56392115",
"0.554742"... | 0.81636864 | 0 |
Retrieve tracked keys from memcache ==== Returns keys:: The tracked keys | def get_tracked_keys
@memcache.get(@tracking_key) || []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_objects_keys\n @object_data[].keys\n end",
"def key_ids\n @keys.keys\n end",
"def keys\n @monitor.synchronize { @stash.keys }\n end",
"def keys\n\t\t\treturn @storage.keys\n\t\tend",
"def keys\n @hash.keys\n end",
"def keys\n @hash.keys\n end",
"def key... | [
"0.7004097",
"0.6902772",
"0.68922305",
"0.6824827",
"0.6816982",
"0.6816982",
"0.6816982",
"0.67646813",
"0.67646813",
"0.6726424",
"0.6712907",
"0.6700374",
"0.6668381",
"0.6648168",
"0.6617792",
"0.65991104",
"0.6525515",
"0.6477177",
"0.64321655",
"0.64056975",
"0.6398333... | 0.82069546 | 0 |
Remove all tracked keys | def stop_tracking_keys
@memcache.delete(@tracking_key) if @tracking_key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_all\n synchronized { @hash = {} }\n end",
"def remove_all_keys\n\t\tdelete(\"/user/keys\")\n\tend",
"def remove_all_keys\n\t\tdelete(\"/user/keys\")\n\tend",
"def clear\n heroku.remove_all_keys\n display \"All keys removed.\"\n end",
"def clear\n heroku.remove_all_keys\n ... | [
"0.7781697",
"0.7711293",
"0.7711293",
"0.7637387",
"0.7637387",
"0.7496556",
"0.7451442",
"0.7438645",
"0.73214936",
"0.7292554",
"0.7275242",
"0.72710973",
"0.7216195",
"0.7192658",
"0.7187513",
"0.71715724",
"0.7083836",
"0.6997382",
"0.69505566",
"0.69397974",
"0.68809354... | 0.69491965 | 19 |
Add a key in the array of tracked keys (used by expire_match) ==== Parameter key:: the key to add | def cache_start_tracking(key)
return unless @tracking_key
keys = get_tracked_keys
keys.push(key)
set_tracked_keys(keys)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_key(key)\n keys.add(key)\n end",
"def add(key)\n @internal_hash[key] = true\n end",
"def add( key_file )\n @key_files.push( key_file ).uniq!\n self\n end",
"def add(key, value)\n update_array(key, value, :add)\n end",
"def insert(key)\n @k... | [
"0.8169",
"0.704668",
"0.6907145",
"0.6874536",
"0.68710005",
"0.6612582",
"0.656328",
"0.6506404",
"0.6465425",
"0.6456198",
"0.640189",
"0.63858557",
"0.6362564",
"0.6356876",
"0.6323165",
"0.63218915",
"0.63056874",
"0.6292981",
"0.62851053",
"0.62638396",
"0.6240793",
"... | 0.6475322 | 8 |
Remove a key from the array of tracked keys (used by expire_match) ==== Parameter key:: the key to remove | def cache_stop_tracking(key)
return unless @tracking_key
keys = get_tracked_keys
keys.delete(key)
set_tracked_keys(keys)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(key); end",
"def remove(key)\n @store.delete_if { |i| i[:key] == build_key(key) }\n end",
"def remove(key)\n\n if include?(key)\n self[key].delete(key)\n @count -= 1\n end\n\n end",
"def remove(key)\n\n end",
"def remove(key)\n a_hash[key] = nil\n end",
"def... | [
"0.77511764",
"0.764434",
"0.7594666",
"0.7500757",
"0.7339274",
"0.73385334",
"0.7308718",
"0.72621405",
"0.7230989",
"0.7210839",
"0.71979815",
"0.71966237",
"0.71826476",
"0.71803576",
"0.71578467",
"0.7098925",
"0.70959204",
"0.70691776",
"0.70691776",
"0.70691776",
"0.70... | 0.63374525 | 79 |
Tell why the geometry is not valid, `nil` means it is valid. | def invalid_reason
if defined?(super) == "super"
raise Error::RGeoError, "ValidityCheck MUST be loaded before " \
"definition of #{self.class}##{__method__}."
end
raise Error::UnsupportedOperation, "Method #{self.class}##{__method__} not defined."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_reason\n FFIGeos.GEOSisValidReason_r(Geos.current_handle_pointer, ptr)\n end",
"def validate_geometry(geometry)\n geometry.tap do |g|\n total = g.width + g.height\n raise ScaleDown::InvalidGeometry if total == 0\n raise ScaleDown::InvalidGeometry if g.width > ScaleDown... | [
"0.696121",
"0.6626763",
"0.6435146",
"0.6326332",
"0.6312135",
"0.62558997",
"0.6205111",
"0.6161946",
"0.6153711",
"0.61103314",
"0.6073514",
"0.6057115",
"0.60427356",
"0.60351163",
"0.60351163",
"0.6033082",
"0.6033082",
"0.6033082",
"0.6033082",
"0.6033082",
"0.60253626"... | 0.0 | -1 |
Try and make the geometry valid, this may change its shape. Returns a valid copy of the geometry. | def make_valid
if defined?(super) == "super"
raise Error::RGeoError, "ValidityCheck MUST be loaded before " \
"definition of #{self.class}##{__method__}."
end
raise Error::UnsupportedOperation, "Method #{self.class}##{__method__} not defined."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_geometry(geometry)\n geometry.tap do |g|\n total = g.width + g.height\n raise ScaleDown::InvalidGeometry if total == 0\n raise ScaleDown::InvalidGeometry if g.width > ScaleDown.max_dimensions[0] || g.height > ScaleDown.max_dimensions[1]\n end\n end",
"def geometry\n... | [
"0.6137213",
"0.6025622",
"0.5874996",
"0.5766039",
"0.57558864",
"0.56415963",
"0.534868",
"0.53351253",
"0.5247452",
"0.5243225",
"0.5230586",
"0.5191058",
"0.5191058",
"0.5165842",
"0.51457846",
"0.5099582",
"0.50561446",
"0.50388336",
"0.50222486",
"0.5011283",
"0.5011035... | 0.0 | -1 |
Get an image file object by passing in the filename | def image(filename)
if not File.file?(File.join(Rails.root, 'db', 'seed', 'images', filename))
abort("Error: please ensure the file named #{filename} exists")
end
File.new(File.join(Rails.root, 'db', 'seed', 'images', filename))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image\n MiniMagick::Image.open(filename)\n rescue MiniMagick::Invalid\n # Proceed as if this is not an image\n nil\n end",
"def read_image(filename)\n if filename\n image = Magick::Image.read(filename).first\n return image\n end\n end",
"def image\n @image ||= M... | [
"0.717793",
"0.71555066",
"0.6728952",
"0.66683",
"0.6604901",
"0.65894127",
"0.65659946",
"0.65235114",
"0.650377",
"0.64938456",
"0.6469755",
"0.64651465",
"0.64166987",
"0.63764024",
"0.6373741",
"0.63514626",
"0.63309115",
"0.62961555",
"0.62886626",
"0.62775785",
"0.6254... | 0.6076532 | 30 |
Seed an image by passing its file name, imageable type (e.g. Banner, Product) and imageable id (the id of the object being the image belongs to) | def seed_image(filename, imageable_type, imageable_id)
Picture.create!(
:id => $image_id,
:image => image(filename),
:imageable_type => imageable_type,
:imageable_id => imageable_id
)
$image_id += 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_image(title, description, parent_id, mime_type, file_name)\n\t insert_file(title, description, parent_id, 'application/vnd.google-apps.photo', file_name)\n\tend",
"def create_image(image)\n self.images.create(image: image) if image.present?\n end",
"def image(filename)\n if not File.file?(File... | [
"0.67103827",
"0.6587216",
"0.64055264",
"0.634066",
"0.6290271",
"0.62429047",
"0.6206341",
"0.6201628",
"0.6168619",
"0.6123131",
"0.61099833",
"0.609694",
"0.6067298",
"0.60596555",
"0.60488516",
"0.6036508",
"0.6034444",
"0.6034444",
"0.6034444",
"0.6034444",
"0.6034444",... | 0.83658993 | 0 |
recipient (string) sms recipient in general format; e.g. '+886912345678' message (string) message content options (hash) optional config options.ignore_cert (boolean) Ignore SSL certificate or not options.insecure (boolean) Use plain HTTP or HTTPS options.mode (string) delivery mode 'bit' instant delivery (default) 'bu... | def deliver(recipient, message, options={})
protocol = options[:insecure] ? "http" : "https"
uri = URI.parse "#{protocol}://#{API_HOST}"
uri.path = case (options[:mode].to_sym rescue nil)
when nil, :bit
SMS_ENDPOINT
when :bulk
BULK_SMS_ENDPOINT
else
raise StandardError... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deliver_sms(params)\n#puts \"**** Message#deliver_sms; params=#{params}\"\n sms_gateway = params[:sms_gateway]\n phone_number_array = @contact_info.map {|c| c[:phone]}.compact.uniq\n phone_numbers = phone_number_array.join(',')\n assemble_sms()\n#puts \"**** sms_gateway.deliver #{sms_gateway} w #{p... | [
"0.6247631",
"0.6133201",
"0.5962416",
"0.5926002",
"0.5901603",
"0.5879868",
"0.58379805",
"0.58018184",
"0.58001703",
"0.5750512",
"0.5749427",
"0.5743206",
"0.57254726",
"0.5708531",
"0.5705451",
"0.5702569",
"0.5699854",
"0.5676836",
"0.5674442",
"0.56590253",
"0.56587434... | 0.63261914 | 0 |
Returns content for palindrome testing. | def processed_content
to_s.scan(/[a-z\d]/i).join.downcase
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def palindrome?\n processed_content = self.content.downcase\n processed_content == processed_content.reverse\n end",
"def palindrome?\n #can also be written as processed_content = @content.downcase\n processed_content == processed_content.reverse\n end",
"def palindrome?\n if process... | [
"0.78215855",
"0.77056116",
"0.74646527",
"0.74529034",
"0.73807824",
"0.73807824",
"0.69562006",
"0.677419",
"0.6742182",
"0.67274034",
"0.6726408",
"0.6698095",
"0.66943634",
"0.6660575",
"0.6643621",
"0.6636674",
"0.66109383",
"0.65968305",
"0.65919346",
"0.6576927",
"0.65... | 0.0 | -1 |
POST Modifies the starting location. Used for Kiosk mode. | def origin
unless params[:origin].blank?
params[:origin].slice!(0) if params[:origin][0].upcase == "R" # Remove proceeding R if present
origin = params[:origin].to_s.rjust(4, '0').prepend("R") # Add zero padding and Prepend R
session[:start] = origin
cookies.permanent[:origin] = origin.upcas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start\n unless params[:location].blank? or cookies[:origin].present?\n params[:location].slice!(0) if params[:location][0].upcase == \"R\" # Remove proceeding R if present\n start_location = params[:location].to_s.rjust(4, '0').prepend(\"R\") # Add zero padding and Prepend R\n cookies.permane... | [
"0.6110914",
"0.5793921",
"0.5705552",
"0.5650262",
"0.55903393",
"0.5515551",
"0.53945667",
"0.53575295",
"0.53048974",
"0.5268503",
"0.52399457",
"0.521427",
"0.521427",
"0.51967525",
"0.51783925",
"0.5168158",
"0.5166256",
"0.5159487",
"0.5148909",
"0.5127986",
"0.5120559"... | 0.0 | -1 |
GET Modifies the starting location passed via URL (QR Codes) Passes starting location as the room number Redirects immediately to Map | def start
unless params[:origin].blank?
params[:origin].slice!(0) if params[:origin][0].upcase == "R" # Remove proceeding R if present
origin = params[:origin].to_s.rjust(4, '0').prepend("R") # Add zero padding and Prepend R
session[:start] = origin.upcase
end
redirect_to "/map"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @mapURL = map_url(@location.address)\n render :show\n end",
"def location\n @client.get(\"#{path}/location\")\n end",
"def get_by_location\n \tlat = params[:lat]\n \tlng = params[:lng]\n \tnext_start = params[:next_start]\n \tshops = Hotpepper.search_location(lat, lng, next_st... | [
"0.6155691",
"0.585538",
"0.5851553",
"0.58069074",
"0.57812464",
"0.5770744",
"0.57235765",
"0.57201725",
"0.5680059",
"0.55999684",
"0.55897725",
"0.5575051",
"0.5547962",
"0.55264217",
"0.5519914",
"0.5516726",
"0.54907876",
"0.5490285",
"0.54848766",
"0.5468661",
"0.54567... | 0.66142786 | 0 |
POST /logvisitor Logs a visitor. Called from redirect.js, which redirects to home after 2 minutes of inactivity. Logs a visitor after one minute of inactivity. | def logvisitor
@visitor.end = DateTime.current
@visitor.save
render :nothing => true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_visit\n session_id = request.session_options[:id]\n client = DeviceDetector.new(request.env[\"HTTP_USER_AGENT\"])\n client_os = client.os_name\n if !VisitorLog.find_by_session_id(session_id)\n VisitorLog.create(:session_id => session_id, :logged_in => false, :device_type => client_os)\n ... | [
"0.67755216",
"0.65221065",
"0.6351727",
"0.61986196",
"0.60083514",
"0.6008046",
"0.5907962",
"0.5881883",
"0.5810546",
"0.5589945",
"0.5542837",
"0.55297786",
"0.5526256",
"0.5517241",
"0.54993564",
"0.54477334",
"0.5386828",
"0.5366683",
"0.5328699",
"0.5314285",
"0.530728... | 0.747792 | 0 |
Not sure if this method is used anywhere. May be safe to remove (and its associated test). | def department_location
room_number = params[:department_room_number]
id = params[:department_id]
room = Room.where(room_number: room_number).first_or_create
department = Department.find(id)
department.room = room
respond_to do |format|
if department.save && room_number.present?
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def teardown\n # No-op\n end",
"def teardown; end",
"def teardown; end",
"def teardown\r\n end",
"def teardown\n end",
"def teardown\n end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def teardown\n # Empty\n end",
"def tear... | [
"0.6982562",
"0.6964223",
"0.6964223",
"0.68784964",
"0.68616194",
"0.68616194",
"0.68571436",
"0.68571436",
"0.68571436",
"0.68571436",
"0.6855948",
"0.6855948",
"0.68421805",
"0.68421805",
"0.6838619",
"0.6830802",
"0.6830802",
"0.6826895",
"0.6820012",
"0.6820012",
"0.6820... | 0.0 | -1 |
POST Import a CSV file | def csv
require 'csv'
unless params[:uploaded_csv].blank?
csv_path = params[:uploaded_csv].path
# Wipe database on csv load, will need to be modified when event RSS feeds are fixed
data_validated = false
begin
CSV.foreach(csv_path, :headers => true) do |row|
csv_build... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import\n if (params[:file].nil?)\n redirect_to upload_posts_path, notice: Messages::POST_UPLOAD_FILE_VALIDATION\n elsif !File.extname(params[:file]).eql?(\".csv\")\n redirect_to upload_posts_path, notice: Messages::POST_UPLOAD_CSV_FORMAT_ERROR\n else\n error_messages = PostsHelper.check... | [
"0.76166224",
"0.7596468",
"0.73232114",
"0.7321852",
"0.73090726",
"0.7177098",
"0.7153369",
"0.71468693",
"0.7121341",
"0.71149886",
"0.70809525",
"0.7061352",
"0.7048606",
"0.70431477",
"0.70223266",
"0.6974748",
"0.69640493",
"0.6879288",
"0.68585986",
"0.6842251",
"0.683... | 0.0 | -1 |
POST Upload an SVG map | def map_upload
unless params[:uploaded_map].blank?
require 'fileutils'
# Ensure public/maps exists
FileUtils::mkdir_p "public/maps"
directory = "public/maps.tmp"
# Ensure a blank maps.tmp directory exists
FileUtils.rm_rf directory
FileUtils::mkdir_p directory
# Cop... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_modified_svg(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end",
"def create\n @svgpost = Svgpost.new(params[:svgpost])\n\n respond_to do |format|\n if @svgpost.save\n format.html { redirect_to @svgpost, ... | [
"0.6345288",
"0.60454863",
"0.5910406",
"0.5904281",
"0.57501334",
"0.5699276",
"0.55295473",
"0.55014163",
"0.53606075",
"0.5318381",
"0.53156465",
"0.5296549",
"0.5285719",
"0.5275586",
"0.5257626",
"0.5251734",
"0.5231633",
"0.52070206",
"0.5196743",
"0.5192396",
"0.517660... | 0.7257759 | 0 |
, :except => [ :list, :index, :show ] | def admin_access
if current_user.access? :admin
return true
elsif current_user
flash[:notice] = "Du har ikke adgang til denne side"
redirect_to nationalities_path
else
flash[:notice] = "Du har ikke adgang til denne side"
redirect_to login_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n prevent_non_admin\n end",
"def index # Only view\n end",
"def exclude; end",
"def skip_actions; end",
"def index\n @unwanteds = Unwanted.all\n end",
"def excluded; end",
"def show\n skip_authorization\n end",
"def index\n super\n end",
"def index\n\t\trender :nothing =>... | [
"0.6920027",
"0.69064814",
"0.6796341",
"0.6749889",
"0.67018455",
"0.6641809",
"0.6630838",
"0.6596641",
"0.65870297",
"0.6580645",
"0.6422456",
"0.64153963",
"0.6361794",
"0.63441455",
"0.63201255",
"0.63158643",
"0.6274175",
"0.6261968",
"0.62484145",
"0.6238501",
"0.62385... | 0.0 | -1 |
currently a noop method. If a format other than mongo query format is used for prefilters, this method would do the appropriate conversion | def convert_filter_to_mongo_query(filter)
filter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cast_value\n value.mongoize\n end",
"def queryAndConvert() \n\t\tres = self.query()\n\t\treturn res.convert()\n end",
"def convert(obj)\n ret = convert_proc.call(obj)\n filters.execute(ret)\n end",
"def post_conversion(converted_query)\n return unless (converted_query && ... | [
"0.61837065",
"0.6159584",
"0.5950193",
"0.58030474",
"0.578086",
"0.5766119",
"0.5676294",
"0.5637948",
"0.5543535",
"0.5540873",
"0.5540873",
"0.5540873",
"0.54870456",
"0.54727894",
"0.54264444",
"0.53915036",
"0.5389541",
"0.5389541",
"0.53628594",
"0.5360193",
"0.5345107... | 0.6503161 | 0 |
Taken from No, I don't understand it. I'm so very glad someone else had written the function in Ruby already. I have cleaned it up a little, mind you. | def lower_bound
return 0 if total == 0
(
phat + dist_sq/(2*total) - dist * Math.sqrt((phat*(1-phat)+dist_sq/(4*total))/total)
) / (
1+dist_sq/total
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anchored; end",
"def probers; end",
"def rassoc(p0) end",
"def private; end",
"def terpene; end",
"def stderrs; end",
"def NL43_locator(seq=\"\",temp_dir=File.dirname($0))\n hxb2_ref = \"TGGAAGGGCTAATTTGGTCCCAAAAAAGACAAGAGATCCTTGATCTGTGGATCTACCACACACAAGGCTACTTCCCTGATTGGCAGAACTACACACCAGGGCCAGGGATCA... | [
"0.55222267",
"0.5253322",
"0.5247037",
"0.5245344",
"0.52333957",
"0.5209013",
"0.5171067",
"0.5133766",
"0.50971305",
"0.5078304",
"0.5058504",
"0.5055896",
"0.50149393",
"0.49791473",
"0.4974453",
"0.49652758",
"0.4925356",
"0.4924265",
"0.491668",
"0.49029976",
"0.4893860... | 0.0 | -1 |
Named as in p with a ^ (hat). Not phat as in fat. | def phat
@phat ||= 1.0 * positive/total
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ^(p0) end",
"def ^(p0) end",
"def ^(p0) end",
"def ^(p0) end",
"def ^(p0) end",
"def ^(arg0)\n end",
"def ^(arg0)\n end",
"def ^(arg0)\n end",
"def |(p0) end",
"def |(p0) end",
"def |(p0) end",
"def |(p0) end",
"def |(p0) end",
"def |(p0) end",
"def prefix!( *pf )\r\n clone.... | [
"0.6600134",
"0.6600134",
"0.6600134",
"0.6600134",
"0.6600134",
"0.6059679",
"0.6059679",
"0.6059679",
"0.5816411",
"0.5816411",
"0.5816411",
"0.5816411",
"0.5816411",
"0.5816411",
"0.5789358",
"0.56973857",
"0.56973857",
"0.56973857",
"0.56973857",
"0.56973857",
"0.56973857... | 0.0 | -1 |
Retrieves the git channel for the specific IRC channel | def git_channel(channel)
return @channels[channel] if @channels[channel]
@channels[channel] = Git::Channel.new(@config[channel.server.name][channel.nname])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_channel_by_name(client, channel_name)\n channel_data = client.channels_info(channel: \"#\" + channel_name.to_s)\n channel_data.channel.id\nend",
"def channel\n Channel.get(@name)\n end",
"def channel\n @channels[BASE_PATH]\n end",
"def channel_name\n @channel_name ||= SlackUtils::S... | [
"0.6916028",
"0.69111717",
"0.6870902",
"0.65356845",
"0.64999634",
"0.6493034",
"0.64337313",
"0.6372567",
"0.635321",
"0.6327158",
"0.6298036",
"0.6194856",
"0.618641",
"0.61220217",
"0.6047776",
"0.6002146",
"0.59374535",
"0.59219605",
"0.59219605",
"0.5915711",
"0.5908137... | 0.7265467 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.