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 |
|---|---|---|---|---|---|---|
Tests that the course's teacher_id is not nil and returns true or false. | def teacher_is_valid?
return self.teacher_id != nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_teacher?(teacher)\n return @has_teacher\n end",
"def can_create_course?\n ptainstructors = Ptainstructor.find_by_semester_id(self.id)\n teachers = Teacher.find_by_semester_id(self.id)\n if ((ptainstructors == nil) or (teachers == nil))\n return false\n end\n return true\n end",... | [
"0.7449263",
"0.7200843",
"0.68973225",
"0.67134386",
"0.67134386",
"0.6505894",
"0.6498933",
"0.64595133",
"0.64591366",
"0.64050275",
"0.64050275",
"0.64050275",
"0.63600016",
"0.63040674",
"0.62889653",
"0.6263735",
"0.6236275",
"0.62268835",
"0.61472505",
"0.61325",
"0.61... | 0.81804997 | 0 |
Returns true if not nil and a string | def not_nil_and_string(str)
return true unless ((str == nil) or (not str.instance_of? String))
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string?\n !@arg[:textValue].nil?\n end",
"def plain_string?\n (type == :string || type == :text) && # String typed\n !value.nil? &&\n !value.empty? &&\n !is_text_run? && # No inline styles\n !is_formula? &&\n !is_array_formula?\n end",
"def is_nil_or_empty... | [
"0.77826357",
"0.7532298",
"0.7471273",
"0.73913074",
"0.7351006",
"0.72637653",
"0.7220084",
"0.72026634",
"0.7195809",
"0.7175912",
"0.7134027",
"0.71185726",
"0.71095157",
"0.70471597",
"0.6998655",
"0.6998655",
"0.6924642",
"0.68650234",
"0.68450797",
"0.6827738",
"0.6824... | 0.84099704 | 2 |
Returns array with number of students in course and class_max. | def class_how_full?
return [self.students.count, self.class_max]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expected_grades\n assignment.course.students.count\n end",
"def expected_grades\n metrics.count * course.students.count\n end",
"def num_grades (student)\n @grades[student].length\n end",
"def find_max\n\t# Use method: stu_max = @students_list.max_by{|x| x.avg}\n\t max =0\n\t for i in... | [
"0.6461427",
"0.6382975",
"0.6140354",
"0.59984523",
"0.59177566",
"0.59177566",
"0.59030765",
"0.58153164",
"0.5814784",
"0.57280606",
"0.56930727",
"0.5684635",
"0.5638393",
"0.5582642",
"0.55610883",
"0.55566406",
"0.55316156",
"0.55268115",
"0.55179995",
"0.54999554",
"0.... | 0.72358114 | 0 |
get next step and do error check | def get_next_coords_with_check(rv_inst)
x, y = next_step(rv_inst)
return false unless within_boundary?(x, y)
[x, y]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_step\n self.step_flow.next_step if can_increment_step\n end",
"def next_step\n if goto_true.present?\n fs = FlowStep.job_flow_step(job_id: job_id, flow_step: goto_true)\n if fs.entered?\n job.quarantine!(msg: \"Broken flow, step already entered #{fs.step}, called from #{self.step... | [
"0.7344636",
"0.72298145",
"0.69111645",
"0.6673074",
"0.6626729",
"0.6489606",
"0.64854777",
"0.64048445",
"0.6333045",
"0.63223755",
"0.62552595",
"0.62164146",
"0.6188408",
"0.6183894",
"0.6120049",
"0.6107624",
"0.60964954",
"0.60677344",
"0.6057557",
"0.6050881",
"0.6028... | 0.0 | -1 |
GET /users GET /users.json | def index
set_records_count_header @application.users
@users = @application.users.offset(params[:offset] || 0).limit(params[:limit] || 6).all
render json: @users
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end",
"def GetUsers params = {}\n\n para... | [
"0.82109934",
"0.7873764",
"0.7860689",
"0.78108346",
"0.78067017",
"0.7678852",
"0.76586664",
"0.76318866",
"0.7582366",
"0.75291824",
"0.7487637",
"0.74485743",
"0.7439024",
"0.7437192",
"0.7427442",
"0.73978853",
"0.73978853",
"0.73978853",
"0.73978853",
"0.7377353",
"0.73... | 0.0 | -1 |
GET /users/1 GET /users/1.json | def show
render json: @user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ... | [
"0.81046426",
"0.7703556",
"0.77011716",
"0.76262826",
"0.7582106",
"0.74818",
"0.7461394",
"0.7446168",
"0.730656",
"0.7300699",
"0.72902125",
"0.72781444",
"0.72358584",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.722... | 0.0 | -1 |
POST /users POST /users.json | def create
@user = @application.users.create(user_params)
if @user.valid?
render json: @user, status: :created, location: api_application_user_path(@application,@user)
else
render json: @user.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end",
"def post b... | [
"0.77171224",
"0.7520082",
"0.7383616",
"0.72409296",
"0.71978706",
"0.71414214",
"0.7104655",
"0.7059102",
"0.7041023",
"0.70248663",
"0.7003639",
"0.7002607",
"0.7002607",
"0.7002607",
"0.6992824",
"0.6990796",
"0.6980945",
"0.69801277",
"0.6979133",
"0.6979133",
"0.6976736... | 0.69177127 | 26 |
PATCH/PUT /users/1 PATCH/PUT /users/1.json | def update
if @user.update(user_params)
render json: @user, status: :ok, location: api_application_user_path(@application,@user)
else
render json: @user.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"de... | [
"0.72248507",
"0.7128768",
"0.7003289",
"0.6902831",
"0.68211025",
"0.681476",
"0.6707567",
"0.6692646",
"0.667998",
"0.66728854",
"0.66717863",
"0.666447",
"0.666447",
"0.66587144",
"0.66587144",
"0.6653841",
"0.6647832",
"0.6642772",
"0.6640692",
"0.6634225",
"0.66175383",
... | 0.0 | -1 |
DELETE /users/1 DELETE /users/1.json | def destroy
@user.destroy
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
"def delete\n render json: Users.delete(params[\"id\... | [
"0.7875006",
"0.7750684",
"0.7713516",
"0.7609021",
"0.7470493",
"0.7405674",
"0.7405674",
"0.7367919",
"0.7344157",
"0.7337963",
"0.7326088",
"0.7308071",
"0.73078537",
"0.73048145",
"0.72960234",
"0.728958",
"0.7289456",
"0.7287733",
"0.7282039",
"0.7248638",
"0.7248638",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = @application.users.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def user_params
params.require(:user).permit(:first_name, :last_name, :email, role_ids: [])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.6949516",
"0.68133247",
"0.6803944",
"0.6795208",
"0.6745487",
"0.67407674",
"0.65270406",
"0.6520888",
"0.6491314",
"0.6430685",
"0.6430685",
"0.6430685",
"0.6398393",
"0.6355302",
"0.63544565",
"0.6347063",
"0.6343035",
"0.63376737",
"0.6326283",
"0.6326283",
"0.6326283"... | 0.0 | -1 |
get lat/long from Google Maps API (but don't do this with seed file because it already has lat/long and there is a limit of 2500 free Geocoder API daily requests) | def store_lat_long
if self.lat == nil or self.long == nil # remove if condition once we are done with seeding (prevents updating of address from changing lat/long)
full_address = UsersController.helpers.get_full_address(self)
if full_address
geocoder = Geocoder.new
lat_long = geocoder.getLatLong(full_address)
self.lat = lat_long.lat
self.long = lat_long.long
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLocation\n loc = Addressable::URI.new(\n :scheme => \"https\",\n :host => \"maps.googleapis.com\",\n :path => \"maps/api/geocode/json\",\n :query_values => {:address => \"160+Folsom,+San+Francisco,+CA\",\n :sensor => \"false\"}).to_s\n\n location_request = RestCl... | [
"0.80758435",
"0.7882811",
"0.7423059",
"0.736033",
"0.73394614",
"0.7172164",
"0.7158358",
"0.70930356",
"0.70808554",
"0.70366",
"0.6963212",
"0.69458073",
"0.6872593",
"0.68240243",
"0.6811838",
"0.6769961",
"0.6768718",
"0.6767218",
"0.6739678",
"0.67289066",
"0.6652707",... | 0.6053369 | 64 |
GET /chores GET /chores.json | def index
if params[:inactive]
@chores = @dwelling.chores.inactive
else
@chores = @dwelling.chores.active
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @chores }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @chores = Chore.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @chores }\n end\n end",
"def index\n @chores = Chore.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @chores ... | [
"0.7667952",
"0.7667952",
"0.73327523",
"0.663462",
"0.65576047",
"0.65516376",
"0.6535003",
"0.65298945",
"0.6520278",
"0.65133876",
"0.65133876",
"0.64939165",
"0.64831054",
"0.64747036",
"0.6400427",
"0.6392898",
"0.6392401",
"0.6387337",
"0.63791645",
"0.6378337",
"0.6320... | 0.0 | -1 |
GET /chores/1 GET /chores/1.json | def show
respond_to do |format|
format.html # show.html.erb
format.json { render json: @chore }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @chores = Chore.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @chores }\n end\n end",
"def index\n @chores = Chore.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @chores ... | [
"0.7217747",
"0.7217747",
"0.7068815",
"0.6629999",
"0.6605961",
"0.65608907",
"0.65493286",
"0.647383",
"0.6466289",
"0.6445522",
"0.64377236",
"0.64305204",
"0.6425135",
"0.64091754",
"0.64091754",
"0.63869417",
"0.63065416",
"0.63034844",
"0.6289654",
"0.6283831",
"0.62499... | 0.6263101 | 20 |
GET /chores/new GET /chores/new.json | def new
@chore = Chore.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @chore }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @what = What.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @what }\n end\n end",
"def new\n @trecho = Trecho.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trecho }\n end\n end"... | [
"0.7724551",
"0.7696025",
"0.75392795",
"0.75392795",
"0.75292146",
"0.7518587",
"0.7508558",
"0.7488637",
"0.74832785",
"0.7445576",
"0.7434531",
"0.74166805",
"0.7416609",
"0.7412969",
"0.74036425",
"0.74007285",
"0.7393031",
"0.7391988",
"0.7384591",
"0.7375571",
"0.736899... | 0.73945916 | 17 |
POST /chores POST /chores.json | def create
@chore = @dwelling.chores.build(params[:chore])
@chore.owner = current_user
@chore.active = true
# Make the actual cron-format string
cron_cmd = "/bin/bash -l -c 'cd #{Rails.root} && bundle exec rake chores:activate_chore CHORE_ID="
case @chore.cron_str
when "Every M/W/F"
@chore.cron_str = "0 0 * * MON,WED,FRI #{cron_cmd}"
when "Every T/Th"
@chore.cron_str = "0 0 * * TUE,THU #{cron_cmd}"
when "Every Sunday"
@chore.cron_str = "0 0 * * SUN #{cron_cmd}"
else
@chore.cron_str = nil
end
# if @chore.cron_str
# puts @chore.cron_str
# puts (CronEdit::Crontab.Add "chore_#{params[:id]}", @chore.cron_str)
# end
respond_to do |format|
if @chore.save
if @chore.cron_str
puts @chore.cron_str
puts (CronEdit::Crontab.Add "chore_#{@chore.id}", "#{@chore.cron_str}#{@chore.id}'")
end
format.html { redirect_to @chore, notice: 'Chore was successfully created.' }
format.json { render json: @chore, status: :created, location: @chore }
else
format.html { render :new }
format.json { render json: @chore.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @trecho = Trecho.new(params[:trecho])\n\n respond_to do |format|\n if @trecho.save\n format.html { redirect_to @trecho, notice: 'Trecho was successfully created.' }\n format.json { render json: @trecho, status: :created, location: @trecho }\n else\n format.html { r... | [
"0.6310843",
"0.61941934",
"0.61177766",
"0.6102432",
"0.6085019",
"0.6085019",
"0.5890039",
"0.5855365",
"0.5853253",
"0.58197314",
"0.58007395",
"0.57716566",
"0.5770526",
"0.5768314",
"0.57669896",
"0.57569224",
"0.5743025",
"0.5720324",
"0.57035047",
"0.56996423",
"0.5699... | 0.0 | -1 |
PUT /chores/1 PUT /chores/1.json | def update
# TODO: Add cron_str updating
respond_to do |format|
if @chore.update_attributes(params[:chore])
format.html { redirect_to @chore, notice: 'Chore was successfully updated.' }
format.json { head :no_content }
else
format.html { render :edit }
format.json { render json: @chore.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (k... | [
"0.62771356",
"0.6196834",
"0.6012672",
"0.59981066",
"0.5987398",
"0.5973499",
"0.5958063",
"0.5890946",
"0.58825177",
"0.58708787",
"0.58613443",
"0.5828852",
"0.58155924",
"0.58119524",
"0.5797129",
"0.57598126",
"0.57539856",
"0.57539666",
"0.57370955",
"0.5734351",
"0.57... | 0.0 | -1 |
DELETE /chores/1 DELETE /chores/1.json | def destroy
if @chore.cron_str
puts "Removing #{@chore.id} from crontab #{@chore.cron_str}"
CronEdit::Crontab.Remove "chore_#{@chore.id}"
end
@chore.destroy
respond_to do |format|
format.html { redirect_to chores_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n end\n end",
"def destroy\n @relogio = Relogio.find(params[:id])\n @relogio.destroy\n\n respond... | [
"0.7116329",
"0.6966691",
"0.68851936",
"0.687377",
"0.6866558",
"0.6849486",
"0.6830195",
"0.67674917",
"0.67503357",
"0.6733298",
"0.67235756",
"0.67218965",
"0.67200875",
"0.6710213",
"0.6709624",
"0.6709523",
"0.6704778",
"0.6683748",
"0.6662799",
"0.6644471",
"0.6643353"... | 0.0 | -1 |
PUT /chores/1/deactivate PUT /chores/1/deactivate.json | def deactivate
permission_denied unless @chore.active
@chore.update_attribute(:active, false)
redirect_to chores_url, notice: "Chore was successfully deactivated"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deactivate!\n update(status: false)\n end",
"def deactivate\n @administrator.deactivate\n respond_to do |format|\n format.html { redirect_to %i[admin settings root], notice: t('.success') }\n format.json { head :no_content }\n end\n end",
"def deactivate!\n update!(active: false)... | [
"0.6535043",
"0.6502027",
"0.6497195",
"0.6474528",
"0.6473345",
"0.64664996",
"0.6379119",
"0.6335481",
"0.63133657",
"0.6246437",
"0.6218604",
"0.6201164",
"0.6141221",
"0.61262643",
"0.61262643",
"0.6048281",
"0.6043066",
"0.6030595",
"0.59413356",
"0.5925472",
"0.59025437... | 0.6285831 | 9 |
Needs to be correctly rubyfied | def write_cdl(formater, strict = false)
@netcdf_elmt.write_cdl(formater, strict)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def berlioz; end",
"def formation; end",
"def verdi; end",
"def schubert; end",
"def ruby_code(obj); end",
"def yyerrok; end",
"def yyerrok; end",
"def terpene; end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
... | [
"0.6405247",
"0.59887683",
"0.597267",
"0.5894008",
"0.58938324",
"0.58494395",
"0.58386767",
"0.5763663",
"0.5763663",
"0.5743984",
"0.5727187",
"0.5727187",
"0.5727187",
"0.5727187",
"0.5642698",
"0.5619231",
"0.56012976",
"0.5598274",
"0.5598274",
"0.5597811",
"0.5597811",... | 0.0 | -1 |
def fibonacci (num) array = [0] newnum = (num + array.last) array.push(newnum) return fibonacci(array.last) end puts fibonacci(1) def fibonacci(n) n <= 1 ? n : fibonacci( n 1 ) + fibonacci( n 2 ) end puts fibonacci(5) | def fibonacci(a, b, count, count_limit)
if(count >= count_limit)
return a
else
c = a + b
puts a
a = b
b = c
fibonacci(a, b, count += 1, count_limit)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fibonacci(num)\n if num == 0\n return 0\n end\n array = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]\n array[num - 1] + fibonacci(num - 2)\nend",
"def fibonacci( n )\r\n fib_nums = []\r\n return n if n <= 1\r\n fib_nums << fibonacci( n - 1 )\r\n fib_nums << fibonacci( n - 2 )\r\n p \"#{fib_nums}... | [
"0.90173095",
"0.893149",
"0.88415843",
"0.8812374",
"0.87966496",
"0.87907535",
"0.87907535",
"0.87704897",
"0.8757011",
"0.87508065",
"0.87498444",
"0.8740849",
"0.8740849",
"0.8719238",
"0.87175226",
"0.87175226",
"0.87102616",
"0.8702471",
"0.86989176",
"0.86873835",
"0.8... | 0.0 | -1 |
Characterizes the file at 'filepath' if available, otherwise, pulls a copy from the repository and runs characterization on that file. | def perform(file_set, file_id, filepath = nil, user = nil)
@event_start = DateTime.current
@relation = file_set.class.characterization_proxy
file = file_set.characterization_proxy
raise "#{@relation} was not found for FileSet #{file_set.id}" unless file_set.characterization_proxy?
filepath = Hyrax::WorkingDirectory.find_or_retrieve(file_id, file_set.id) unless filepath && File.exist?(filepath)
characterize(
file: file,
filepath: filepath,
user: user,
file_set: file_set
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform(file_set, file_id, filepath = nil)\n raise \"#{file_set.class.characterization_proxy} was not found for FileSet #{file_set.id}\" unless file_set.characterization_proxy?\n\n filepath = Hyrax::WorkingDirectory.find_or_retrieve(file_id, file_set.id) unless filepath && File.exist?(filepath)\n char... | [
"0.52823174",
"0.5210008",
"0.5159241",
"0.51019925",
"0.5078289",
"0.50264984",
"0.50216323",
"0.49831176",
"0.49456105",
"0.49415442",
"0.48564264",
"0.4850974",
"0.47973493",
"0.47727823",
"0.47692093",
"0.4724287",
"0.47218582",
"0.46690923",
"0.46659172",
"0.46640107",
"... | 0.58841264 | 0 |
this method must use rand rand is already tested | def random_add(num, options = [1,2,3,4,5,6,7,8,9,10])
num + options.sample
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random()\n \n end",
"def get_random()\n \n end",
"def rand\n Kernel.rand(self)\n end",
"def random_to_one\n return rand()\n end",
"def random_to_one\n return rand()\n end",
"def random_to_one\n return rand()\n end",
"def random_to_one\n return rand()\n en... | [
"0.78279054",
"0.78279054",
"0.75441974",
"0.7326345",
"0.7326345",
"0.7326345",
"0.7326345",
"0.7267854",
"0.716074",
"0.712885",
"0.71130025",
"0.71070814",
"0.707349",
"0.7039445",
"0.7027506",
"0.7020674",
"0.7019629",
"0.70107657",
"0.6999173",
"0.6999173",
"0.6999173",
... | 0.0 | -1 |
put our textures in a line and move them for the demo | def conveyor_belt_y
center_y + center_y / 2 + 20
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sprites_tech_demo\n outputs.labels << [ 5, 170, \"Sprites (x, y, w, h, path, angle, a)\"]\n outputs.sprites << [ 10, 40, 128, 101, 'dragonruby.png']\n outputs.sprites << [ 150, 40, 128, 101, 'dragonruby.png', state.tick_count % 360] # angle changes\n outputs.sprites << [ 300, 40, 128, 101, 'dra... | [
"0.61493033",
"0.60375863",
"0.59905905",
"0.5974331",
"0.5890882",
"0.5806754",
"0.58013374",
"0.573792",
"0.5723799",
"0.5627446",
"0.55931437",
"0.55794793",
"0.5562106",
"0.5561261",
"0.55466783",
"0.5529758",
"0.5524997",
"0.5508639",
"0.5502859",
"0.5476679",
"0.5460872... | 0.0 | -1 |
kuler theme vitamin c 0, 67, 88 blue 31, 138, 112 green 190, 219, 57 lime 255, 255, 26 yellow 253, 116, 0 orange | def blue
Color.new(80, 0, 67, 88)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def theme_keynote\n # Colors\n# @blue = '#6886B4'\n# @yellow = '#FDD84E'\n# @green = '#72AE6E'\n# @red = '#D1695E'\n# @purple = '#8A6EAF'\n# @orange = '#EFAA43'\n# @blue_1 = '#86B468'\n# @yellow_1 = '#D84EFD'\n# @green_1 = '#AE6E72'\n# @red_1 = '#695ED1'\n# @purple_1 = '#6... | [
"0.7381542",
"0.67488563",
"0.6742703",
"0.6713649",
"0.66772413",
"0.66748166",
"0.6630464",
"0.66071796",
"0.65866166",
"0.6582692",
"0.65512216",
"0.65481365",
"0.64555264",
"0.64341515",
"0.6433256",
"0.64250046",
"0.6372795",
"0.6346312",
"0.6345289",
"0.63384163",
"0.63... | 0.0 | -1 |
GET /role_permissions GET /role_permissions.json | def index
@role_permissions = RolePermission.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @permissions = @role.permissions\n end",
"def role_permissions\n return @role_permissions\n end",
"def index\n index_helper\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @role_permissions }\n ... | [
"0.7905877",
"0.7544304",
"0.746048",
"0.73831844",
"0.733874",
"0.73187125",
"0.73051906",
"0.7292113",
"0.7248183",
"0.7146382",
"0.71400607",
"0.7135353",
"0.71282166",
"0.71179444",
"0.71124387",
"0.7088553",
"0.7062083",
"0.7036797",
"0.70311975",
"0.69700336",
"0.696098... | 0.7490713 | 2 |
GET /role_permissions/1 GET /role_permissions/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @permissions = @role.permissions\n end",
"def show\n @role_permission = RolePermission.find(params[:id])\n #authorize! :show, @role_permission\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @role_permission }\n ... | [
"0.78743994",
"0.7417906",
"0.7400819",
"0.7365946",
"0.7365749",
"0.73462176",
"0.72603685",
"0.7228223",
"0.71156067",
"0.71040523",
"0.7083756",
"0.7076414",
"0.7024793",
"0.7008309",
"0.69937366",
"0.69722027",
"0.6940789",
"0.69049615",
"0.68813884",
"0.6838774",
"0.6809... | 0.0 | -1 |
POST /role_permissions POST /role_permissions.json | def create
@role_permission = RolePermission.new(role_permission_params)
respond_to do |format|
if @role_permission.save
format.html { redirect_to @role_permission, notice: 'Role permission was successfully created.' }
format.json { render :show, status: :created, location: @role_permission }
else
format.html { render :new }
format.json { render json: @role_permission.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @role = Role.new(role_params) \n @role.permissions = []\n @role.set_permissions(params[:permissions]) if params[:permissions]\n\n respond_to do |format|\n if @role.save\n format.html { redirect_to @role, notice: 'Role was successfully created.' }\n format.json { render :... | [
"0.7852936",
"0.7502534",
"0.7254272",
"0.72430396",
"0.71401995",
"0.7106022",
"0.7096851",
"0.7094173",
"0.69884014",
"0.68079764",
"0.67391264",
"0.6723992",
"0.6656945",
"0.663575",
"0.6632088",
"0.66257614",
"0.66144454",
"0.6598142",
"0.65332043",
"0.6525639",
"0.650748... | 0.7122269 | 5 |
PATCH/PUT /role_permissions/1 PATCH/PUT /role_permissions/1.json | def update
respond_to do |format|
if @role_permission.update(role_permission_params)
format.html { redirect_to @role_permission, notice: 'Role permission was successfully updated.' }
format.json { render :show, status: :ok, location: @role_permission }
else
format.html { render :edit }
format.json { render json: @role_permission.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @role.permissions = []\n @role.set_permissions(params[:permissions]) if params[:permissions]\n respond_to do |format|\n if @role.update(role_params)\n format.html { redirect_to @role, notice: 'Role was successfully updated.' }\n format.json { render :show, status: :ok, loca... | [
"0.81744426",
"0.8034166",
"0.7848315",
"0.77968335",
"0.7289854",
"0.72796535",
"0.7194642",
"0.71135396",
"0.7068992",
"0.70109946",
"0.7010619",
"0.7010619",
"0.7010619",
"0.7010619",
"0.7010619",
"0.7010619",
"0.7010619",
"0.7010619",
"0.7010619",
"0.7010619",
"0.7010619"... | 0.7437931 | 4 |
DELETE /role_permissions/1 DELETE /role_permissions/1.json | def destroy
@role_permission.destroy
respond_to do |format|
format.html { redirect_to role_permissions_url, notice: 'Role permission was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @roles_and_permission = @roles.roles_and_permission.find(params[:id])\n @roles_and_permission.destroy\n\n respond_to do |format|\n format.html { redirect_to roles_and_permissions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lab_permissions_role = ... | [
"0.7829103",
"0.77497405",
"0.7609267",
"0.72871375",
"0.7160339",
"0.7127967",
"0.7113657",
"0.70617336",
"0.7011175",
"0.69962",
"0.6982307",
"0.6944075",
"0.6943822",
"0.691753",
"0.69158435",
"0.690891",
"0.69029933",
"0.6897984",
"0.6892507",
"0.68684214",
"0.6859807",
... | 0.7711633 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_role_permission
@role_permission = RolePermission.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.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.533008... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def role_permission_params
params.require(:role_permission).permit(:role_id, :permission_id, :hierarchy_id, :hierarchy_type)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
Returns an array of parameter tokens | def extract_params(idx)
params = []
return params if idx[:param_tokens].nil?
e = idx[:param_tokens].each
begin
while (ptok = e.next)
next unless ptok.type == :VARIABLE
params << ptok
nesting = 0
# skip to the next parameter to avoid finding default values of variables
loop do
ptok = e.next
case ptok.type
when :LPAREN, :LBRACK
nesting += 1
when :RPAREN, :RBRACK
nesting -= 1
when :COMMA
break unless nesting.positive?
end
end
end
rescue StopIteration; end # rubocop:disable Lint/SuppressedException
params
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def param_list\n read_next.must_be_identifier!(\"(\")\n if next_token.is_identifier?(\")\")\n ASTList.create\n else\n params\n end.tap do\n read_next.must_be_identifier!(\")\")\n end\n end",
"def param_list\n if @call_seq then\n params = @call_seq.split(\"... | [
"0.7025695",
"0.69731814",
"0.6955403",
"0.68085855",
"0.6805074",
"0.66393584",
"0.6564486",
"0.6461608",
"0.639049",
"0.639049",
"0.639049",
"0.63889414",
"0.63889414",
"0.63889414",
"0.63889414",
"0.63889414",
"0.63889414",
"0.63889414",
"0.63889414",
"0.63795525",
"0.6342... | 0.6708287 | 5 |
Returns array of tokens that cover the value that the parameter token has as its default Search forward to find value assigned to this parameter We want to find the thing after `=` and before `,` | def extract_default_value_tokens(ptok)
value_tokens = []
token = ptok.next_code_token
nesting = 0
while token
case token.type
when :LPAREN, :LBRACK
nesting += 1
when :RBRACK
nesting -= 1
when :RPAREN
nesting -= 1
if nesting.negative?
# This is the RPAREN at the end of the parameters. There wasn't a COMMA
last_token = token.prev_code_token
break
end
when :EQUALS
first_token = token.next_code_token
when :COMMA
unless nesting.positive?
last_token = token.prev_code_token
break
end
end
token = token.next_token
end
value_tokens = tokens[tokens.find_index(first_token)..tokens.find_index(last_token)] if first_token && last_token
value_tokens
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scan_for_commas(token); end",
"def parameters\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 74 )\n return_value = ParametersReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n ... | [
"0.6007873",
"0.58190423",
"0.5797972",
"0.5745399",
"0.5708995",
"0.5708995",
"0.5694716",
"0.5653947",
"0.56236243",
"0.56137717",
"0.5551762",
"0.5526229",
"0.5504136",
"0.54743356",
"0.5433497",
"0.54331636",
"0.5410425",
"0.53768414",
"0.5353954",
"0.5281074",
"0.5262896... | 0.7109807 | 0 |
Returns an array of tokens that cover the data type of the parameter ptok Search backwards until we either bump into a comma (whilst not nested), or reach the opening LPAREN | def extract_type_tokens(ptok)
type_tokens = []
token = ptok.prev_code_token
nesting = 0
while token
case token.type
when :LBRACK
nesting += 1
when :LPAREN
nesting += 1
if nesting.positive?
# This is the LPAREN at the start of the parameter list
first_token = token.next_code_token
last_token = ptok.prev_code_token
break
end
when :RBRACK, :RPAREN
nesting -= 1
when :COMMA
if nesting.zero?
first_token = token.next_code_token
last_token = ptok.prev_code_token
break
end
end
token = token.prev_code_token
end
type_tokens = tokens[tokens.find_index(first_token)..tokens.find_index(last_token)] if first_token && last_token
type_tokens
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_multiple_values\n next_token if peek_token == :lparen #skip :lparen\n value = []\n value << current_token if String === next_token until peek_token.nil? || peek_token == :rparen\n next_token if peek_token == :rparen # consume the :rparen\n value.join(',')\n end",
"def extract_default_... | [
"0.66376424",
"0.6580629",
"0.6500217",
"0.63559425",
"0.61661",
"0.6093485",
"0.60577714",
"0.6030269",
"0.59247357",
"0.5919154",
"0.5918971",
"0.5834444",
"0.5763134",
"0.57408804",
"0.5736345",
"0.56850344",
"0.56667316",
"0.56598485",
"0.5652574",
"0.5630184",
"0.5615968... | 0.79251134 | 0 |
need to slice all 'consonants' until we see a vowel put the consonants in the back of the word | def translate(phrase)
#split phrase into words
word_array = phrase.split ' '
#to_pig each word
answer_array = word_array.map {|word| to_pig(word)}
#join words back together
answer = answer_array.join ' '
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consonant_cancel(sentence)\n vowel = \"aeiou\"\n new_arr = []\n sentence.split(\" \").each do |word|\n word.each_char.with_index do |char, i|\n if vowel.include?(char)\n new_word = word[i..-1]\n new_arr << new_word\n break\n end... | [
"0.7740106",
"0.7559508",
"0.7298511",
"0.72851765",
"0.72481126",
"0.7236133",
"0.7235147",
"0.71451503",
"0.70983225",
"0.7075094",
"0.7036107",
"0.7001227",
"0.69713634",
"0.6934594",
"0.69040334",
"0.68526834",
"0.68111396",
"0.6802874",
"0.6777801",
"0.67281926",
"0.6724... | 0.0 | -1 |
get location display string for infowindow | def get_title_description()
if !self.building_number.nil?
if self.title.include? self.building_number
return "Building " + self.building_number
else
return "Building " + self.building_number + "- " + self.title
end
else
return self.title
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gmaps4rails_infowindow\n \"<div class='location-infobox'> <a href=/locations/#{location.id}>#{name}</a> <p>Date visited: #{first_date.to_s}</p> <p>Located: #{states}</p> </div>\"\n end",
"def gmaps4rails_infowindow\n \"<h1>#{name}</h1><br>Latitude: #{latitude} Longitude: #{longitude}\"\n end",
"def... | [
"0.77931225",
"0.7434446",
"0.70734817",
"0.70160294",
"0.6988533",
"0.6876871",
"0.6782313",
"0.67746544",
"0.67471105",
"0.67471105",
"0.67471105",
"0.67471105",
"0.6676378",
"0.6648519",
"0.66036433",
"0.659076",
"0.6589225",
"0.65853107",
"0.65673053",
"0.65673053",
"0.65... | 0.0 | -1 |
returns true if this location has no more offerings | def isEmpty?
return self.offerings.count == 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_more?\n return false unless @eligibles.empty?\n NO_MORE\n end",
"def has_onsite_holdings?\n return false unless self[:location_facet].present?\n\n # consider each location for this record....\n self[:location_facet].each do |location_facet|\n # skip over anything that's offsite..... | [
"0.73762673",
"0.67329735",
"0.66097456",
"0.6604794",
"0.6591897",
"0.6465306",
"0.6453284",
"0.6357941",
"0.63112307",
"0.61815304",
"0.6155567",
"0.613523",
"0.6133661",
"0.61175406",
"0.6083638",
"0.60711193",
"0.60544145",
"0.60544145",
"0.60503423",
"0.60490185",
"0.603... | 0.7491813 | 0 |
Translates a relative coordinate into a real one | def coord(x); (x*@game.height).to_i; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relative_position(x, y)\n Castaway::Point.new(x, y) * production.resolution\n end",
"def relative(xr, yr)\n Position.new(x + xr, y + yr)\n end",
"def trans(coord)\n\treturn [coord[0]+600, -coord[1]+350]\nend",
"def translate(x, y)\n [ x - bounds.x, y - bounds.y ]\n end",
"def relative_c... | [
"0.68393636",
"0.683689",
"0.66858196",
"0.65956646",
"0.6520671",
"0.63886434",
"0.6382348",
"0.63723624",
"0.6366046",
"0.63283783",
"0.62372655",
"0.62296593",
"0.618523",
"0.6112659",
"0.61017495",
"0.60924226",
"0.60902846",
"0.60755956",
"0.60750085",
"0.60594547",
"0.6... | 0.0 | -1 |
Translates a real coordinate into a relative one | def relative(x); x.to_f/@game.height; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relative(xr, yr)\n Position.new(x + xr, y + yr)\n end",
"def relative_position(x, y)\n Castaway::Point.new(x, y) * production.resolution\n end",
"def relative_coordinate(x_change, y_change)\n new_x = x + x_change\n new_y = y + y_change\n\n if in_bounds?(new_x, new_y)\n Coo... | [
"0.69609404",
"0.6803381",
"0.6719552",
"0.6611655",
"0.65168256",
"0.63784885",
"0.63612187",
"0.62970483",
"0.6227307",
"0.6213919",
"0.6183957",
"0.61689305",
"0.61380786",
"0.6110571",
"0.6079533",
"0.6065434",
"0.6040156",
"0.60316646",
"0.59944105",
"0.5973886",
"0.5945... | 0.5592236 | 63 |
Returns element at index. If index is greater than size of array then elements from size to index are filled with extender. | def [](x)
if x >=size
for i in size..x
self[i]=@extender
end
end
super(x)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def at(index)\n \t@array[index]\n end",
"def at( index )\r\n @ary.at(index + @offset)\r\n end",
"def [](index)\n raise ArgumentError, \"index must be < #{size}\" if index >= size\n number[index]\n end",
"def [](i)\n i = i + size if i < 0\n i >= size || i < 0 ? nil : @elements[i]\n e... | [
"0.6966553",
"0.6731727",
"0.67117345",
"0.6696483",
"0.66485125",
"0.65777916",
"0.65613496",
"0.65542305",
"0.65542305",
"0.64502865",
"0.64394116",
"0.6433187",
"0.6425451",
"0.64229184",
"0.6405252",
"0.63360935",
"0.6311753",
"0.62470424",
"0.6196959",
"0.61914635",
"0.6... | 0.64432234 | 10 |
Sets the element at index. If index is greater than size of array then elements from size to index are filled with extender. | def []=(x,v)
max = size
super(x,v)
if size - max >1
(max..size-2).each do |i|
self[i] = @extender
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set(index, element)\n @array_list.set(index, element)\n end",
"def set(index, element)\n\t\traise OutOfBoundsException if index >=@size\n\t\t@data[index] = element\n\tend",
"def set(index, element)\n\t\traise OutOfBoundsException if index >= @size\n\t\t@data[index] = element\n\tend",
"def set( index ... | [
"0.78111315",
"0.7660529",
"0.7637192",
"0.7404538",
"0.71958965",
"0.71853995",
"0.7008617",
"0.7003086",
"0.69953805",
"0.69635797",
"0.69442767",
"0.6909584",
"0.67130154",
"0.6609288",
"0.6599748",
"0.65412235",
"0.65343094",
"0.6498837",
"0.64581245",
"0.64570606",
"0.64... | 0.6563811 | 15 |
Change a country code to a humanreadable country Eg: AU = Australia | def country_name(country_code)
country = ISO3166::Country[country_code]
country.name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def country_code\n cc = carmen_country\n\n cc ? \"#{cc.code.upcase}\" : nil\n end",
"def country_code_alpha2\n country_code == 'EL' ? 'GR' : country_code\n end",
"def normalize_country\n c = @data_object.add_country.strip\n\n c = c.downcase.gsub(/[\\. ]/, '').sub(/^the/, '')\n \n if ... | [
"0.79442674",
"0.7809843",
"0.77949905",
"0.7592245",
"0.7531377",
"0.74884015",
"0.7444261",
"0.74237597",
"0.7387312",
"0.72821397",
"0.7242137",
"0.7216055",
"0.7196977",
"0.7196977",
"0.71336573",
"0.7094743",
"0.708637",
"0.7041646",
"0.70227927",
"0.7021154",
"0.7018162... | 0.71554726 | 14 |
Yes or no, turns true/false in to yes/no | def yes_or_no(value = false)
value ? "Yes" : "No"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yes_no(bool)\n case bool\n when 1\n \"yes\"\n when 0\n \"no\"\n end\n end",
"def as_yes_or_no(boolean)\n boolean ? 'Yes' : 'No'\n end",
"def yes_or_no(boolean)\n\t if boolean\n\t 'Yes'\n else\n 'No'\n end\n end",
"def yesno(bool)\n return 'N/A' if bool.nil?... | [
"0.8360561",
"0.8320044",
"0.82375777",
"0.80010164",
"0.77325964",
"0.7700007",
"0.7644134",
"0.75712717",
"0.7500385",
"0.747691",
"0.74525595",
"0.7441747",
"0.74324995",
"0.74247384",
"0.7395808",
"0.73370415",
"0.7267556",
"0.726377",
"0.72150713",
"0.72150713",
"0.72034... | 0.79481506 | 4 |
Format share descriptions a bit nicer by converting and to spaces. | def share_description(value)
raw(value).gsub("<br>", " ").gsub("<br />", " ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def share_description(value) \n raw(value).gsub(\"<br>\", \" \").gsub(\"<br />\", \" \")\n end",
"def format_description description\n \"#{description}\".ljust(30)\n end",
"def format_title_description\n if description.present? && title.present?\n self.description = description.strip.capita... | [
"0.6643694",
"0.6355451",
"0.6085365",
"0.60843813",
"0.60843813",
"0.6040165",
"0.60256976",
"0.6025095",
"0.5960897",
"0.58909446",
"0.5823",
"0.58066446",
"0.5805102",
"0.57892996",
"0.57788354",
"0.5769854",
"0.570135",
"0.56535614",
"0.56459296",
"0.56459296",
"0.5631979... | 0.6755102 | 0 |
Link helper takes a URL and outputs a link with a custom label with http and www stripped out | def link_helper(url)
# set up another variable for the link
link = url
# add http if missing from url
if !url.include?("http://") && !url.include?("https://")
url = "http://" + url
end
# strip out http/https from link
if link.include?("http://") || link.include?("https://")
link = link.split("://")[1]
end
# strip out the www from the link
link = link.split("www.")[1] if link.include?("www.")
# remove trailing slash
link = link[0..(link.length - 2)] if link[link.length - 1].eql?("/")
# return a link_to with the final link and url
link_to(link, url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_to (label, url)\n \"<a href='#{url}'>#{label}</a>\"\n end",
"def link\n Html::Link.new(:href => url) << display_name\n end",
"def external_link(label, path, **opt, &block)\n opt[:target] = '_blank' unless opt.key?(:target)\n make_link(label, path, **opt, &block)\n end",
"def build... | [
"0.74292344",
"0.69627106",
"0.68916947",
"0.6874132",
"0.6842955",
"0.6818617",
"0.68048346",
"0.67558837",
"0.66976136",
"0.66417",
"0.66417",
"0.66399485",
"0.66192704",
"0.6571805",
"0.65665644",
"0.6544465",
"0.6539952",
"0.65295047",
"0.65069044",
"0.6494934",
"0.649424... | 0.7181887 | 1 |
SVG Image Helper Converts a dragonflystored SVG image to inline SVG with a missing asset fallback. | def svg_image(image)
raw image.data
rescue Dragonfly::Job::Fetch::NotFound
"Image missing"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inline_svg(path)\n file = File.open(\"public/images/#{path}\", \"rb\")\n file.read\n end",
"def image file, opts = {}\n # FIXME handle case when SVG is a File or IO object\n if ::String === file && (file.downcase.end_with? '.svg')\n opts[:fallback_font_name] ||= default_svg_font if respond_... | [
"0.6976713",
"0.69373757",
"0.6889673",
"0.6708993",
"0.6666454",
"0.6664146",
"0.66472864",
"0.66189384",
"0.6558477",
"0.62838167",
"0.626389",
"0.6240496",
"0.61302423",
"0.61154705",
"0.61154705",
"0.60168093",
"0.59429413",
"0.5888581",
"0.58310914",
"0.5781527",
"0.5745... | 0.75487447 | 0 |
def self.locate_iss location = HTTParty.get(' end def self.update_iss_location location = HTTParty.get(' iss = Spacecraft.find_or_create_by(name: 'ISS') iss.update(lat:location['iss_position']['latitude'], long: location['iss_position']['latitude']) end | def check_spacepeople
astros = HTTParty.get('http://api.open-notify.org/astros.json')
if astros
#remove previous spacepeople
self.spacepeople.destroy_all
#create spacepeople
astros['people'].each do |astro|
if astro['craft'] == self.apiname
Spaceperson.create(spacecraft_id:self.id,name:astro['name'])
end
end
#update crew integer
self.crew = astros['number'].to_i
self.save
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_location\n location = flickr.places.findByLatLon(lat: lat, lon: lon)\n location.size >= 1 ? @location = location.first['name'] : @location = \"Unidentifiable location\"\n end",
"def location\n fetch('sword_art_online.location')\n end",
"def locationLookup(currLoc) \n client = ... | [
"0.6029923",
"0.60228974",
"0.6001954",
"0.58900857",
"0.58715767",
"0.58423007",
"0.58423007",
"0.58287287",
"0.5827817",
"0.5827817",
"0.5827817",
"0.58257616",
"0.58185494",
"0.58185494",
"0.58185494",
"0.58185494",
"0.58185494",
"0.58185494",
"0.58185494",
"0.58185494",
"... | 0.0 | -1 |
Note if we wanted then we can get bytes read and bytes written by process from looking at the /proc/xxx/stat etc Get OS paramter in terms of process id | def param_from_pid( param )
tuples = {}
`ps -eo pid,#{param}`.split("\n").each_with_index() do |row, index|
next unless index > 0
cols = row.split(' ')
tuples[cols[0]] = cols[1]
end
tuples
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_proc_used_mem\n #pid, size = `ps ax -o pid,rss | grep -E \"^[[:space:]]*#{$$}\"`.strip.split.map(&:to_i)\n #`ps -o rss -p #{$$}`.chomp.split(\"\\n\").last.to_i\n #`ps -o rss -p #{$$}`.strip.split.last.to_i * 1024\n `ps -o rss= -p #{Process.pid}`.to_i \nend",
"def get_process_memory(pid)\n... | [
"0.6906598",
"0.6768117",
"0.65414405",
"0.63869137",
"0.6370739",
"0.635648",
"0.63547426",
"0.62939173",
"0.6222233",
"0.6195584",
"0.6146317",
"0.61278117",
"0.61239326",
"0.6122102",
"0.6067677",
"0.6046345",
"0.6046345",
"0.602877",
"0.6022213",
"0.5993502",
"0.59912866"... | 0.5928532 | 28 |
GET /posts GET /posts.json | def index
@posts = Post.all.paginate(page: params[:page], per_page: 10).order('created_at DESC')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n ... | [
"0.7865315",
"0.7494904",
"0.7494433",
"0.7494433",
"0.7488696",
"0.74314564",
"0.728645",
"0.728645",
"0.728645",
"0.72562826",
"0.72522277",
"0.7247287",
"0.7246305",
"0.72221965",
"0.72042215",
"0.72039723",
"0.7169929",
"0.71689725",
"0.71644753",
"0.7121855",
"0.71152896... | 0.0 | -1 |
GET /posts/1 GET /posts/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def show\n render json: Post.find(params[\"id\"])\n end",
"def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end",
"def show\n @post = Post.find(params[:id])\n\n render json: @post\n end",
... | [
"0.7710844",
"0.7353502",
"0.73427415",
"0.7337394",
"0.7322748",
"0.7292442",
"0.72757447",
"0.72560185",
"0.71621436",
"0.71594524",
"0.71558005",
"0.71558005",
"0.7119999",
"0.70952386",
"0.70952386",
"0.70952386",
"0.70939225",
"0.7072017",
"0.7061268",
"0.70457697",
"0.7... | 0.0 | -1 |
POST /posts POST /posts.json | def create
@post = Post.new(post_params)
respond_to do |format|
if @post.save
format.html { redirect_to @post, notice: "Post was successfully created. #{make_undo_link}" }
format.json { render :show, status: :created, location: @post }
else
format.html { render :new }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n render json: Post.create(params[\"post\"])\n end",
"def create\n respond_with Post.create(params[:posts])\n end",
"def create\n @post = Post.create(post_params)\n render json: @post, serializer: PostSerializer\n end",
"def create\n @post = Post.new(post_params)\n @po... | [
"0.74469984",
"0.7322041",
"0.7307387",
"0.7123827",
"0.70159745",
"0.70137525",
"0.6984378",
"0.69397914",
"0.69314337",
"0.6905685",
"0.6818554",
"0.6812814",
"0.67935044",
"0.67930967",
"0.6778908",
"0.6778908",
"0.676283",
"0.67605776",
"0.67513967",
"0.6735167",
"0.66988... | 0.0 | -1 |
PATCH/PUT /posts/1 PATCH/PUT /posts/1.json | def update
respond_to do |format|
if @post.update(post_params)
format.html { redirect_to @post, notice: "Post was successfully updated. #{make_undo_link}" }
format.json { render :show, status: :ok, location: @post }
else
format.html { render :edit }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end",
"def update\n respond_with Post.update(params[:id], params[:posts])\n end",
"def update\n @post = Post.find(params[:id])\n respond_to do |format|\n if @post.update_attributes(params[:post])\n forma... | [
"0.7186309",
"0.7040826",
"0.67726034",
"0.6765877",
"0.6668908",
"0.6647892",
"0.6577694",
"0.6555246",
"0.65498155",
"0.6549577",
"0.6534143",
"0.65298116",
"0.64983106",
"0.6496966",
"0.64672637",
"0.6430547",
"0.6427938",
"0.64262456",
"0.6425561",
"0.6418947",
"0.6418713... | 0.0 | -1 |
DELETE /posts/1 DELETE /posts/1.json | def destroy
@post.destroy
respond_to do |format|
format.html { redirect_to posts_url, notice: "Post was successfully destroyed. #{make_undo_link}" }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n post = Post.find(params[:id])\n if post.destroy\n render json: {status: \"success\", data: {id: param... | [
"0.8046884",
"0.76902676",
"0.7583626",
"0.75803024",
"0.7568048",
"0.75047046",
"0.75031126",
"0.74750155",
"0.74671036",
"0.74650854",
"0.746482",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_post
@post = Post.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.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.533008... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def post_params
params.require(:post).permit(:title, :body)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
GetFile is a lib task | def get_the_individual_file_to_be_processed
# p "individual file selection"
files = GetFiles.get_all_of_the_filenames(@project.freecen_files_directory, @project.file_range)
files
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_utils; end",
"def cl_request(fn, *_)\n get_file fn\n # No other action required\n end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; ... | [
"0.67055136",
"0.6650713",
"0.6587971",
"0.6587971",
"0.6587971",
"0.6587971",
"0.6587971",
"0.6587971",
"0.6587971",
"0.6587971",
"0.6587971",
"0.6587971",
"0.6587971",
"0.65311325",
"0.6515225",
"0.6434485",
"0.63988495",
"0.63988495",
"0.63809806",
"0.6370115",
"0.6342625"... | 0.0 | -1 |
This extracts the header and entry information from the file and adds it to the database | def extract_the_data(skip)
skip = skip
success = true
data_lines = 0
data_records = []
@array_of_lines.each_with_index do |line, n|
next if n < skip
@project.write_messages_to_all("Warning: line #{n} is empty.<br>", true) if line[0..24].all?(&:blank?)
next if line[0..24].all?(&:blank?)
@record = CsvRecord.new(line, @csvfile, @project)
success, message, result = @record.extract_data_line(n)
if result[:birth_place_flag].present? || result[:deleted_flag].present? || result[:individual_flag].present? || result[:location_flag].present? ||
result[:name_flag].present? || result[:occupation_flag].present? || result[:address_flag].present? || result[:deleted_flag].present?
result[:flag] = true
else
result[:flag] = false
end
result[:record_valid] = 'true' unless result[:error_messages].present? || result[:warning_messages].present? || result[:flag]
data_records << result
@csvfile.total_errors = @csvfile.total_errors + 1 if result[:error_messages].present?
@csvfile.total_warnings = @csvfile.total_warnings + 1 if result[:warning_messages].present?
@csvfile.total_info = @csvfile.total_info + 1 if result[:info_messages].present?
@project.write_messages_to_all(message, true) unless success
success = true
data_lines = data_lines + 1
end
[success, data_lines, data_records]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_file(src, dest)\n create_table(dest)\n\n puts \"***** Importing #{dest}\"\n\n count = 0\n# names = File.foreach(src).collect do |line|\n names = open(src).collect do |line| \n count += 1\n if count % 2000 == 0\n puts count\n end\n\n dat... | [
"0.6136084",
"0.5975705",
"0.59674114",
"0.59189665",
"0.5797993",
"0.5744685",
"0.5741313",
"0.5722444",
"0.5715248",
"0.56792694",
"0.5661171",
"0.55863667",
"0.55834824",
"0.5569017",
"0.5527201",
"0.55188465",
"0.5503522",
"0.55035114",
"0.55014515",
"0.5498595",
"0.54931... | 0.0 | -1 |
Find a way to accumulate the :worldwide_grosses and return that Integer using director_data as input | def gross_for_director(director_data)
index = 0
total = 0
while index < director_data[:movies].length do
total+=director_data[:movies][index][:worldwide_gross]
index+=1
end
total
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gross_for_director(director_data)\n movie_index = 0\n worldwide_grosses = 0\n while movie_index < director_data[:movies].length\n worldwide_grosses += director_data[:movies][movie_index][:worldwide_gross]\n movie_index += 1\n end\nworldwide_grosses\nend",
"def gross_for_director(director_data)\n s... | [
"0.8030293",
"0.7978247",
"0.7977822",
"0.7925302",
"0.789238",
"0.7839118",
"0.7754274",
"0.775082",
"0.77156013",
"0.7669104",
"0.7668819",
"0.7653319",
"0.7607447",
"0.7601318",
"0.7600932",
"0.7586774",
"0.75804365",
"0.7576979",
"0.7556352",
"0.75259334",
"0.75167644",
... | 0.7936656 | 3 |
Parses the user input. | def parse(data)
input = Descriptor.new(data)
result = case
when input.empty?
@synchronizer.fetch
when input.params?
find_or_fetch_by_params(input.data)
when input.remote_id?
@synchronizer.find(data)
when input.local_id?
find_by_local_id(data)
when input.array_of_ids?
find_by_array_of_ids(input)
else
result = data.dup
end
[result].flatten.compact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_input\n print \">> \"\n input = gets.chomp\n begin\n parse_user_input(input)\n rescue StandardError\n invalid_command\n end\n end",
"def parse_input(input)\n\tinput.split(\" \")\nend",
"def parse_input \n \t\tformat_input\n\n \t\tp \"Input is #{@input_params}\"\n ... | [
"0.71648514",
"0.7058947",
"0.67822915",
"0.6722172",
"0.6691221",
"0.6683566",
"0.6649619",
"0.66485393",
"0.6561567",
"0.65061444",
"0.65022105",
"0.64279926",
"0.6419001",
"0.63971895",
"0.6393312",
"0.63820463",
"0.6366957",
"0.635749",
"0.634433",
"0.6335955",
"0.6335294... | 0.0 | -1 |
VO is immutable. Here is a setter method to return a new value object | def ==(other_debt_portfolio_position)
self.class == other_debt_portfolio_position.class &&
debt_positions == other_debt_portfolio_position.debt_positions &&
creditor_id == other_debt_portfolio_position.creditor_id &&
creditor_name == other_debt_portfolio_position.creditor_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def [](value) \r\n obj = clone\r\n obj.instance_variable_set(:@value, value)\r\n obj.freeze_without_memoizable \r\n obj\r\n end",
"def set(object, value); end",
"def value=(v)\n set(v)\n end",
"def assign(obj)\n @value = obj\n end",
"def value... | [
"0.7021836",
"0.70031625",
"0.6977304",
"0.6952841",
"0.6867461",
"0.68251985",
"0.68251985",
"0.665002",
"0.6610498",
"0.65815234",
"0.6515533",
"0.64989656",
"0.64555174",
"0.6432056",
"0.6368276",
"0.6366005",
"0.63383156",
"0.632852",
"0.63054854",
"0.6270775",
"0.6262346... | 0.0 | -1 |
hash method required to honour equals contract | def hash
[@creditor_id, @creditor_name, @debt_positions].hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash(*) end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash_code; end",
"def hash() source.hash ^ (target.hash+1); end",
"def hash() source.hash ^ (target.hash+1); end",
"def hash()\n #This is... | [
"0.8078165",
"0.8056436",
"0.8056436",
"0.8056436",
"0.8056436",
"0.8056436",
"0.8056436",
"0.8056436",
"0.7682853",
"0.74962723",
"0.74962723",
"0.74792016",
"0.7375365",
"0.7375365",
"0.7375365",
"0.7375365",
"0.7375365",
"0.7375365",
"0.7375365",
"0.7375365",
"0.7375365",
... | 0.0 | -1 |
GET /feelings/1 GET /feelings/1.json | def show
@feeling = Feeling.find(params[:id])
@sake = Sake.find(params[:sake_id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @feeling }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_feeling\n @feeling = Feeling.find(params[:id])\n end",
"def index\n @feelings = Feeling.where(user: current_user).all\n end",
"def find_feeling(user)\n self.feelings.where( user_id: user.id ).first\n end",
"def new\n @sake= Sake.find(params[:sake_id])\n @feeling = Feeling.new\n ... | [
"0.6516207",
"0.64383405",
"0.63671356",
"0.6219716",
"0.59933156",
"0.59692436",
"0.59370697",
"0.5857662",
"0.5825682",
"0.57739466",
"0.5749843",
"0.57436013",
"0.57394665",
"0.5708842",
"0.5706743",
"0.56900954",
"0.56874657",
"0.5677101",
"0.56712615",
"0.56625116",
"0.5... | 0.6761551 | 0 |
GET /feelings/new GET /feelings/new.json | def new
@sake= Sake.find(params[:sake_id])
@feeling = Feeling.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @feeling }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @feeling = Feeling.new(feeling_params)\n\n respond_to do |format|\n if @feeling.save\n format.html { redirect_to new_feeling_path }\n #format.js\n format.json { render :show, status: :created, location: @feeling }\n else\n format.html { render :new }\n ... | [
"0.69000375",
"0.689388",
"0.686288",
"0.68234533",
"0.6801308",
"0.67607284",
"0.67200273",
"0.671727",
"0.66915035",
"0.66681135",
"0.66681135",
"0.6653322",
"0.6639211",
"0.66371816",
"0.66341233",
"0.65769696",
"0.6576178",
"0.65605223",
"0.65164644",
"0.6514515",
"0.6512... | 0.7440437 | 0 |
POST /feelings POST /feelings.json | def create
@sake= Sake.find(params[:sake_id])
@feeling = Feeling.new(params[:feeling])
@feeling.sake_id = params[:sake_id]
@feeling.member_id = current_member.id
p @feeling.to_s
p "tetetetetete"
respond_to do |format|
if @feeling.save
# format.html { redirect_to @feeling, notice: 'Feeling was successfully created.' }
format.html { redirect_to (sake_path(@sake))}
format.json { render json: @feeling, status: :created, location: @feeling }
else
format.html { render action: "new" }
format.json { render json: @feeling.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @survey = Survey.find(params[:survey_id])\n emoji = params[:emoji]\n mood = params[:mood]\n @feeling = Feeling.new(mood: mood, emoji: emoji)\n @survey.feelings << @feeling\n\n if @feeling.save\n render :ok, json: @feeling\n else\n @errors = @feelings.error.full_messages... | [
"0.67593867",
"0.6597652",
"0.62334234",
"0.6068047",
"0.59607345",
"0.59429276",
"0.59033436",
"0.5790278",
"0.5701767",
"0.5436488",
"0.54179907",
"0.5405718",
"0.54017603",
"0.5370631",
"0.5346274",
"0.53166443",
"0.5291314",
"0.52852315",
"0.5277501",
"0.52619827",
"0.526... | 0.5887462 | 7 |
PUT /feelings/1 PUT /feelings/1.json | def update
@feeling = Feeling.find(params[:id])
respond_to do |format|
if @feeling.update_attributes(params[:feeling])
format.html { redirect_to @feeling, notice: 'Feeling was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @feeling.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_feeling\n @feeling = Feeling.find(params[:id])\n end",
"def update\n puts \"update #{@feeling.as_json} #{updated_params.as_json}\"\n respond_to do |format|\n if @feeling.update(updated_params)\n puts \"brucep update success\"\n #format.html { redirect_to @feeling, notice:... | [
"0.6885447",
"0.6589147",
"0.62522805",
"0.612598",
"0.6112526",
"0.6074186",
"0.60537636",
"0.60494673",
"0.6044397",
"0.60422385",
"0.6028454",
"0.59988153",
"0.5990904",
"0.59555966",
"0.5932589",
"0.592771",
"0.59120136",
"0.58992726",
"0.5899209",
"0.58894825",
"0.588246... | 0.7325833 | 0 |
DELETE /feelings/1 DELETE /feelings/1.json | def destroy
@feeling = Feeling.find(params[:id])
@feeling.destroy
respond_to do |format|
format.html { redirect_to feelings_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @feeling = Feeling.find(params[:id])\n @feeling.destroy\n render :ok, json: { feeling: @feeling }\n end",
"def destroy\n @feeling.destroy\n respond_to do |format|\n format.html { redirect_to feelings_url, notice: 'Feeling was successfully destroyed.' }\n format.json { head... | [
"0.75347584",
"0.7383757",
"0.6595079",
"0.65502685",
"0.65330356",
"0.64812326",
"0.6477097",
"0.6459164",
"0.6458657",
"0.6448738",
"0.64453256",
"0.6416836",
"0.636335",
"0.6354889",
"0.6345786",
"0.6336549",
"0.6336549",
"0.6334268",
"0.6329851",
"0.6329404",
"0.6311851",... | 0.76134413 | 0 |
execute this script by using the url " | def random_expand_zone
@user = User.find_by_name(get_random_user_name)
if @user == nil
redirect_to( :controller => "users", :action => "index" )
else
@result = ScalabilityTest.random_expand_or_attack(@user.id, :MODE_EXPAND)
flash[:notice] = @result
redirect_to( :controller => "zones", :action => "index" )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exec loc, script, params = {}\n params.merge! :script => script, :loc => loc\n http :post, \"/exec\", params\n end",
"def script\n # escape command parameter\n params[:command] = params[:command].gsub('..', '').gsub(';', '');\n\n ret = @uri.script(params[:command].split(',')[0], p... | [
"0.6602629",
"0.64787155",
"0.6315788",
"0.6217141",
"0.62066674",
"0.62066674",
"0.6182121",
"0.6182121",
"0.608962",
"0.5983742",
"0.596497",
"0.58386564",
"0.5798183",
"0.5786304",
"0.5779729",
"0.5773019",
"0.5756665",
"0.5747272",
"0.5733928",
"0.56829095",
"0.5661902",
... | 0.0 | -1 |
execute this script by using the url " | def random_attack_zone
@user = User.find_by_name(get_random_user_name)
if @user == nil
redirect_to( :controller => "users", :action => "index" )
else
@result = ScalabilityTest.random_expand_or_attack(@user.id, :MODE_ATTACK)
if @result != true
flash[:notice] = @result
end
redirect_to( :controller => "zones", :action => "index" )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exec loc, script, params = {}\n params.merge! :script => script, :loc => loc\n http :post, \"/exec\", params\n end",
"def script\n # escape command parameter\n params[:command] = params[:command].gsub('..', '').gsub(';', '');\n\n ret = @uri.script(params[:command].split(',')[0], p... | [
"0.6601394",
"0.6477018",
"0.6313268",
"0.62140787",
"0.6207827",
"0.6207827",
"0.61791366",
"0.61791366",
"0.60919094",
"0.5984265",
"0.5966487",
"0.5835891",
"0.579875",
"0.578373",
"0.5777577",
"0.5775059",
"0.5757025",
"0.5745799",
"0.5731728",
"0.568103",
"0.5661622",
... | 0.0 | -1 |
execute this script by using the url " | def random_expand_or_attack
@user = User.find_by_name(get_random_user_name)
if @user == nil
redirect_to( :controller => "users", :action => "index" )
else
@result = ScalabilityTest.random_expand_or_attack(@user.id, :MODE_EXPAND_ATTACK)
if @result != true
flash[:notice] = @result
end
redirect_to( :controller => "zones", :action => "index" )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exec loc, script, params = {}\n params.merge! :script => script, :loc => loc\n http :post, \"/exec\", params\n end",
"def script\n # escape command parameter\n params[:command] = params[:command].gsub('..', '').gsub(';', '');\n\n ret = @uri.script(params[:command].split(',')[0], p... | [
"0.6601394",
"0.6477018",
"0.6313268",
"0.62140787",
"0.6207827",
"0.6207827",
"0.61791366",
"0.61791366",
"0.60919094",
"0.5984265",
"0.5966487",
"0.5835891",
"0.579875",
"0.578373",
"0.5777577",
"0.5775059",
"0.5757025",
"0.5745799",
"0.5731728",
"0.568103",
"0.5661622",
... | 0.0 | -1 |
execute this script by using the url " | def random_view
if GameController::USE_MEMCACHED
xprev = Cache.get("scalability_test_random_view_x")
yprev = Cache.get("scalability_test_random_view_y")
if (xprev != nil && yprev != nil)
xpos = xprev
ypos = yprev
else
xpos = (rand() * 100 + ScalabilityTest::TEST_NEWUSER_STARTX).to_i
ypos = (rand() * 100 + ScalabilityTest::TEST_NEWUSER_STARTY).to_i
Cache.put("scalability_test_random_view_x", xpos, 30)
Cache.put("scalability_test_random_view_y", ypos, 30)
end
else
xpos = (rand() * 100 + ScalabilityTest::TEST_NEWUSER_STARTX).to_i
ypos = (rand() * 100 + ScalabilityTest::TEST_NEWUSER_STARTY).to_i
end
if GameController::USE_MEMCACHED
if Zone.MEMCACHED_ViewportSame(xpos, xpos + ScalabilityTest::VIEW_W, ypos, ypos + ScalabilityTest::VIEW_H)
@zonedata_str = Zone.MEMCACHED_LoadZoneXML
else
@zonedata = Zone.find_zones_in_view_xml(xpos, xpos + ScalabilityTest::VIEW_W, ypos, ypos + ScalabilityTest::VIEW_H)
@zonedata_str = Zone.MEMCACHED_SaveZoneXML(xpos, xpos + ScalabilityTest::VIEW_W, ypos, ypos + ScalabilityTest::VIEW_H, @zonedata)
end
else
@zonedata = Zone.find_zones_in_view_xml(xpos, xpos + ScalabilityTest::VIEW_W, ypos, ypos + ScalabilityTest::VIEW_H)
end
#cache will be effective for 30 seconds
respond_to do |format|
format.xml { render :layout => false}
end
# redirect_to( :controller => "users", :action => "index" )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exec loc, script, params = {}\n params.merge! :script => script, :loc => loc\n http :post, \"/exec\", params\n end",
"def script\n # escape command parameter\n params[:command] = params[:command].gsub('..', '').gsub(';', '');\n\n ret = @uri.script(params[:command].split(',')[0], p... | [
"0.66025037",
"0.6477993",
"0.63171273",
"0.62181985",
"0.6205764",
"0.6205764",
"0.61818856",
"0.61818856",
"0.6088451",
"0.5982234",
"0.59651244",
"0.5839875",
"0.5797022",
"0.5786959",
"0.57803434",
"0.577235",
"0.5756304",
"0.5748083",
"0.57353514",
"0.5684458",
"0.566189... | 0.0 | -1 |
execute this script by using the url " | def random_operation
@user = User.find_by_id( session[:user_id] )
if @user == nil
redirect_to( :controller => "users", :action => "index" )
else
if (@user.avg_soldiers_per_zone < 1)
#UserZone.train_soldiers(@user.id, GameRules::TURNS_PER_TRAINING)
else
@result = ScalabilityTest.random_expand_or_attack(@user.id, :MODE_EXPAND_ATTACK)
if @result != true
flash[:notice] = @result
end
end
redirect_to( :controller => "zones", :action => "index" )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exec loc, script, params = {}\n params.merge! :script => script, :loc => loc\n http :post, \"/exec\", params\n end",
"def script\n # escape command parameter\n params[:command] = params[:command].gsub('..', '').gsub(';', '');\n\n ret = @uri.script(params[:command].split(',')[0], p... | [
"0.6602629",
"0.64787155",
"0.6315788",
"0.6217141",
"0.62066674",
"0.62066674",
"0.6182121",
"0.6182121",
"0.608962",
"0.5983742",
"0.596497",
"0.58386564",
"0.5798183",
"0.5786304",
"0.5779729",
"0.5773019",
"0.5756665",
"0.5747272",
"0.5733928",
"0.56829095",
"0.5661902",
... | 0.0 | -1 |
execute tthis script by using the url " | def random_login
if random_login_internal
redirect_to( :controller => "users", :action => "info" )
else
redirect_to( :controller => "users", :action => "index" )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exec loc, script, params = {}\n params.merge! :script => script, :loc => loc\n http :post, \"/exec\", params\n end",
"def execute(url_chunk, additional_options = {})\n request = ::Typhoeus::Request.new(\n Addressable::URI.escape(\"#{service_url}/#{url_chunk}\"),\n options[:typho... | [
"0.6489701",
"0.59599537",
"0.5874378",
"0.5874378",
"0.5815341",
"0.5813311",
"0.57710665",
"0.5706828",
"0.5706828",
"0.5659056",
"0.5601633",
"0.55524963",
"0.55498976",
"0.549836",
"0.5450067",
"0.5436006",
"0.54299647",
"0.5401356",
"0.54008293",
"0.5392405",
"0.53913945... | 0.0 | -1 |
execute this script by using the url " | def create_10000_random_zone_records()
for time in (1..100)
random_login_internal
for i in (1..100)
@user = User.find_by_id( session[:user_id] )
if @user == nil
redirect_to( :controller => "users", :action => "index" )
else
if (@user.avg_soldiers_per_zone < 1)
# UserZone.train_soldiers(@user.id, GameRules::TURNS_PER_TRAINING)
else
@result = ScalabilityTest.random_expand_or_attack(@user.id, :MODE_EXPAND_ATTACK)
if @result != true
flash[:notice] = @result
end
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exec loc, script, params = {}\n params.merge! :script => script, :loc => loc\n http :post, \"/exec\", params\n end",
"def script\n # escape command parameter\n params[:command] = params[:command].gsub('..', '').gsub(';', '');\n\n ret = @uri.script(params[:command].split(',')[0], p... | [
"0.6601394",
"0.6477018",
"0.6313268",
"0.62140787",
"0.6207827",
"0.6207827",
"0.61791366",
"0.61791366",
"0.60919094",
"0.5984265",
"0.5966487",
"0.5835891",
"0.579875",
"0.578373",
"0.5777577",
"0.5775059",
"0.5757025",
"0.5745799",
"0.5731728",
"0.568103",
"0.5661622",
... | 0.0 | -1 |
instance: Post or User | def no_link_picture(instance)
if instance.picture.present?
image_tag(instance.picture.image.url, class: 'img-responsive')
elsif instance.class == User
image_tag('/images/default.png', class: 'img-responsive')
else
image_tag('/images/default2.jpg', class: 'img-responsive')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_post_and_user\n @post = Post.find(params[:id])\n @user = @post.user\n end",
"def posts\n @user = User.find(params[:id])\n end",
"def show\n @user = User.find(@post.user_id)\n end",
"def post_user\n place = self.place\n place.user\n end",
"def set_post\n @post = Post... | [
"0.7034812",
"0.67661947",
"0.6716437",
"0.66680026",
"0.6645234",
"0.6625824",
"0.6603691",
"0.6595365",
"0.6553536",
"0.6505671",
"0.6497176",
"0.64470124",
"0.64018506",
"0.63721555",
"0.637033",
"0.63123876",
"0.63058937",
"0.62761784",
"0.6275205",
"0.62611544",
"0.62242... | 0.0 | -1 |
Collection of all existing adapters | def adapters
Ribbit::Adapters.adapters
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adapters\n @adapters ||= {}\n end",
"def adapters\n @adapters ||= {}\n end",
"def adapters\n @__adapters__ ||= {}\n end",
"def adapters\n adapters_by_type.values.flatten\n end",
"def adaptors\n @adaptors ||= []\n end",
"def each_adapter\n ret... | [
"0.8323311",
"0.8265546",
"0.8175799",
"0.7955741",
"0.74720234",
"0.74542874",
"0.73759955",
"0.7338438",
"0.7284318",
"0.7232815",
"0.69850993",
"0.68754315",
"0.6808092",
"0.67782295",
"0.65089655",
"0.641997",
"0.6357729",
"0.6348418",
"0.61437345",
"0.6136653",
"0.611748... | 0.77416784 | 4 |
Proxy logger onto the adapter | def logger
adapter.logger if adapter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logger\n adapter.logger\n end",
"def logger\n adapter.logger\n end",
"def use_logger(logger)\n adapter.logger = logger\n end",
"def with_logger\n yield\n end",
"def logger\n raise NotImplementedError\n end",
"def log=(logger); end",
"def logger=(logger); end"... | [
"0.763701",
"0.763701",
"0.7351045",
"0.7019354",
"0.6986181",
"0.6950784",
"0.69455206",
"0.69455206",
"0.69070506",
"0.69070506",
"0.69070506",
"0.69070506",
"0.69070506",
"0.68697566",
"0.68667364",
"0.6860585",
"0.68583554",
"0.6857631",
"0.67945534",
"0.6741521",
"0.6741... | 0.7621533 | 2 |
Call this method to modify defaults in your initializers. | def configure(silent = false)
self.configuration ||= Configuration.new
yield(configuration)
self.sender = Sender.new(configuration)
# Attempt to attach an adapter, either by class or name
if adapters.include? configuration.adapter
self.adapter = configuration.adapter.new(configuration)
elsif configuration.adapter
adapter_class = Ribbit::Adapters.load_adapter configuration.adapter
self.adapter = adapter_class.new(configuration) rescue nil
end
self.adapter.activate! if self.adapter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_defaults\n end",
"def set_defaults\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults!\n __load_config( DEFAULTS )\n end",
"de... | [
"0.8400854",
"0.8400854",
"0.83391494",
"0.83391494",
"0.83391494",
"0.83391494",
"0.83391494",
"0.83391494",
"0.82290864",
"0.76817745",
"0.76817745",
"0.76770246",
"0.76770246",
"0.76770246",
"0.76770246",
"0.76770246",
"0.76770246",
"0.76770246",
"0.76770246",
"0.76770246",
... | 0.0 | -1 |
Sends an exception manually using this method, even when you are not in a controller. | def notify(exception, opts = {})
send_notice(build_notice_for(exception, opts))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rails_controller_rescue\n yield\n rescue Exception => exception\n rails_controller_instance.rescue_with_handler(exception) || raise\n\n unless rails_controller_instance.performed?\n raise Rodauth::Rails::Error, \"rescue_from handler didn't write any response\"\n end\n end",
"... | [
"0.6937155",
"0.69290596",
"0.6915478",
"0.66785717",
"0.64892334",
"0.64892334",
"0.6461491",
"0.6461491",
"0.6461491",
"0.6461491",
"0.6455849",
"0.64511526",
"0.6448381",
"0.64462507",
"0.64460176",
"0.64460176",
"0.6437136",
"0.6428754",
"0.64042866",
"0.6399111",
"0.6346... | 0.0 | -1 |
Sends the notice unless it is one of the default ignored exceptions | def notify_or_ignore(exception, opts = {})
notice = build_notice_for(exception, opts)
send_notice(notice) unless notice.ignore?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notice!\n self.severity = :NOTICE\n end",
"def notice; end",
"def notify_or_ignore(exception, context = {})\n notify(exception, context) unless ignored?(exception)\n end",
"def rescue_action_in_public_with_errornot(exception)\n unless errornot_ignore_user_agent?\n ... | [
"0.65168333",
"0.6434321",
"0.640824",
"0.621561",
"0.6197395",
"0.61959904",
"0.6174005",
"0.6072776",
"0.60374594",
"0.5936417",
"0.5936417",
"0.5920188",
"0.59181964",
"0.587393",
"0.5858212",
"0.5795644",
"0.57782435",
"0.57683146",
"0.57156485",
"0.57066834",
"0.5706503"... | 0.72404635 | 0 |
Returns the path that should be used when inserting the saved file into a web page, if the file is stored in the public directory. If it is saved outside the public directory, +nil+ is returned. Remembers the path to saved files in the same way as +full_path+. | def public_path
public_regexp = Regexp.new("^#{RAILS_ROOT}/public")
full_path =~ public_regexp ? full_path.gsub(public_regexp, '') : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path\n return self.saved? ? @realfile.path : nil\n end",
"def full_path\n @full_path ||= path ? File.join(root, path) : root\n end",
"def full_path\n self.read_attribute(:full_path) || self.assign_full_path\n end",
"def full_file_path\n Rails.root.join('uploads', file... | [
"0.7514132",
"0.7460955",
"0.72375244",
"0.7008816",
"0.698824",
"0.6974727",
"0.69676834",
"0.68841445",
"0.6872106",
"0.6816394",
"0.6764531",
"0.676347",
"0.66960204",
"0.66363245",
"0.66237694",
"0.66237694",
"0.661472",
"0.66116416",
"0.66044027",
"0.6592236",
"0.6589502... | 0.5868937 | 94 |
Returns +true+ if there is a saved file upload on the server for the record. Will continue to return +true+ (assuming the file does exist) even if you change the record's filename (see +full_path+ for further details). | def file_exists?
File.file?(full_path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saved?\n return !@realfile.nil?\n end",
"def uploaded?( filename, buffer )\n return false if @upload_dir.nil?\n\n savedfile = \"#{@upload_dir}/#{filename}\"\n return false unless File.exist?( savedfile )\n\n old = File.read( savedfile, encoding: buffer.encoding )\n re... | [
"0.7306589",
"0.71793115",
"0.6998457",
"0.697859",
"0.6914678",
"0.68744737",
"0.6836966",
"0.6771272",
"0.67272085",
"0.6706031",
"0.6674942",
"0.66317785",
"0.6540338",
"0.6505724",
"0.6500729",
"0.64993715",
"0.6482897",
"0.64757866",
"0.64682585",
"0.64680517",
"0.643696... | 0.66961014 | 10 |
Returns the size of the uploaded file in bytes. Returns +nil+ if no file exists. | def filesize
file_exists? ? File.size(full_path) : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size\n file.try(:size) || 0\n end",
"def size\n # return @file.size if @file.respond_to?(:size)\n File.size(self.path) rescue 0\n end",
"def size\n @size ||= File.size(file)\n end",
"def size\n file.content_length\n end",
"def size\n file.size\n ... | [
"0.8352511",
"0.7998247",
"0.77831376",
"0.77427554",
"0.76856",
"0.768396",
"0.76258296",
"0.7605367",
"0.7595493",
"0.7482904",
"0.7394585",
"0.73271537",
"0.73249555",
"0.7291562",
"0.7259073",
"0.7258775",
"0.7258775",
"0.7219015",
"0.72136396",
"0.7148106",
"0.71453327",... | 0.7986197 | 2 |
If there is a file saved on the server for the record, this method sets its permissions using the nix +chmod+ command. +permissions+ should be an octalformat integer. The default setting when saving files is 0644. | def chmod(permissions = nil)
permissions ||= self.class.upload_options[:chmod]
File.chmod(permissions, full_path) if file_exists?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_permissions_on_storage\n if @options[:perms]\n response = system(\"chmod -R o+w #{File.join(@path, 'storage')}\")\n if response\n say_success \"Updated permissions on storage/ directory.\"\n else\n say_failed \"Could not update permissions on storage/ director... | [
"0.61778283",
"0.6151694",
"0.6135356",
"0.6115305",
"0.6100644",
"0.6083128",
"0.59712285",
"0.59698904",
"0.59641623",
"0.58579946",
"0.5851635",
"0.5821485",
"0.58096987",
"0.578552",
"0.5781495",
"0.5779447",
"0.5756283",
"0.5678055",
"0.56312793",
"0.5623642",
"0.5612418... | 0.72598076 | 0 |
Returns the full system path (including +RAILS_ROOT+) to the uploaded file, as specified by the record's current attributes. Used by +full_path+ in the event that no file exists. | def full_path_from_current_attributes
path = self.class.upload_options[:directory].
gsub(Regexp.new("^(#{RAILS_ROOT})?/?"), RAILS_ROOT + '/') + '/' +
instance_directory + '/' + send(self.class.upload_options[:filename])
path.gsub(/\/+/, '/')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_file_path\n Rails.root.join('uploads', filepath).to_s\n end",
"def upload_full_path\n @upload_full_path ||= File.join(@upload_file_path, name)\n end",
"def full_path\n @full_path ||= path ? File.join(root, path) : root\n end",
"def full_path\n File.join(@path, @name)\n ... | [
"0.7924824",
"0.7746192",
"0.7309491",
"0.7155678",
"0.7129289",
"0.71280617",
"0.71274024",
"0.7108221",
"0.71034974",
"0.7069348",
"0.7019013",
"0.69260925",
"0.6884028",
"0.6842242",
"0.6799916",
"0.6784461",
"0.67746043",
"0.67746043",
"0.6749577",
"0.6685508",
"0.6606524... | 0.8146056 | 0 |
Returns the subdirectory in which to save the record's file. | def instance_directory
dir = self.class.upload_options[:subdirectory]
dir.nil? ? '' : send(dir).to_s.gsub(/[^a-z0-9_\/\\-]/i, '')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def where_to_save\n output_dir = @template_options[OUTPUT_DIR]\n # assume absolute\n full_path = output_dir\n if (Pathname.new(output_dir)).relative?\n full_path = File.expand_path(output_dir, Dir.pwd)\n end\n return full_path\n end",
"def dir\n calc_dir(@basename)\n e... | [
"0.7135162",
"0.70473164",
"0.69739074",
"0.6963096",
"0.6945805",
"0.6892057",
"0.6891918",
"0.6887564",
"0.6885954",
"0.68631154",
"0.6838524",
"0.6834567",
"0.6834567",
"0.6816714",
"0.6801869",
"0.6791086",
"0.6790537",
"0.6783097",
"0.6739227",
"0.6738241",
"0.6710788",
... | 0.6466741 | 53 |
Renames the uploaded file stored in the filesystem if the record's attribute changes have caused the file's path to change. Only works if the path is a function only of the record's own properties, not of the properties of any associations. Called using the +before_update+ callback in ActiveRecord::Base. | def rename_uploaded_file
return unless @uploaded_file.nil?
if file_exists? and full_path != full_path_from_current_attributes
ensure_directory_exists
File.rename(full_path, full_path_from_current_attributes)
remove_empty_directory
@saved_full_path = full_path_from_current_attributes
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_path\n update_column :path, file.url unless url?\n end",
"def rename_file\n return unless @old_filename && @old_filename != full_filename\n if save_attachment? && File.exists?(@old_filename)\n FileUtils.rm @old_filename\n elsif File.exists?(@old_filename)\n ... | [
"0.64164037",
"0.6395799",
"0.63228154",
"0.6070498",
"0.59627134",
"0.5951",
"0.584486",
"0.5843303",
"0.58145225",
"0.57840216",
"0.5773075",
"0.57341856",
"0.5700501",
"0.5687526",
"0.5684828",
"0.565464",
"0.5646318",
"0.5643698",
"0.5638444",
"0.56376165",
"0.5627437",
... | 0.66050786 | 0 |
Removes the uploaded file from the filesystem when the record is destroyed. | def delete_uploaded_file
return unless file_exists?
File.delete(full_path)
remove_empty_directory
@saved_full_path = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n file&.delete\n end",
"def remove!\n with_callbacks(:remove) do\n delete_file\n @file = nil\n @cache_id = nil\n end\n end",
"def remove_storage_file\n FileUtils.rm(file_path)\n end",
"def destroy_file\n File.delete full_file_... | [
"0.8280413",
"0.78890043",
"0.7848294",
"0.7796873",
"0.7754481",
"0.7726725",
"0.77135676",
"0.7681864",
"0.76635927",
"0.76607996",
"0.76587003",
"0.76528925",
"0.7627879",
"0.76008064",
"0.7595313",
"0.75708073",
"0.7497657",
"0.7457666",
"0.7372867",
"0.7372867",
"0.73067... | 0.7575204 | 15 |
Makes sure that the appropriate directory exists so the file can be saved into it. | def ensure_directory_exists
dir = File.dirname(full_path_from_current_attributes)
FileUtils.mkdir_p(dir) unless File.exists?(dir)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_directory\n FileUtils.mkdir_p(to_s)\n self\n end",
"def ensure_meta_info_dir_exists!\n FileUtils.mkdir_p(RubyFileReader::Reader.meta_info_dir_pathname)\n end",
"def ensureDir(filename)\n dir = File::dirname(filename) ;\n system(\"mkdir -p #{dir}\") ;\n end",
"def ensure... | [
"0.7606959",
"0.7197922",
"0.7135695",
"0.7133732",
"0.7124492",
"0.7109498",
"0.7090023",
"0.699093",
"0.6986757",
"0.6981973",
"0.69757754",
"0.69732857",
"0.69710934",
"0.69115514",
"0.69115514",
"0.68944305",
"0.68728375",
"0.6853175",
"0.683741",
"0.6814181",
"0.6808982"... | 0.772864 | 0 |
Removes the file's directory if it is empty. Recusively deletes directories going up the tree until it reaches a nonempty directory. Thumbs.db and .DS_Store files are removed if they are the only contents of a directory. | def remove_empty_directory(path = nil)
dir = path || File.dirname(full_path)
dir.gsub!(/(\/+\.\.?\/*)*$/, '')
system_files = %w(Thumbs.db .DS_Store)
if File.directory?(dir) and !File.symlink?(dir) and (Dir.entries(dir) - %w(. ..) - system_files).empty?
system_files.each { |sys| File.delete("#{dir}/#{sys}") if File.exists?("#{dir}/#{sys}") }
Dir.rmdir(dir)
remove_empty_directory(dir.gsub(/\/+[^\/]*\/*$/, ''))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_file_and_clean_directories( path )\n # first, delete the file\n delete_file( path )\n # recursively remove any parent directories, but only if they are empty, stop if they are not\n remove_empty_folders_recursively( path )\n end",
"def delete\n File.delete fullpath\n d... | [
"0.7876363",
"0.7431147",
"0.735552",
"0.7164017",
"0.7158658",
"0.7134201",
"0.70936924",
"0.6960207",
"0.6943068",
"0.68454456",
"0.6800318",
"0.6778718",
"0.6776878",
"0.6767045",
"0.6748883",
"0.67399156",
"0.67366195",
"0.66414785",
"0.65970296",
"0.6578105",
"0.6546556"... | 0.7812255 | 1 |
validates_presence_of :data, :if => :screening? | def screening?
self.tip == "screening"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid?\n data\n end",
"def valid?\n data\n end",
"def validates_presence(atts, opts={})\n validatable_attributes(atts, opts){|a,v,m| (m || \"is not present\") if model.db.send(:blank_object?, v) && v != false}\n end",
"def _validate_presence_of_record(record)\n\t\traise ActiveReco... | [
"0.6122415",
"0.6122415",
"0.59217066",
"0.59083885",
"0.584703",
"0.5814555",
"0.5795216",
"0.56899846",
"0.5668165",
"0.5650698",
"0.5601923",
"0.5544541",
"0.55386275",
"0.5492995",
"0.54901725",
"0.5482241",
"0.5479928",
"0.54751027",
"0.54716825",
"0.5458889",
"0.5458889... | 0.0 | -1 |
This method generates an array of all moves that can be made after the current move. | def children
board_nodes = []
(0...3).each do |r|
(0...3).each do |c|
if board.empty? [r, c]
temp_board = board.dup
temp_board[[r, c]] = next_mover_mark
mark = (next_mover_mark == :o) ? :x : :o
board_nodes << TicTacToeNode.new(temp_board, mark, [r, c])
end
end
end
board_nodes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_possible_moves\n positions_array = []\n x = @position[0]\n y = @position[1]\n next_position = [x+1,y+2]\n positions_array << next_position if position_check(next_position)\n next_position = [x+1,y-2]\n positions_array << next_position if position_check(next_position)\n next_positio... | [
"0.7454911",
"0.7448829",
"0.7407405",
"0.73753744",
"0.7238307",
"0.7236044",
"0.7215574",
"0.72127986",
"0.7204278",
"0.7180208",
"0.7141102",
"0.7116441",
"0.708988",
"0.70805866",
"0.7072528",
"0.706047",
"0.7034363",
"0.7026709",
"0.6984989",
"0.6974822",
"0.69528663",
... | 0.0 | -1 |
Cluster information for local HPC center | def clusters
@clusters ||= parse_clusters(ENV['OOD_CLUSTERS'])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __cluster_info\n health = JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_cluster/health\")))\n nodes = if version == '0.90'\n JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_nodes/?process&http\")))\n else\n JSON.parse(Net::HTTP.get(URI(\"#{__clust... | [
"0.783914",
"0.7342468",
"0.7267701",
"0.7236756",
"0.69630283",
"0.69404453",
"0.6911999",
"0.68401474",
"0.683745",
"0.68071854",
"0.6804641",
"0.6697523",
"0.6693067",
"0.6671251",
"0.6616565",
"0.66137177",
"0.65780985",
"0.6563077",
"0.6559855",
"0.6530973",
"0.6498104",... | 0.6409815 | 24 |
Customize configuration for this object. | def configure
yield self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure(conf)\n super\n end",
"def configure opts\n configuration.merge!(opts)\n end",
"def configure\n\t\t\tyield configuration\n\t\tend",
"def config(&block)\n yield(self)\n end",
"def configure(config={})\n config.each do |(key, val)|\n self.config[key] = val\n ... | [
"0.699449",
"0.67794436",
"0.67255783",
"0.6702203",
"0.6691903",
"0.6674663",
"0.66543835",
"0.6599814",
"0.65958476",
"0.6579515",
"0.656739",
"0.65650153",
"0.65650153",
"0.65650153",
"0.65650153",
"0.65533733",
"0.65533733",
"0.6552773",
"0.6551654",
"0.65291464",
"0.6529... | 0.0 | -1 |
Sets the default configuration for this object. | def set_default_configuration
ActiveSupport::Deprecation.warn("The environment variable RAILS_DATAROOT will be deprecated in an upcoming release, please use OOD_DATAROOT instead.") if ENV['RAILS_DATAROOT']
self.dataroot = ENV['OOD_DATAROOT'] || ENV['RAILS_DATAROOT']
self.dataroot ||= "~/#{ENV['OOD_PORTAL'] || "ondemand"}/data/#{ENV['APP_TOKEN']}" if ENV['APP_TOKEN']
# Add markdown template support
self.markdown = Redcarpet::Markdown.new(
Redcarpet::Render::HTML,
autolink: true,
tables: true,
strikethrough: true,
fenced_code_blocks: true,
no_intra_emphasis: true
)
# Initialize URL handlers for system apps
self.public = Urls::Public.new(
title: ENV['OOD_PUBLIC_TITLE'] || 'Public Assets',
base_url: ENV['OOD_PUBLIC_URL'] || '/public'
)
self.dashboard = Urls::Dashboard.new(
title: ENV['OOD_DASHBOARD_TITLE'] || 'Open OnDemand',
base_url: ENV['OOD_DASHBOARD_URL'] || '/pun/sys/dashboard'
)
self.shell = Urls::Shell.new(
title: ENV['OOD_SHELL_TITLE'] || 'Shell',
base_url: ENV['OOD_SHELL_URL'] || '/pun/sys/shell'
)
self.files = Urls::Files.new(
title: ENV['OOD_FILES_TITLE'] || 'Files',
base_url: ENV['OOD_FILES_URL'] || '/pun/sys/dashboard/files'
)
self.editor = Urls::Editor.new(
title: ENV['OOD_EDITOR_TITLE'] || 'Editor',
# this is not a typo => the editor is /edit off of the base url
base_url: ENV['OOD_EDITOR_URL'] || '/pun/sys/dashboard/files'
)
# Add routes for useful features
self.routes = OpenStruct.new(
files_rack_app: true,
wiki: true
)
# Override Bootstrap SASS variables
self.bootstrap = OpenStruct.new(
navbar_inverse_bg: '#53565a',
navbar_inverse_link_color: '#fff',
navbar_inverse_color: '$navbar-inverse-link-color',
navbar_inverse_link_hover_color: 'darken($navbar-inverse-link-color, 20%)',
navbar_inverse_brand_color: '$navbar-inverse-link-color',
navbar_inverse_brand_hover_color: '$navbar-inverse-link-hover-color'
)
ENV.each {|k, v| /^BOOTSTRAP_(?<name>.+)$/ =~ k ? self.bootstrap[name.downcase] = v : nil}
self.enable_log_formatter = ::Rails.env.production?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_defaults!\n __load_config( DEFAULTS )\n end",
"def set_conf_default(conf)\n end",
"def set_conf_default(conf)\n end",
"def default_settings=(hash)\n @default_settings = hash\n end",
"def init_default_config\n configuration.project_id ||= Debugger.default_p... | [
"0.79569805",
"0.7421777",
"0.7421777",
"0.73778707",
"0.7283854",
"0.7276993",
"0.727658",
"0.7254159",
"0.7189189",
"0.71845925",
"0.7117096",
"0.7102306",
"0.69883287",
"0.69883287",
"0.69837916",
"0.6973781",
"0.6941869",
"0.6939254",
"0.688868",
"0.68759835",
"0.68759835... | 0.0 | -1 |
Read in cluster config and parse it | def parse_clusters(config)
OodCore::Clusters.load_file(config || '/etc/ood/config/clusters.d')
rescue OodCore::ConfigurationNotFound
OodCore::Clusters.new([])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_cluster_config\n defs_file = open(\"cluster_defs.json\")\n defs_json = defs_file.read\n clust_cfg = JSON.parse(defs_json)\n defs_file.close\n return clust_cfg\nend",
"def read_cluster_config\n if ENV['VAGRANT_CWD'] then\n folder = ENV['VAGRANT_CWD'] + \"/cluster_defs.json\"\n defs_file ... | [
"0.793889",
"0.7560589",
"0.72770584",
"0.68423265",
"0.6518475",
"0.6499474",
"0.6489818",
"0.6366344",
"0.6357149",
"0.63405496",
"0.6338704",
"0.6313696",
"0.6297541",
"0.625269",
"0.6183174",
"0.61547285",
"0.61348826",
"0.61177576",
"0.61155534",
"0.60882854",
"0.6075647... | 0.7347687 | 2 |
GET /tests GET /tests.json | def index
@tests = Test.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n render status: :ok, json: @tests\n end",
"def test\n get(\"/help/test.json\")\n end",
"def test\n get(\"/help/test.json\")\n end",
"def index\n @tests = Test.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tes... | [
"0.77513814",
"0.77281153",
"0.77281153",
"0.73835593",
"0.73397875",
"0.69955796",
"0.69955796",
"0.6836035",
"0.67343783",
"0.66843206",
"0.6667517",
"0.6658951",
"0.6608686",
"0.65748185",
"0.6561979",
"0.6547614",
"0.6522385",
"0.65215474",
"0.65199804",
"0.6516882",
"0.6... | 0.65987116 | 19 |
GET /tests/1 GET /tests/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test\n get(\"/help/test.json\")\n end",
"def test\n get(\"/help/test.json\")\n end",
"def get_one\n test_data = @test.get_one\n return render json: test_data\n end",
"def index\n render status: :ok, json: @tests\n end",
"def index\n @tests = Test.all\n\n r... | [
"0.7404314",
"0.7404314",
"0.7304388",
"0.7279787",
"0.7125164",
"0.6878569",
"0.6878569",
"0.6849366",
"0.67718923",
"0.6757094",
"0.6669219",
"0.6624378",
"0.66209686",
"0.66169363",
"0.6546323",
"0.64791626",
"0.64788824",
"0.6474367",
"0.6439662",
"0.643125",
"0.6427616",... | 0.0 | -1 |
POST /tests POST /tests.json | def create
@test = Test.new(test_params)
@test.update_question_details(test_params) if @test.valid?
respond_to do |format|
if @test.save
format.html { redirect_to @test, notice: 'Test was successfully created.' }
format.json { render :show, status: :created, location: @test }
else
format.html { render :new }
format.json { render json: @test.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def v2_tests_post(test_detail, opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: TestsApi#v2_tests_post ...\"\n end\n \n # verify the required parameter 'test_detail' is set\n fail \"Missing the required parameter 'test_detail' when calling v2_tests... | [
"0.7214356",
"0.7066029",
"0.70654726",
"0.69897264",
"0.6816136",
"0.65941167",
"0.65495807",
"0.65495807",
"0.65495807",
"0.65495807",
"0.65495807",
"0.65495807",
"0.65109015",
"0.6479572",
"0.6469656",
"0.64529276",
"0.6437642",
"0.64076364",
"0.6396511",
"0.63255227",
"0.... | 0.0 | -1 |
PATCH/PUT /tests/1 PATCH/PUT /tests/1.json | def update
respond_to do |format|
@test.update_question_details(test_params)
if @test.update(test_params)
format.html { redirect_to @test, notice: 'Test was successfully updated.' }
format.json { render :show, status: :ok, location: @test }
else
format.html { render :edit }
format.json { render json: @test.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @test = Test.find(params[:id])\n\n respond_to do |format|\n if @test.update_attributes(params[:test])\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n... | [
"0.66275895",
"0.6462119",
"0.6461085",
"0.641104",
"0.6391308",
"0.6391308",
"0.6391308",
"0.6391308",
"0.6391308",
"0.6391308",
"0.6391308",
"0.6353196",
"0.63523674",
"0.63470954",
"0.6342605",
"0.6310571",
"0.6279947",
"0.62674844",
"0.62450176",
"0.6235671",
"0.6208939",... | 0.58197886 | 63 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.