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 |
|---|---|---|---|---|---|---|
Reload the items being shown | def reload_data(dungeon)
#store the dungeon
@dungeon = dungeon
#Tables to hold dungeon floor data
@maps = @dungeon.maps
@data = @dungeon.data
#Load the base data of the floors
@floors = @dungeon.floors
@width = @dungeon.width
@height = @dungeon.height
@ids = [@dungeon.map, @dungeon.compass, @dungeon.key, @dungeon.boss_key]
@floor_names = @dungeon.floor_names
@extras = @dungeon.extras
#initialize cursor data
@items = [ ]
@xy_pos = [ ]
#get the floor rectangle
rect = Rect.new(FloorsRectangle)
#store the cursor position item data
@floors.times do i
#store the floor number
@items i
#store the x and y position of the floors
x = rect.x + rect.width 2
h = 30
y = rect.y + rect.height 2 + @floors h 2 - i h - h 2
@xy_pos [x,y]
end
# Add the other cursor positions for the dungeon items
@ids.each {id @items $data_items[id]}
@xy_pos.push MapLocation, CompassLocation, KeysLocation, BossKeyLocation
# Add the toggles
@items += [ left_toggle, right_toggle ]
@xy_pos += ToggleCoords
# Get the current floor
@current_floor = @dungeon.current_floor
# Make cursor index the current floor
@index = @items.index(@current_floor)
# Draw the dungeon, floors, items and floor name
draw_background('hdrdungeonmapscreenoot')
draw_dungeon(@current_floor)
draw_floors
draw_items
# Move the cursor to the correct position
@cursor.x, @cursor.y = @xy_pos[@index][0], @xy_pos[@index][1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reload_items\n @item_data = nil\n end",
"def refresh_items\n rows.clear\n\n items.each do |item|\n rows << [item]\n end\n end",
"def group_reload\n\t\tRails.application.load_seed \n\t\t@items = Item.all\n\t\trender 'index'\n\tend",
"def reload\n @items = nil\n\n ... | [
"0.75987786",
"0.689893",
"0.6847197",
"0.6763099",
"0.67515767",
"0.6382917",
"0.62953",
"0.6274821",
"0.622656",
"0.622656",
"0.62231314",
"0.61876774",
"0.61342746",
"0.5953241",
"0.5932395",
"0.59179705",
"0.5917457",
"0.590853",
"0.5881079",
"0.5876047",
"0.58575034",
... | 0.0 | -1 |
GET /classcourses GET /classcourses.json | def index
@classcourses = Classcourse.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respond_to do |format|\n format.json { render json: @courses }\n end\n end",
"def index\n\t\t@courses = Course.all\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @courses }\n\t\t... | [
"0.73067385",
"0.7259481",
"0.71841806",
"0.714735",
"0.714735",
"0.7140192",
"0.71147335",
"0.7060882",
"0.7033239",
"0.6989966",
"0.692844",
"0.69112396",
"0.68972695",
"0.6892204",
"0.6872881",
"0.68595946",
"0.6858032",
"0.68547773",
"0.68184125",
"0.6783514",
"0.6780619"... | 0.74815416 | 0 |
GET /classcourses/1 GET /classcourses/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @classcourses = Classcourse.all\n end",
"def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respond_to do |format|\n format.json { render json: @courses }\n end\n end",
"def index\n @courses = Course.all\n render json: @courses, status: :o... | [
"0.7444431",
"0.74073446",
"0.7242293",
"0.72231704",
"0.72187376",
"0.72187376",
"0.7205321",
"0.7187661",
"0.71724486",
"0.7122724",
"0.7112016",
"0.70900077",
"0.70333964",
"0.7013382",
"0.69934624",
"0.69866085",
"0.6982889",
"0.6968831",
"0.6962562",
"0.6962562",
"0.6962... | 0.0 | -1 |
POST /classcourses POST /classcourses.json | def create
@classcourse = Classcourse.new(classcourse_params)
respond_to do |format|
if @classcourse.save
format.html { redirect_to @classcourse, notice: 'Classcourse was successfully created.' }
format.json { render :show, status: :created, location: @classcourse }
else
format.html { render :new }
format.json { render json: @classcourse.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n # render plain: params[:courses].inspect\n @courses = Courses.new(courses_params)\n\n respond_to do |format|\n if @courses.save\n format.html { redirect_to @courses, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @cour... | [
"0.71606845",
"0.68968534",
"0.683812",
"0.6807336",
"0.67942196",
"0.67745584",
"0.6765484",
"0.67281306",
"0.6704129",
"0.66772485",
"0.6624955",
"0.6612518",
"0.6607749",
"0.65959156",
"0.65913314",
"0.65913314",
"0.65913314",
"0.65913314",
"0.65913314",
"0.65913314",
"0.6... | 0.7334485 | 0 |
PATCH/PUT /classcourses/1 PATCH/PUT /classcourses/1.json | def update
respond_to do |format|
if @classcourse.update(classcourse_params)
format.html { redirect_to @classcourse, notice: 'Classcourse was successfully updated.' }
format.json { render :show, status: :ok, location: @classcourse }
else
format.html { render :edit }
format.json { render json: @classcourse.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @course.update(course_params)\n render_jsonapi_response(@course)\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Class was successfully updated.' }\n format.json { render :show, status: :ok, lo... | [
"0.7074635",
"0.70389813",
"0.69147736",
"0.6888524",
"0.686462",
"0.6843808",
"0.6843808",
"0.6843808",
"0.6843808",
"0.6843808",
"0.6843808",
"0.6843808",
"0.6843808",
"0.6812234",
"0.6803637",
"0.680348",
"0.6790419",
"0.678449",
"0.67434525",
"0.67412263",
"0.67327374",
... | 0.71269804 | 0 |
DELETE /classcourses/1 DELETE /classcourses/1.json | def destroy
@classcourse.destroy
respond_to do |format|
format.html { redirect_to classcourses_url, notice: 'Classcourse was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content ... | [
"0.7551243",
"0.7551243",
"0.7551243",
"0.7551243",
"0.7544677",
"0.75269705",
"0.75200903",
"0.7520045",
"0.7520045",
"0.7520045",
"0.7520045",
"0.7520045",
"0.7520045",
"0.7520045",
"0.7520045",
"0.7520045",
"0.7520045",
"0.7520045",
"0.7476909",
"0.7469841",
"0.7443457",
... | 0.77074766 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_classcourse
@classcourse = Classcourse.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 classcourse_params
params.require(:classcourse).permit(:name, :period, :available, :course_id, :former_id, :description)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
This method takes a value and adds it to the front of the list Time Complexiy: Space Complexity: | def add_first(value)
raise NotImplementedError, "Please implement add_first"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_at_head(val)\n @list.unshift(val)\n end",
"def add_at_head(val)\n \n end",
"def add value\n if @head.nil?\n @length = 1\n @head = GenericList::Node.new(value)\n else\n lst = @head\n ptr = @head.nxt\n while ptr && @proc.call(value, lst.value) <= 0\n ls... | [
"0.80555207",
"0.730046",
"0.7265301",
"0.7019105",
"0.6983186",
"0.69771427",
"0.6802432",
"0.6782304",
"0.6689504",
"0.66727585",
"0.6633938",
"0.6625498",
"0.66042805",
"0.66010994",
"0.659719",
"0.6587629",
"0.6583835",
"0.65597767",
"0.65372634",
"0.6519339",
"0.64951336... | 0.6247762 | 59 |
This method returns the first value in the list without changing the list. Time Complexiy: Space Complexity: | def get_first
raise NotImplementedError, "Please implement get_first"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first ; list.first ; end",
"def get_first\r\n # if the list is empty, head is nil\r\n if @head.nil?\r\n return nil\r\n else \r\n value = @head.data\r\n return value\r\n end\r\n end",
"def list_first(list)\n list.head.data unless list.head.nil?\nend",
"def first\n # return ... | [
"0.8143089",
"0.778463",
"0.759073",
"0.72296137",
"0.7227916",
"0.7194945",
"0.70187914",
"0.6968552",
"0.6936897",
"0.688034",
"0.68667287",
"0.6861319",
"0.6828681",
"0.6828681",
"0.6807178",
"0.6797188",
"0.6745941",
"0.6727662",
"0.67097116",
"0.66919523",
"0.6690913",
... | 0.0 | -1 |
This method returns the length of the list Time Complexiy: Space Complexity: | def length
raise NotImplementedError, "Please implement length"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length\n # calculates the length of the list\n end",
"def size\n result, list = 0, self\n until list.empty?\n if list.cached_size?\n return result + list.size\n else\n result += 1\n end\n list = list.tail\n end\n result\n end",
"def l... | [
"0.8002158",
"0.7974038",
"0.7940393",
"0.7899738",
"0.7889373",
"0.7782048",
"0.769937",
"0.7630836",
"0.7557636",
"0.74947226",
"0.74947226",
"0.74824035",
"0.7478828",
"0.7454454",
"0.7444298",
"0.7403518",
"0.7392406",
"0.7382136",
"0.7380837",
"0.7380178",
"0.7372625",
... | 0.0 | -1 |
This method takes a value and adds it to the back of the list Time Complexiy: Space Complexity: | def add_last(value)
raise NotImplementedError, "Please implement add_last"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_at_tail(val)\n @list << val\n end",
"def add_at_tail(val)\n \n end",
"def add_at_head(val)\n @list.unshift(val)\n end",
"def add_last(value)\r\n \r\n # if list is empty, insert the new value at the head\r\n if @head.nil?\r\n @head = Node.new(value, nil)\r\n return... | [
"0.71741265",
"0.6856845",
"0.67372507",
"0.6713793",
"0.6623805",
"0.6596195",
"0.659009",
"0.6570051",
"0.65432745",
"0.6452928",
"0.6437095",
"0.63583606",
"0.6345438",
"0.6331958",
"0.6322815",
"0.6322083",
"0.6305345",
"0.6300425",
"0.6295252",
"0.6290315",
"0.6259055",
... | 0.60092866 | 58 |
This method returns the last value in the list Time Complexiy: Space Complexity: | def get_last
raise NotImplementedError, "Please implement get_last"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last(list)\n list[-1]\nend",
"def last\n list.first\n end",
"def get_last_item(arr)\n\treturn arr[-1]\nend",
"def last\n list = self\n list = list.tail until list.tail.empty?\n list.head\n end",
"def last\n @tail.val\n end",
"def get_last\n return nil if @head.nil?\n... | [
"0.80904794",
"0.78726155",
"0.7767861",
"0.7677838",
"0.7651865",
"0.7605032",
"0.7585331",
"0.75756496",
"0.7556125",
"0.75514644",
"0.7495602",
"0.7482156",
"0.7463609",
"0.7458997",
"0.74491006",
"0.7446005",
"0.7434559",
"0.7430832",
"0.7424399",
"0.74215746",
"0.7400827... | 0.0 | -1 |
This method takes an index and returns the value at that position in the list. If it does not exist, it returns nil. Time Complexiy: Space Complexity: | def get_at_index(index)
raise NotImplementedError, "Please implement get_at_index"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(index)\n @list[index] || -1\n end",
"def item(index)\n each_with_index { |item, ix| return item if index == ix } && nil\n end",
"def get(index)\n return -1 if @head.nil?\n return -1 if index > @size - 1\n\n if index < @size - index\n iter = @head\n cnt = 0\n until it... | [
"0.7952804",
"0.7482463",
"0.73991466",
"0.73620105",
"0.7348333",
"0.7331555",
"0.73218006",
"0.7278032",
"0.7240481",
"0.71636206",
"0.71288854",
"0.7101727",
"0.7079108",
"0.70143753",
"0.700991",
"0.70000726",
"0.6997352",
"0.6977848",
"0.6974263",
"0.696313",
"0.6951967"... | 0.6211681 | 61 |
This method takes a value and removes the first node with that value from the list. If it does not exist, it returns nil. Time Complexiy: Space Complexity: | def delete(value)
raise NotImplementedError, "Please implement delete"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(value)\n if self.include?(value)\n if head.data == value\n remove_head(value, head)\n else\n remove_value(value, head)\n end\n else\n return nil\n end\n end",
"def remove(value)\n\t\t\telement = self.head\n\t\t\tprevious_element = @head\n\t\t\twhile element.... | [
"0.8111445",
"0.8007466",
"0.7986752",
"0.7856689",
"0.76936895",
"0.7621533",
"0.75756806",
"0.74554694",
"0.7427061",
"0.74143165",
"0.7368093",
"0.73509747",
"0.7265213",
"0.7251418",
"0.7203256",
"0.71945405",
"0.7181852",
"0.7089254",
"0.70736355",
"0.7060285",
"0.700386... | 0.0 | -1 |
Advanced Exercises This method returns the value at the middle node in the list Time Complexiy: Space Complexity: | def find_middle_value
raise NotImplementedError, "Please implement find_middle_value"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_middle_value\r\n \r\n # if list is empty\r\n return nil if @head.nil?\r\n # if list has only one node\r\n return @head.data if @head.next.nil?\r\n \r\n # if list has multiple nodes, initialize a slow pointer and a fast pointer\r\n slow = @head\r\n fast = @head\r\n \r\n # t... | [
"0.78226775",
"0.76270485",
"0.7448042",
"0.7255251",
"0.7075204",
"0.6996867",
"0.6949632",
"0.6948217",
"0.68829495",
"0.6864202",
"0.65512305",
"0.6528332",
"0.6377209",
"0.63735497",
"0.63672185",
"0.6229073",
"0.6207994",
"0.61941206",
"0.6167224",
"0.61362666",
"0.61084... | 0.6194731 | 17 |
find the nth node from the end and return its value Time Complexiy: Space Complexity: | def find_nth_from_end(n)
raise NotImplementedError, "Please implement find_nth_from_end"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_nth_from_end(n)\r\n # lead, nth = @head\r\n\r\n # n.times { lead = lead.next if lead }\r\n \r\n # while lead && lead.next && nth && nth.next\r\n # lead = lead.next\r\n # nth = nth.next\r\n # end\r\n\r\n # return nth&.data\r\n n = self.count.pred - n\r\n return if n < 0\r\... | [
"0.7609893",
"0.76071",
"0.75948304",
"0.7363108",
"0.71184844",
"0.7102136",
"0.70752794",
"0.7063246",
"0.70514464",
"0.7034081",
"0.7029989",
"0.6980251",
"0.69714636",
"0.6946161",
"0.68919224",
"0.68838185",
"0.68752664",
"0.6870051",
"0.68510604",
"0.6848102",
"0.684029... | 0.63397396 | 86 |
This method checks if the linked has a cycle. A cycle exists if any node in the linked list links to a node already visited. It returns true if a cycle is found, false otherwise. Time Complexiy: Space Complexity: | def has_cycle
raise NotImplementedError, "Please implement has_cycle"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_cycle\n if @head == nil || @head.next == nil\n return false\n end\n slow = @head\n fast = @head\n while fast != nil\n slow = slow.next\n fast = fast.next\n if fast != nil\n fast = fast.next\n end\n if slow == fast\n return true # cycle detected\n ... | [
"0.86184007",
"0.856242",
"0.8514728",
"0.8003016",
"0.7952781",
"0.75314385",
"0.7485635",
"0.7464854",
"0.73168796",
"0.7215481",
"0.716853",
"0.715537",
"0.7142239",
"0.7033497",
"0.6963799",
"0.69021994",
"0.68935263",
"0.6873265",
"0.6710891",
"0.67035663",
"0.66724944",... | 0.5798825 | 46 |
Helper method for tests Creates a cycle in the linked list for testing purposes Assumes the linked list has at least one node | def create_cycle
return if @head == nil # don't do anything if the linked list is empty
# navigate to last node
current = @head
while current.next != nil
current = current.next
end
current.next = @head # make the last node link to first node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_cycle\r\n return if @head == nil # don't do anything if the linked list is empty\r\n \r\n # navigate to last node\r\n current = @head\r\n while current.next != nil\r\n current = current.next\r\n end\r\n \r\n current.next = @head # make the last node link to first node\r\n e... | [
"0.8238132",
"0.8220127",
"0.8124021",
"0.8034499",
"0.7030841",
"0.7030841",
"0.69006324",
"0.6697276",
"0.66597",
"0.6457345",
"0.64286387",
"0.6412259",
"0.63544786",
"0.6342136",
"0.630625",
"0.62818205",
"0.62734306",
"0.6272129",
"0.625401",
"0.624276",
"0.6199815",
"... | 0.8186042 | 3 |
used to allow create function to write to the db | def userlist_params
params.require(:userlist).permit(:name, :file)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create; end",
"def create; end",
"def create; end",
"def create; end",
"def create\n \t\n end",
"def create\n File.open(@db_file, \"w\" ) do |file|\n end\n end",
"def create\n \n end",
"def create\n\t\twrite('')\n\t\tself\n\tend",
"def create\n\t\twrite('')\n\t\tself\n\tend",
"def ... | [
"0.7569902",
"0.7569902",
"0.7569902",
"0.7569902",
"0.7330191",
"0.7255232",
"0.71910995",
"0.71597964",
"0.71597964",
"0.7109665",
"0.7102035",
"0.70707595",
"0.70707595",
"0.7024228",
"0.68900734",
"0.685824",
"0.68547124",
"0.68547124",
"0.68534046",
"0.6831469",
"0.68314... | 0.0 | -1 |
The contructor takes the following configuration options: :region:: A string naming the region to be used. If no region is given, the default region is used. :credentials:: A hash containing the fields 'access_key_id' and 'secret_access_key' with the credential information to your amazon account. :instance:: An instance of the AWS::EC2. If that instance is given, no +credentials:+ should be given. Kiel::Cloud::AWS will instead use this instance. :start_options:: Options that are applied to EC2::InstanceCollection.create (siehe awssdk for more details). The aws_tests.rb uses the :key_name and :security_groups options to set the name of the used ssh key and a security group, where ssh is enabled. | def initialize options = {}
require 'aws/ec2'
options.each_key do | key |
raise ArgumentError, "unrecognized option \'#{key}\'" unless RECOGNIZED_OPTIONS.include? key
end
@ec2 = options[ :instance ]
@start_options = options[ :start_options ] || {}
if @ec2
puts "\'credentials\' ignored as an instance was given too" if options.key? :credentials
else
::AWS.config( options[ :credentials ] )
@ec2 = ::AWS::EC2.new
@ec2 = @ec2.regions[ options[ :region ] ] if options.key? :region
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aws_instance_create(opts)\n AWS::EC2::InstanceCollection.new.create(\n image_id: Rails.configuration.x.aws[Rails.configuration.x.aws['region']][\"ami_#{self.os}\"], \n private_ip_address: self.ip_address,\n key_name: Rails.configuration.x.aws['ec2_key_pair_name'],\n user_data: self.gener... | [
"0.7250779",
"0.7122463",
"0.7079295",
"0.70470524",
"0.70228297",
"0.7001072",
"0.6942722",
"0.69050723",
"0.67896456",
"0.6753665",
"0.67460376",
"0.6668463",
"0.6591186",
"0.6590869",
"0.65905505",
"0.6561923",
"0.6557253",
"0.64974135",
"0.6497373",
"0.64622134",
"0.64251... | 0.8159999 | 0 |
Finds all images where the given tags apply | def all_images_by_tags tags
images = @ec2.images.with_owner('self').tagged( tags.first.first )
images = images.select do | image |
image_tags = image.tags.to_h
image_tags.merge( tags ) == image_tags
end
images
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_images_by_tags(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'SearchResultsSet')\n end",
"def select_regexp_matching_images(re_hn)\n Docker::Image.all.select { |img|\n info_map = img.info\n info_map && info_map['RepoTags'] && i... | [
"0.7304328",
"0.72824883",
"0.71125233",
"0.6823975",
"0.6745659",
"0.6658034",
"0.64427763",
"0.64353603",
"0.6402152",
"0.63022757",
"0.6301073",
"0.6258428",
"0.62350523",
"0.6214165",
"0.6110604",
"0.61042464",
"0.6058074",
"0.60450935",
"0.596262",
"0.5940298",
"0.593803... | 0.8014573 | 0 |
store the given +instance+ and add the hash of +tags+ to the image. | def store_image instance, tags
begin
puts "waiting 2 minutes before starting to take the image..."
sleep 120
puts "creating image..."
image = @ec2.images.create(
:instance_id => instance.id,
:no_reboot => true,
:description => "automaticaly created #{tags[ 'image_type' ]} image",
:name => "#{tags[ 'image_type' ]} #{Digest::SHA1.hexdigest tags.inspect}" )
wait_for_image image
tags.each do | key, value |
image.add_tag( key, :value => value )
end
ensure
stop_instance instance
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(instance)\n @pstore.transaction do\n @registry << instance\n @pstore[:registry] = @registry\n end\n end",
"def register(instance)\n key = build_key(instance)\n key_registry[key] = instance\n end",
"def tag_instance(instance, itags, vtags)\n yield \"#{@mgr.timestamp()... | [
"0.63879764",
"0.61037225",
"0.60244",
"0.60088336",
"0.5814858",
"0.5629697",
"0.56242365",
"0.55753314",
"0.55497885",
"0.55449665",
"0.55080044",
"0.54626656",
"0.543501",
"0.5368953",
"0.5325819",
"0.524622",
"0.52176887",
"0.5205973",
"0.5174517",
"0.5139046",
"0.5097000... | 0.6570229 | 0 |
stops the given instance. | def stop_instance instance
begin
instance.terminate
rescue
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop()\n self.destroy()\n\n # Stop the EC2 instance\n $ec2.terminate_instances([self.id])\n end",
"def stop!\n stop_instance(_id) && reload!\n end",
"def stop_instance(which)\n inst = Instance.running_for_profile(self).select {|i| i.num == which}\n return nil if inst.empty?\n ins... | [
"0.7572558",
"0.7570503",
"0.75245523",
"0.74717134",
"0.7327866",
"0.7316469",
"0.72782356",
"0.7256038",
"0.7255468",
"0.7225797",
"0.7206585",
"0.7204487",
"0.7183401",
"0.7183401",
"0.71771383",
"0.71771383",
"0.7132348",
"0.7132348",
"0.71279687",
"0.7127028",
"0.7125789... | 0.87907475 | 0 |
the public dns name of the given instance | def dns_name instance
instance.dns_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_dns_name\n data[:public_dns_name]\n end",
"def dns_name\n [\"public\", fqdn].join(\".\")\n end",
"def dnsName(connection:, instanceId:)\n connection.describe_instances('instance-id' =>[instanceId])[:body]['reservationSet'][0]['instancesSet'][0]['dnsName']\nend",
"def priva... | [
"0.8670069",
"0.84650123",
"0.78335327",
"0.7517484",
"0.74860924",
"0.7432223",
"0.7336888",
"0.7330647",
"0.7324221",
"0.7318624",
"0.728772",
"0.7048723",
"0.6787695",
"0.674181",
"0.67249143",
"0.6721302",
"0.6721087",
"0.6673001",
"0.6670736",
"0.66041285",
"0.65980023",... | 0.84862983 | 1 |
deletes the given images by tags. For now this function is used just for cleanup during tests. | def delete_image tags
all_images_by_tags( tags ).each { | image | image.deregister }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_images(old_images)\n old_images.each do |name, image|\n image.delete(:all) if image && image != send(name)\n end\n end",
"def delete_tags\n @tags.delete_tags(@filename) unless @tags.nil?\n end",
"def remove_images\n @sample.cover_image.purge if sample_params[:remove_cover_im... | [
"0.74385285",
"0.7330226",
"0.70858693",
"0.70231134",
"0.6900659",
"0.6876395",
"0.6866197",
"0.6833353",
"0.67633814",
"0.674299",
"0.6707447",
"0.6683725",
"0.66831994",
"0.66642225",
"0.6663758",
"0.664957",
"0.6624313",
"0.6602817",
"0.6578556",
"0.65631133",
"0.65499794... | 0.8863835 | 0 |
DELETE /likes/1 DELETE /likes/1.json | def destroy
@like.destroy
respond_to do |format|
format.html { redirect_to likes_url, notice: 'Like was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_likes\n end",
"def delete_likes\n end",
"def delete_likes\n end",
"def delete\n render json: Like.delete(params[\"id\"])\n end",
"def destroy\n @like = Like.find(params[:id])\n @like.destroy\n\n respond_to do |format|\n format.html { redirect_to likes_url }\n format.jso... | [
"0.7963881",
"0.7963881",
"0.7963881",
"0.79174495",
"0.7806257",
"0.7663847",
"0.7566095",
"0.75602895",
"0.7476212",
"0.7421949",
"0.7401767",
"0.73041147",
"0.72835547",
"0.7274384",
"0.72561353",
"0.7253145",
"0.7231774",
"0.72289056",
"0.721481",
"0.7192185",
"0.7183945"... | 0.74774575 | 9 |
Use callbacks to share common setup or constraints between actions. | def set_like
@like = Like.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 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def user_params
params.require(:user).permit(:name, :email, :password,
:password_confirmation, :admin)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
Takes the output of 'listformats' | def supported_formats
# WARNING: This shit won't be documented or even properly tested. It's almost 3 in the morning and I have no idea what I'm doing.
header_index = output.index('format code')
return nil if header_index.nil?
formats = []
output.slice(header_index..-1).split("\n").each do |line|
format = {}
format[:format_code], format[:extension], format[:resolution], format[:note] = line.scan(/\A(\d+)\s+(\w+)\s+(\S+)\s(.*)/)[0]
formats.push format
end
formats.shift # The first line is just headers
return [] if formats.first.nil?
formats.map do |format|
format[:note].strip! # Get rid of any trailing whitespace on the note.
format[:format_code] = format[:format_code].to_i # convert format code to integer
format
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formats; end",
"def formats; end",
"def formats\n format\n end",
"def format_list(items); end",
"def formats_list(opts = {})\n data, _status_code, _headers = formats_list_with_http_info(opts)\n data\n end",
"def _process_format(format); end",
"def _process_format(format); e... | [
"0.7296468",
"0.7296468",
"0.7017773",
"0.68966985",
"0.68700165",
"0.6818226",
"0.6818226",
"0.6783731",
"0.6762236",
"0.6757597",
"0.6698212",
"0.6543471",
"0.65027666",
"0.64434475",
"0.64336014",
"0.6369373",
"0.63579035",
"0.6350338",
"0.63238275",
"0.6295964",
"0.628964... | 0.72399247 | 2 |
Takes the output of a download | def filename
# Check to see if file was already downloaded
if already_downloaded?
output.scan(/\[download\]\s(.*)\shas already been downloaded/)[0][0]
else
if output.include? 'Merging formats into'
output.scan(/Merging formats into \"(.*)\"/)[0][0]
else
output.scan(/\[.*\] Destination:\s(.*)$/).last.last
end
end
rescue NoMethodError # There wasn't a match somewhere. Kill it with fire
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download(url)\n Net::HTTP.get_response(url)\n end",
"def download(url)\n filedl = url.split(\"/\").last\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request)\n open(fil... | [
"0.7154122",
"0.70453376",
"0.6984138",
"0.69566315",
"0.69412565",
"0.6933437",
"0.6844037",
"0.68016577",
"0.6758505",
"0.6752457",
"0.674688",
"0.6733171",
"0.67049104",
"0.66677004",
"0.665118",
"0.66465455",
"0.659826",
"0.6598008",
"0.6585964",
"0.65766865",
"0.65718883... | 0.0 | -1 |
Takes the output of a download | def already_downloaded?
output.include? 'has already been downloaded'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download(url)\n Net::HTTP.get_response(url)\n end",
"def download(url)\n filedl = url.split(\"/\").last\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request)\n open(fil... | [
"0.7154122",
"0.70453376",
"0.6984138",
"0.69566315",
"0.69412565",
"0.6933437",
"0.6844037",
"0.68016577",
"0.6758505",
"0.6752457",
"0.674688",
"0.6733171",
"0.67049104",
"0.66677004",
"0.665118",
"0.66465455",
"0.659826",
"0.6598008",
"0.6585964",
"0.65766865",
"0.65718883... | 0.0 | -1 |
all x where 1<= x < 3 generation = case birthyear when 1946..1963: "old man" when 1990..2010: "man" else nil end | def are_you_sure?
while true
print "are you sure? [y/n]:"
response = gets
case response
when /^[yY]/
return true
when /^[nN]/, /^$/
return false
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def years\n case @age\n when 1..5 then puts \"You are a baby\"\n when 6..12 then puts \"You are a child\"\n when 13..21 then puts \"You are a young people\"\n when 22...35 then puts \"You are adult\"\n end\n end",
"def year(year_range = (1930..1950))\n rand(year_range)\nend",
"def t... | [
"0.6845971",
"0.6731113",
"0.65738505",
"0.65294087",
"0.6522749",
"0.6474609",
"0.6425371",
"0.6413978",
"0.63935626",
"0.6381227",
"0.63766205",
"0.6362049",
"0.63595027",
"0.6265721",
"0.6214396",
"0.6183809",
"0.6140212",
"0.6115477",
"0.61091095",
"0.6088668",
"0.6076541... | 0.0 | -1 |
Copying Objects Marshaling Objects | def deepcopy(o)
Marshal.load(Marshal.dump(o))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy object\r\n\tMarshal.load(Marshal.dump(object))\r\nend",
"def copy object\n\tMarshal.load(Marshal.dump(object))\nend",
"def deep_copy object\n Marshal.load(Marshal.dump(object))\n end",
"def deep_copy object\n Marshal.load(Marshal.dump(object))\n end",
"def make_copy\n\t\t\tMarshal.... | [
"0.7771058",
"0.77033603",
"0.74526066",
"0.74526066",
"0.7422729",
"0.7390828",
"0.73505205",
"0.733965",
"0.72892886",
"0.72892886",
"0.7261105",
"0.7219204",
"0.72144514",
"0.72008055",
"0.7169966",
"0.7161638",
"0.7133983",
"0.71060795",
"0.708377",
"0.70648015",
"0.70345... | 0.72762686 | 10 |
GET /user_follow_playlists GET /user_follow_playlists.json | def index
@user_follow_playlists = UserFollowPlaylist.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def follow_list(options)\n session.options = adapt_to_dev_env(options)\n session.get('/follows')\n end",
"def own_playlists\n check_auth :own_playlists\n \n response = connection.post do |req|\n req.url '/user/playlists'\n req.body = { :format => @format }\n e... | [
"0.7328817",
"0.73130304",
"0.7010758",
"0.69365555",
"0.6763378",
"0.6712536",
"0.66999483",
"0.667652",
"0.6640081",
"0.6625453",
"0.6611698",
"0.6606298",
"0.6579872",
"0.6548602",
"0.6509839",
"0.6503257",
"0.64973",
"0.64973",
"0.6487677",
"0.64594084",
"0.6389693",
"0... | 0.7441841 | 0 |
GET /user_follow_playlists/1 GET /user_follow_playlists/1.json def show end GET /user_follow_playlists/new | def new
@user_follow_playlist = UserFollowPlaylist.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @user = current_user\n @playlist = @user.playlists.new\n end",
"def new\n @playlist = current_user.playlists.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @playlist }\n end\n end",
"def new\n if signed_in?\n @playlist = c... | [
"0.7590163",
"0.75452787",
"0.74101454",
"0.72981524",
"0.72081715",
"0.7176448",
"0.7092323",
"0.70287144",
"0.6889157",
"0.6886678",
"0.68515795",
"0.67875654",
"0.6781458",
"0.66690886",
"0.66690886",
"0.6645396",
"0.66421217",
"0.6628846",
"0.662504",
"0.662504",
"0.66205... | 0.7982743 | 0 |
GET /user_follow_playlists/1/edit def edit end POST /user_follow_playlists POST /user_follow_playlists.json | def create
@user_follow_playlist = UserFollowPlaylist.new(user_follow_playlist_params)
@user = current_user
@user_follow_playlist.user_id = @user.id
@user_follow_playlist.playlist_id = params[:playlist][:playlist_id]
respond_to do |format|
if @user_follow_playlist.save
format.html { redirect_to @user_follow_playlist, notice: 'User follow playlist was successfully created.' }
format.json { render :show, status: :created, location: @user_follow_playlist }
else
format.html { render :new }
format.json { render json: @user_follow_playlist.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @user_follow_playlist.update(user_follow_playlist_params)\n format.html { redirect_to @user_follow_playlist, notice: 'User follow playlist was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_follow_playlist }\n ... | [
"0.71344876",
"0.68866616",
"0.6627007",
"0.6559318",
"0.65521383",
"0.65111667",
"0.6485034",
"0.6462702",
"0.6452146",
"0.64405566",
"0.63962525",
"0.63350606",
"0.63320297",
"0.6313042",
"0.6313042",
"0.63078654",
"0.63038385",
"0.6294503",
"0.6293776",
"0.62647665",
"0.62... | 0.0 | -1 |
PATCH/PUT /user_follow_playlists/1 PATCH/PUT /user_follow_playlists/1.json | def update
respond_to do |format|
if @user_follow_playlist.update(user_follow_playlist_params)
format.html { redirect_to @user_follow_playlist, notice: 'User follow playlist was successfully updated.' }
format.json { render :show, status: :ok, location: @user_follow_playlist }
else
format.html { render :edit }
format.json { render json: @user_follow_playlist.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n current_user.update(playlist_names: params[:playlists])\n render json: current_user\n end",
"def update\n @playlist = current_user.playlists.find(params[:id])\n\n respond_to do |format|\n if @playlist.update_attributes(params[:playlist])\n format.html { redirect_to @playlist... | [
"0.7251149",
"0.68261635",
"0.65576255",
"0.6493206",
"0.6437278",
"0.6435886",
"0.6428756",
"0.63827074",
"0.63583475",
"0.63372004",
"0.6333532",
"0.63122714",
"0.6284364",
"0.6284364",
"0.6268122",
"0.62655354",
"0.6250401",
"0.6233114",
"0.6232836",
"0.6227829",
"0.622045... | 0.712267 | 1 |
DELETE /user_follow_playlists/1 DELETE /user_follow_playlists/1.json | def destroy
@user_follow_playlist.destroy
respond_to do |format|
format.html { redirect_to user_follow_playlists_url, notice: 'User follow playlist was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_follows\n\n\t@follower = User.find(params[:id])\n\t@followed = User.find(params[:follows_id])\n\n\t@follower.follows.delete(@followed)\n\t\thead :no_content\n\t\t\n\tend",
"def delete_follows\n \t@follower = User.find(params[:id])\n \t@followed = User.find(params[:follows_id])\n \t\n \tif @followe... | [
"0.71916693",
"0.7149107",
"0.6966582",
"0.6931983",
"0.689206",
"0.68859595",
"0.6880979",
"0.6835571",
"0.68158203",
"0.6814533",
"0.68071336",
"0.6799334",
"0.6793782",
"0.67724544",
"0.67473793",
"0.67426455",
"0.670891",
"0.67036444",
"0.67003757",
"0.66968924",
"0.66747... | 0.7391587 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_user_follow_playlist
@user_follow_playlist = UserFollowPlaylist.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def user_follow_playlist_params
params.require(:playlist).permit(:playlist_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Model > ComponentInstance > Group1 > Group2 > Group3 > Edge | def create_test_instances
model = Sketchup.active_model
definition = model.definitions.add('TC_Sketchup_InputPoint')
group1 = definition.entities.add_group
group2 = group1.entities.add_group
group2.transform!([10, 20, 30])
group3 = group2.entities.add_group
edge = group3.entities.add_line([10, 10, 10], [20, 20, 20])
tr = Geom::Transformation.new([20, 30, 40])
instance = model.entities.add_instance(definition, tr)
[instance, group1, group2, group3, edge]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edge_class() @parallel_edges ? Plexus::MultiEdge : Plexus::Edge; end",
"def ii_groups; end",
"def group\n @slopes = Slope.find_measure_group(params[:slope_id], params[:machine_id])\n\n set_graph\n end",
"def parse_components\n\tcomp_list = comp_schema\n\tcorners = []\n\tcomp_list.keys.each { |id|\... | [
"0.57237923",
"0.5530456",
"0.54603606",
"0.5347004",
"0.52848315",
"0.5271492",
"0.51983416",
"0.5132115",
"0.50918686",
"0.50599754",
"0.5054081",
"0.50071466",
"0.5004343",
"0.4994659",
"0.49932218",
"0.49784058",
"0.4959061",
"0.4958647",
"0.4956111",
"0.4951499",
"0.4951... | 0.47387496 | 46 |
'validate' singular for custom validation functions custom validation | def your_name_is_not_dumb
if name.include?("dumb")
errors.add(:name, "is dumb")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate\n\n end",
"def validate!; end",
"def validate!; end",
"def validate!; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate\n end",
"def validate\n end",
"def validate\n end",
"def validate\n \n \n end",
"def vali... | [
"0.79532427",
"0.7943469",
"0.7943469",
"0.7943469",
"0.79076463",
"0.79076463",
"0.79076463",
"0.79076463",
"0.7851519",
"0.7851519",
"0.7851519",
"0.78182524",
"0.77978706",
"0.7750771",
"0.7750771",
"0.77466553",
"0.77466553",
"0.77466553",
"0.7550273",
"0.7445445",
"0.731... | 0.0 | -1 |
GET /travel_post_attachments GET /travel_post_attachments.json | def index
@travel_post_attachments = TravelPostAttachment.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attachments(*params)\n id = params[0]\n unnamed = params[1]\n if params[0].class == Hash\n params = params[0]\n id = params[:id] if params.has_key? :id\n unnamed = params[:unnamed] if params.has_key? :unnamed\n end\n unnamed = false if unnamed.to_s == \"0\"\n id = $~[1] if id =... | [
"0.6962016",
"0.6897482",
"0.6897482",
"0.6846863",
"0.6846863",
"0.6643332",
"0.6625789",
"0.6600498",
"0.6592622",
"0.65530795",
"0.651225",
"0.6508643",
"0.64891374",
"0.64748704",
"0.64602506",
"0.6403403",
"0.63906837",
"0.63817465",
"0.63083124",
"0.6305153",
"0.629655"... | 0.7795447 | 0 |
GET /travel_post_attachments/1 GET /travel_post_attachments/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @travel_post_attachments = TravelPostAttachment.all\n end",
"def attachments(*params)\n id = params[0]\n unnamed = params[1]\n if params[0].class == Hash\n params = params[0]\n id = params[:id] if params.has_key? :id\n unnamed = params[:unnamed] if params.has_key? :unnamed... | [
"0.7609042",
"0.695496",
"0.6801991",
"0.6801991",
"0.6800041",
"0.6800041",
"0.67055714",
"0.6698931",
"0.66976607",
"0.667029",
"0.6632176",
"0.6557675",
"0.65495396",
"0.6539018",
"0.65274376",
"0.64980006",
"0.6495039",
"0.6426665",
"0.6415616",
"0.63934064",
"0.63823295"... | 0.0 | -1 |
POST /travel_post_attachments POST /travel_post_attachments.json | def create
@travel_post_attachment = TravelPostAttachment.new(travel_post_attachment_params)
respond_to do |format|
if @travel_post_attachment.save
format.html { redirect_to @travel_post_attachment, notice: 'Travel post attachment was successfully created.' }
format.json { render :show, status: :created, location: @travel_post_attachment }
else
format.html { render :new }
format.json { render json: @travel_post_attachment.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n params[:travel_post][:user_id] = current_user.id\n @travel_post = TravelPost.new(travel_post_params)\n\n respond_to do |format|\n if @travel_post.save\n if params[:travel_post_attachments].present?\n params[:travel_post_attachments]['s3'].each do |a|\n @travel_... | [
"0.7243738",
"0.6646454",
"0.6643689",
"0.65935504",
"0.65217245",
"0.6514719",
"0.64900446",
"0.64096874",
"0.63962334",
"0.63491434",
"0.63106763",
"0.6249186",
"0.62110007",
"0.62037027",
"0.6193268",
"0.61640507",
"0.615221",
"0.6140468",
"0.60914975",
"0.60346574",
"0.60... | 0.7467945 | 0 |
PATCH/PUT /travel_post_attachments/1 PATCH/PUT /travel_post_attachments/1.json | def update
respond_to do |format|
if @travel_post_attachment.update(travel_post_attachment_params)
format.html { redirect_to @travel_post_attachment, notice: 'Travel post attachment was successfully updated.' }
format.json { render :show, status: :ok, location: @travel_post_attachment }
else
format.html { render :edit }
format.json { render json: @travel_post_attachment.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @attachments = args[:attachments] if args.key?(:attachments)\n end",
"def update!(**args)\n @attachments = args[:attachments] if args.key?(:attachments)\n end",
"def ti_update_attachment\n if !$attachment.nil?\n $attachment.destroy\n $att... | [
"0.67971176",
"0.67971176",
"0.67438585",
"0.67293555",
"0.664691",
"0.66395915",
"0.66106665",
"0.6581964",
"0.6564523",
"0.65625656",
"0.65428907",
"0.6439052",
"0.64334416",
"0.6418672",
"0.641044",
"0.63924295",
"0.6390427",
"0.6390427",
"0.6383916",
"0.6368262",
"0.63278... | 0.7289995 | 0 |
DELETE /travel_post_attachments/1 DELETE /travel_post_attachments/1.json | def destroy
@travel_post_attachment.destroy
respond_to do |format|
format.html { redirect_to travel_post_attachments_url, notice: 'Travel post attachment was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @post_attachment.destroy\n respond_to do |format|\n format.html { redirect_to post_attachments_url, notice: 'Post attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @attachments = Attachment.find_by_id(params[:id])\n i... | [
"0.7288231",
"0.7284772",
"0.7274887",
"0.7274887",
"0.7274887",
"0.72299373",
"0.7207676",
"0.7204235",
"0.71754205",
"0.71735144",
"0.71480757",
"0.70466816",
"0.70444685",
"0.6970511",
"0.6919693",
"0.69151074",
"0.6905139",
"0.6901768",
"0.6888986",
"0.68840176",
"0.68733... | 0.78208095 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_travel_post_attachment
@travel_post_attachment = TravelPostAttachment.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def travel_post_attachment_params
params.require(:travel_post_attachment).permit(:travel_post_id, :s3)
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.6981537",
"0.67835593",
"0.6748275",
"0.67436063",
"0.6736311",
"0.65937173",
"0.6503359",
"0.6498499",
"0.6482832",
"0.6478776",
"0.645703",
"0.6439998",
"0.63802195",
"0.6377008",
"0.6366287",
"0.632018",
"0.63016284",
"0.63011277",
"0.62932974",
"0.62919617",
"0.6290564... | 0.0 | -1 |
validates_attachment_presence :image validates_presence_of :html, :html_fr | def html(locale=:en)
if locale.to_sym == :en
read_attribute(:html)
else locale.to_sym == :fr
html_fr
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_images_alt_present\n errors.add('body', I18n.t('drgcms.img_alt_not_present')) unless DcPage.images_alt_present?(self.body)\nend",
"def validate_upload\n validate_image_length\n validate_image_type\n validate_image_md5sum\n validate_image_name\n end",
"def validates_as_attachment\n ... | [
"0.7272252",
"0.71813387",
"0.71045053",
"0.7053094",
"0.7037933",
"0.6936135",
"0.68478465",
"0.6747874",
"0.6746696",
"0.66941303",
"0.6636218",
"0.66200423",
"0.6615283",
"0.6527436",
"0.6501556",
"0.64962053",
"0.6494943",
"0.64875835",
"0.6445907",
"0.63553894",
"0.63523... | 0.0 | -1 |
Check each element in the list returns sorted list of executable files | def check_scripts(list)
list = list.select do |file|
next if File.directory? file
unless File.executable? file
@log.notice("=> Error: #{file} is not a valid executable.")
next
end
file
end
list.sort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_file_list_by_shared_libs(list, platform_name)\n # put binary files to bin list\n bin_list, dev_list = list.partition { |e| e =~ /(bin\\/.+)|(lib\\/.*\\.(so|so\\..+|dylib))/ }\n # add directories to bin list\n dirs = []\n bin_list.each do |f|\n ds = File.dirname(f).split('/')\n di... | [
"0.65908766",
"0.6327772",
"0.6263775",
"0.6200991",
"0.61730397",
"0.6162568",
"0.6162568",
"0.60488665",
"0.59918505",
"0.5913149",
"0.58860105",
"0.588096",
"0.58464926",
"0.5796713",
"0.5789534",
"0.5777544",
"0.5773178",
"0.5763482",
"0.5747896",
"0.5741246",
"0.57275134... | 0.7480085 | 0 |
Adds dutch zipcode filter to given attributes. | def filters_dutch_zipcode(*args)
create_filtered_accessor("filter_dutch_zipcode", args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zip_postal_code_field\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.input.id(\"/textZip$/\"), format_method(__method__))\n end",
"def zip_postal_code_field\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.input.className(create_ats_regex_strin... | [
"0.5842912",
"0.57563895",
"0.574289",
"0.5592229",
"0.5556706",
"0.55257684",
"0.5515004",
"0.5486897",
"0.5486099",
"0.5471945",
"0.5464982",
"0.54054826",
"0.54028034",
"0.53806484",
"0.5373877",
"0.5348046",
"0.5348046",
"0.5347725",
"0.5347725",
"0.5347725",
"0.5347725",... | 0.79378325 | 0 |
Adds dutch telephone number filter to given attributes. | def filters_dutch_telephonenumber(*args)
create_filtered_accessor("filter_dutch_telephonenumber", args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filters_dutch_zipcode(*args)\n create_filtered_accessor(\"filter_dutch_zipcode\", args)\n end",
"def phone_number_field\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.input.className(create_ats_regex_string(\"ats-phonefield\")), format_method(__method__))\n e... | [
"0.5373623",
"0.511367",
"0.5058994",
"0.5033166",
"0.4940693",
"0.48461208",
"0.48429477",
"0.48425186",
"0.4785255",
"0.47838923",
"0.47425747",
"0.47339216",
"0.47129056",
"0.46963137",
"0.46917102",
"0.46750605",
"0.46715835",
"0.46690843",
"0.46594816",
"0.465078",
"0.46... | 0.8063734 | 0 |
Adds dutch name filtering. Can be used for full person names or streetnames. | def filters_dutch_name(*args)
create_filtered_accessor("filter_dutch_name", args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_by_name\n @search = Search::ByName.new(\n term: params[:name],\n country: params[:country]\n ).call\n end",
"def named_filter; end",
"def search_filter(name)\n raise Puppet::DevError, \"No search string set for LDAP terminus for #{self.name}\"\n end",
"def filters_dutch_zipcod... | [
"0.63229334",
"0.5994047",
"0.5886457",
"0.58399206",
"0.57541597",
"0.5610188",
"0.5543335",
"0.55159444",
"0.53880024",
"0.53511673",
"0.5282308",
"0.5275656",
"0.5272598",
"0.5253963",
"0.5215984",
"0.51632655",
"0.51602054",
"0.5127988",
"0.5121125",
"0.51177627",
"0.5117... | 0.7889126 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_chofer
@chofer = Chofer.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def chofer_params
params.require(:chofer).permit(:nombre, :apodo, :estado_id, :fechaestado,
:credencial, :vtocarnet, :direccion, :telefono, :celular, :motivo_cambio_estado)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Takes an array of strings of integers and computes the sum | def squash(arr)
arr.map(&:to_i).reduce(:+) || 0 unless arr.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_array_numbers(array)\n result = array.sum\n # .sum cannot be used on a string, only integars and floats\n return result\nend",
"def arr_sum(array)\n\tnum_list = []\n\tarray.to_s.each_char do |char|\n\t\tp char\n\t\tif char.match(/[0-9]/) #== true\n\t\t\tnum_list << char\n\t\tend\n\tend\n\tsum = ... | [
"0.80592096",
"0.80293626",
"0.78457344",
"0.77329284",
"0.76926374",
"0.7677857",
"0.7676009",
"0.76448774",
"0.7619453",
"0.75584835",
"0.7520452",
"0.75203276",
"0.7504046",
"0.7503709",
"0.7490958",
"0.7480888",
"0.7458168",
"0.7458168",
"0.7442688",
"0.7442621",
"0.74414... | 0.0 | -1 |
Returns the number of matches two availability values contain | def availability_match(t1, t2)
(t1.to_i & t2.to_i).to_s(2).count('1')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def availability_summary #This should be changed to availability_summary_count\n unavailable = 0\n available = 0\n awaiting = 0\n\n self.cached_teamsheet_entries.each do |tse|\n if tse.response_status == 0\n unavailable += 1\n elsif tse.response_status == 1\n available += 1\n ... | [
"0.62480056",
"0.62093216",
"0.6171169",
"0.61703026",
"0.61315274",
"0.6042838",
"0.59956396",
"0.59673846",
"0.59605265",
"0.59357697",
"0.59342295",
"0.59267235",
"0.58752155",
"0.5781996",
"0.5760236",
"0.57453984",
"0.5721578",
"0.57019633",
"0.5661384",
"0.5654972",
"0.... | 0.82592964 | 0 |
Takes an integer and blows it up into an array of powers of 2 | def explode(int)
int.to_s(2)
.split('')
.reverse
.map.with_index { |v, i| 2**i * v.to_i }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def powersOfTwo(n)\n return (0..n).map {|x| 2**x}\nend",
"def powers_of_2\r\n\t\tunless $powers_of_2\r\n\t\t\t$powers_of_2 = [1]\r\n\t\t\t((BASE_BYTE << 3) - 1).times do |i|\r\n\t\t\t\t$powers_of_2[i + 1] = $powers_of_2[i] << 1\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\treturn $powers_of_2\r\n\tend",
"def powers_of_t... | [
"0.730188",
"0.728221",
"0.7173046",
"0.6968458",
"0.69261706",
"0.69261146",
"0.6685204",
"0.666783",
"0.66254526",
"0.6618877",
"0.6608273",
"0.6589289",
"0.65416354",
"0.6525966",
"0.65205175",
"0.64435405",
"0.64283466",
"0.6417436",
"0.641398",
"0.6404947",
"0.63762504",... | 0.6801842 | 6 |
Factory for DnsRecord with parameters for the StartofAuthority record. | def makeSoaRecord(cluster, ttl: Config::TTL_SOA)
return DnsRecord.new(name: cluster.nameservers()[0].dns_record(),
type: "SOA",
content: cluster.hostmasters()[0].dns_record(),
ttl: ttl)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeARecord(machine, ttl: Config::TTL_A_RECORD)\n return DnsRecord.new(name: machine.dns_record(),\n type: \"A\",\n content: machine.static_ip(),\n ttl: ttl)\nend",
"def create_record(fqdn, type, ipdata)\n unless @dnss.is_valid?\n ... | [
"0.62050074",
"0.5757412",
"0.57481563",
"0.56712645",
"0.54862064",
"0.5474475",
"0.54620564",
"0.5356815",
"0.53127295",
"0.5286323",
"0.5269497",
"0.52380925",
"0.5202059",
"0.5176227",
"0.5116998",
"0.5102343",
"0.5091611",
"0.50823367",
"0.5065706",
"0.50597066",
"0.5051... | 0.6125036 | 1 |
Factory for DnsRecord with parameters for singleIP Arecords. | def makeARecord(machine, ttl: Config::TTL_A_RECORD)
return DnsRecord.new(name: machine.dns_record(),
type: "A",
content: machine.static_ip(),
ttl: ttl)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_single_dns_record(app_name,\n stack_name,\n zone_name,\n record_name,\n ttl: 300,\n type: 'A',\n hea... | [
"0.65205586",
"0.63625896",
"0.62730104",
"0.5660041",
"0.56253004",
"0.5489906",
"0.54817104",
"0.5428496",
"0.5426296",
"0.54257286",
"0.54069036",
"0.54032445",
"0.5401006",
"0.53173184",
"0.5301888",
"0.5285504",
"0.52828586",
"0.52671427",
"0.51629454",
"0.5136325",
"0.5... | 0.69958085 | 0 |
Factory for DnsRecord with parameters for multiIP Arecords. | def makeARecordGroup(name, machines, ttl: Config::TTL_A_RECORD)
return DnsRecord.new(name: name,
type: "A",
content: machines.map(&:static_ip).join(","),
ttl: ttl)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeARecord(machine, ttl: Config::TTL_A_RECORD)\n return DnsRecord.new(name: machine.dns_record(),\n type: \"A\",\n content: machine.static_ip(),\n ttl: ttl)\nend",
"def create_multiple_dns_records\n fail('method \"create_multiple_dns_... | [
"0.6540745",
"0.6495308",
"0.6098601",
"0.60543686",
"0.53734875",
"0.5352998",
"0.53500855",
"0.5307098",
"0.5296333",
"0.5274852",
"0.52448064",
"0.51609683",
"0.51240635",
"0.5113269",
"0.5106135",
"0.50982976",
"0.5083008",
"0.5011461",
"0.49634638",
"0.4942654",
"0.49379... | 0.67962044 | 0 |
Invert the machine>[group] collection to group>[machine]. | def machinesByGroup()
# Create machine hash.
machines_by_group = @machines.map() { |machine|
Hash[machine.groups().map() { |group| [group, machine.name()] }]
}
# Insert machines into each group list.
machines_by_group.each_with_object({}) do |group_to_name, output|
group_to_name.each() do |group, name|
(output[group] ||= []) << name
end
end
return machines_by_group
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inverse_all(collection)\r\n newcollection = collection.dup.clear\r\n collection.each do |point|\r\n newcollection << inverse(point)\r\n end\r\n newcollection\r\n end",
"def inverse_all!(collection)\r\n collection.each do |point|\r\n... | [
"0.5758476",
"0.5562348",
"0.5524538",
"0.5302074",
"0.5294733",
"0.52106625",
"0.5149166",
"0.51171654",
"0.51046836",
"0.50909835",
"0.5043126",
"0.49908215",
"0.49899295",
"0.4986074",
"0.49582216",
"0.4941234",
"0.4924962",
"0.4910152",
"0.48987198",
"0.4892241",
"0.48904... | 0.46748555 | 44 |
POST recieve uploaded data to create asset | def complete_upload_image
@dom_id = "##{params[:photo][:dom_id]}"
@asset = Image.new(uploaded_asset_attributes.reverse_merge(uploaded_by: current_user))
@asset.add_meta(params[:photo])
@asset.save
render template: "/dash/chooser/complete_upload"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n repo = assets_repo\n\n file = (params.has_key?(:file)) ? params[:file] : false\n @v_asset = repo.create file\n\n respond_to do |format|\n if @v_asset.save\n format.html { redirect_to @v_asset, notice: 'V asset was successfully created.' }\n format.json { render json: @v_... | [
"0.70753896",
"0.70294785",
"0.70206976",
"0.6989416",
"0.6946804",
"0.69080067",
"0.68728954",
"0.68452513",
"0.68068683",
"0.6798605",
"0.67523414",
"0.6732975",
"0.67043954",
"0.6661568",
"0.66361463",
"0.66328007",
"0.66317326",
"0.66317326",
"0.6618943",
"0.6611074",
"0.... | 0.6226052 | 78 |
POST recieve uploaded data to create asset | def complete_upload_document
@dom_id = "##{params[:file][:dom_id]}"
@asset = Document.new(uploaded_asset_attributes.reverse_merge(uploaded_by: current_user))
key = @asset.add_meta(params[:file])
if @asset.save
@asset.update_columns(media: key)
end
render template: "/dash/chooser/complete_upload"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n repo = assets_repo\n\n file = (params.has_key?(:file)) ? params[:file] : false\n @v_asset = repo.create file\n\n respond_to do |format|\n if @v_asset.save\n format.html { redirect_to @v_asset, notice: 'V asset was successfully created.' }\n format.json { render json: @v_... | [
"0.7075417",
"0.7029826",
"0.7020778",
"0.6989374",
"0.6946651",
"0.6907879",
"0.68713355",
"0.68437207",
"0.68071383",
"0.6797314",
"0.67507046",
"0.67329377",
"0.6703564",
"0.6660208",
"0.6636403",
"0.66333985",
"0.66305333",
"0.66305333",
"0.6618205",
"0.66088",
"0.6598035... | 0.0 | -1 |
GET Upload document screen | def upload_document
render template: "/dash/chooser/upload_document"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload\n create_document\n \n render_upload\n end",
"def index\n @title = \"User uploaded files\"\n get_files(params)\n end",
"def show\n send_data(@document.file_content,\n type: @document.content_type,\n filename: @document.filename)\n end",
"def show\n ... | [
"0.7377686",
"0.6846305",
"0.6729821",
"0.67227674",
"0.67124104",
"0.66422486",
"0.66286504",
"0.66286504",
"0.6602241",
"0.6601983",
"0.6529",
"0.63975763",
"0.6387933",
"0.6350712",
"0.63486123",
"0.6339402",
"0.63289386",
"0.63206553",
"0.6318163",
"0.6293653",
"0.6271694... | 0.69793004 | 1 |
GET Upload image screen | def upload_image
render template: "/dash/chooser/upload_image"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_url\n return unless @data['image']\n # Isn't actually displayed in-app without this set\n return unless image['property'] == 'image'\n file(@data['image'])\n end",
"def upload\n end",
"def upload\n end",
"def upload\r\n \r\n end",
"def upload_img\n resul... | [
"0.72090393",
"0.6713342",
"0.6713342",
"0.6681566",
"0.6558098",
"0.65450823",
"0.6537675",
"0.6514277",
"0.64915305",
"0.64872634",
"0.64872634",
"0.64727116",
"0.6442029",
"0.64363635",
"0.64363635",
"0.6429434",
"0.6416752",
"0.64141047",
"0.6383521",
"0.63829",
"0.634601... | 0.6695967 | 3 |
GET Uploaded documents accessible to user | def documents
@assets = filtered_assets.where(type: "Document").order("created_at DESC").paginate(params)
@assets = @assets.search(params[:q], fuzzy: true) if params[:q].present?
respond_to do |format|
format.html do
render template: "/dash/chooser/documents"
end
format.js do
render template: "/dash/chooser/documents_search"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @title = \"User uploaded files\"\n get_files(params)\n end",
"def list_of_allowed_documents\n @client.make_request :get, profile_path\n end",
"def index\n #@document = current_user.documents.find(params[:document_id]) \n @document_photos = @document.document_photos\n end",
... | [
"0.7145653",
"0.69221306",
"0.69150966",
"0.6870118",
"0.6864632",
"0.67361826",
"0.6654241",
"0.6627551",
"0.6553356",
"0.65305257",
"0.65305257",
"0.6528492",
"0.6502118",
"0.64494246",
"0.6448986",
"0.6440549",
"0.64112043",
"0.6408447",
"0.63741565",
"0.6365998",
"0.63632... | 0.5839314 | 93 |
GET Uploaded images accessible to user | def images
@assets = filtered_assets.where(type: "Image").order("created_at DESC").paginate(params)
@assets = @assets.search(params[:q], fuzzy: true) if params[:q].present?
respond_to do |format|
format.html do
render template: "/dash/chooser/images"
end
format.js do
render template: "/dash/chooser/images_search"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def images() \n uri = URI.parse(\"http://\" + @location.host + \":9292/v2/images\")\n return get_request(uri, @token)\n end",
"def images\n end",
"def images\n if @group.is_member?(@user)\n @images = @group.uploads.images.paginate(:page => @page, :per_page => @per_page, :order => 'created... | [
"0.7138144",
"0.69989717",
"0.69926775",
"0.6948251",
"0.68320477",
"0.6790681",
"0.6782597",
"0.6770848",
"0.6762242",
"0.67534244",
"0.6702328",
"0.6691122",
"0.6627288",
"0.66065305",
"0.65964115",
"0.6584066",
"0.65512854",
"0.65486366",
"0.6548617",
"0.6544843",
"0.65164... | 0.601966 | 98 |
It is often the case that we need spaces before and after an atom. | def spaced(atom)
space? >> atom >> space?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indent_atom; \" \"; end",
"def standard_gap\n \" \"\n end",
"def spaces; end",
"def spaces; end",
"def scan_for_space(token); end",
"def space!\r\n # -> uncomment the next line to manually enable rule tracing\r\n # trace_in( __method__, 3 )\r\n\r\n type = SPACE\r\n ch... | [
"0.7093097",
"0.6313484",
"0.6259048",
"0.6259048",
"0.6117792",
"0.605786",
"0.6010417",
"0.5986214",
"0.5922752",
"0.5861822",
"0.58571976",
"0.5838459",
"0.5836727",
"0.5820447",
"0.58202696",
"0.57941896",
"0.57344574",
"0.57303846",
"0.5729524",
"0.57202005",
"0.5706928"... | 0.72603 | 0 |
braced(atom1 >> atom 2) reads better than lbrace >> atom 1 >> atom2 >> brace in most situations. | def braced(atom)
lbrace >> atom >> rbrace
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_braced_word(input)\n input.consume\n result = \"\"\n while not input.eof? do\n c = input.look_ahead\n case c\n when \"}\" : input.consume; return result\n when \"{\" :\n result += rebrace(parse_braced_word(input))\n input.consume -1 # ... | [
"0.5608257",
"0.55360895",
"0.527669",
"0.50604624",
"0.49924934",
"0.4984146",
"0.49760792",
"0.49760792",
"0.49760792",
"0.48877737",
"0.47847593",
"0.47630098",
"0.47391334",
"0.46184665",
"0.46119967",
"0.45921314",
"0.45916477",
"0.45789564",
"0.4525352",
"0.44946122",
"... | 0.75551015 | 0 |
braced(atom1 >> atom 2) reads better than lbrace >> atom 1 >> atom2 >> brace in most situations. | def square_bracketed(atom)
lsquare >> atom >> rsquare
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def braced(atom)\n lbrace >> atom >> rbrace\n end",
"def parse_braced_word(input)\n input.consume\n result = \"\"\n while not input.eof? do\n c = input.look_ahead\n case c\n when \"}\" : input.consume; return result\n when \"{\" :\n result += ... | [
"0.75560373",
"0.5608842",
"0.5277707",
"0.5059736",
"0.49928242",
"0.49833158",
"0.49766147",
"0.49766147",
"0.49766147",
"0.48882356",
"0.47829428",
"0.4762123",
"0.47380665",
"0.46195778",
"0.4610713",
"0.45926467",
"0.4592625",
"0.45791477",
"0.45251766",
"0.449458",
"0.4... | 0.55366534 | 2 |
Remembers a user in a persistent session. | def remember(doctor)
doctor.remember
cookies.permanent.signed[:doctor_id] = doctor.id
cookies.permanent[:remember_token] = doctor.remember_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_user\n return unless exists?(:previous_user)\n set :user, fetch(:previous_user)\n unset :previous_user\n clear_sessions\n end",
"def change_password\n @user = User.find_by_id(session[:remember_token])\n end",
"def log_in_user!(user)\n session[:session_token] = ... | [
"0.67565674",
"0.6643994",
"0.631177",
"0.631177",
"0.628238",
"0.6236517",
"0.6200707",
"0.6200707",
"0.61804515",
"0.6180446",
"0.6169273",
"0.61579806",
"0.613876",
"0.61255866",
"0.6119817",
"0.60908014",
"0.6069442",
"0.60635865",
"0.6060934",
"0.6051993",
"0.60496104",
... | 0.0 | -1 |
Returns true if the given user is the current user. | def current_doctor?(doctor)
doctor == current_doctor
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_current_user(user)\n if user == current_user\n return true\n else\n return false\n end\n end",
"def is_current_user(user)\n logged_in? && @current_user.id == user.id\n end",
"def current_user?(user)\n\t\tcurrent_user == user\n\tend",
"def current_user?(user)\n\t\tuser == cu... | [
"0.9062532",
"0.8867281",
"0.8851428",
"0.881641",
"0.881641",
"0.881641",
"0.881641",
"0.881641",
"0.881641",
"0.881641",
"0.881641",
"0.881641",
"0.881641",
"0.8816007",
"0.87907284",
"0.8765191",
"0.8765191",
"0.8765191",
"0.8765191",
"0.8765191",
"0.8765191",
"0.8765191... | 0.0 | -1 |
Returns the current loggedin user (if any). | def current_doctor
if (doctor_id = session[:doctor_id])
@current_doctor ||= Doctor.find_by(id: doctor_id)
elsif (doctor_id = cookies.signed[:doctor_id])
doctor = Doctor.find_by(id: doctor_id)
if doctor && doctor.authenticated?(:remember, cookies[:remember_token])
log_in doctor
@current_doctor = doctor
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user\n if session[:user_id]\n return User.find(session[:id])\n else\n return nil\n end\n end",
"def current_user\n if session[:user_id]\n User.find(session[:user_id])\n else\n nil\n end\n end",
"def current_user\n return unless session[:user_id... | [
"0.85960984",
"0.8593657",
"0.855797",
"0.8545853",
"0.8534344",
"0.8497545",
"0.847914",
"0.8460573",
"0.8457271",
"0.84556973",
"0.84472865",
"0.8442264",
"0.8441092",
"0.84366953",
"0.8400402",
"0.83765614",
"0.8368829",
"0.8337418",
"0.8337418",
"0.8314651",
"0.8311652",
... | 0.0 | -1 |
Returns true if the user is logged in, false otherwise. | def logged_in?
!current_doctor.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end",
"def logged_in?\n user._logged_in?\n end",
"def logged_in?\n if session[:username]\n if session[:logged_in?]\n return true\n end\n else\n r... | [
"0.9082417",
"0.8764097",
"0.87552106",
"0.8718715",
"0.86894006",
"0.86498255",
"0.86469626",
"0.86372185",
"0.8631328",
"0.86285406",
"0.86285406",
"0.8582609",
"0.85669243",
"0.85613596",
"0.85613596",
"0.8551865",
"0.85491496",
"0.85443276",
"0.85409296",
"0.8539988",
"0.... | 0.0 | -1 |
Forgets a persistent session. | def forget(doctor)
doctor.forget
cookies.delete(:doctor_id)
cookies.delete(:remember_token)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_session!\n raw_session.clear\n end",
"def abandon!\n @user = nil\n session.delete\n end",
"def abandon!\n @user = nil\n session.delete\n end",
"def abandon!\n @user = nil\n session.clear\n end",
"def invalidate_session\n @sequence = 0\n ... | [
"0.7147796",
"0.70562965",
"0.70562965",
"0.703171",
"0.69756675",
"0.68041205",
"0.66663957",
"0.65868694",
"0.65860564",
"0.658252",
"0.658252",
"0.6543507",
"0.64270866",
"0.64270866",
"0.63905734",
"0.6363112",
"0.63412905",
"0.6313454",
"0.6311529",
"0.6259062",
"0.62550... | 0.0 | -1 |
Logs out the current user. | def log_out
forget(current_doctor)
session.delete(:doctor_id)
@current_doctor = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_out\n reset_session\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user ... | [
"0.85847217",
"0.8553567",
"0.8553567",
"0.8553567",
"0.8553567",
"0.8553567",
"0.85448325",
"0.85448325",
"0.85448325",
"0.85448325",
"0.85447145",
"0.8513818",
"0.85132295",
"0.85004026",
"0.8490199",
"0.84505224",
"0.84501094",
"0.84357476",
"0.843385",
"0.843385",
"0.8433... | 0.0 | -1 |
Redirects to stored location (or to the default). | def redirect_back_or(default)
redirect_to(session[:forwarding_url] || default)
session.delete(:forwarding_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirect_to_stored(default='/')\n return_to = session[:return_to] || default\n session[:return_to] = nil\n redirect return_to\n end",
"def redirect_to_stored_location_or(default)\n redirect_to(session[:forward_url] || default)\n session.delete(:forward_url)\n end",
"def redirect_ba... | [
"0.7730111",
"0.7649159",
"0.704684",
"0.7029194",
"0.6981081",
"0.6871779",
"0.67809576",
"0.67569697",
"0.6699827",
"0.65908873",
"0.6580519",
"0.65731466",
"0.65681744",
"0.6567211",
"0.654002",
"0.653624",
"0.6530604",
"0.65075284",
"0.64961356",
"0.64893895",
"0.6443822"... | 0.0 | -1 |
Stores the URL trying to be accessed. | def store_location
session[:forwarding_url] = request.original_url if request.get?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_location\n session[:forwarding_url] = request.url if request.get?\n # Makes sure that the URL is saved only for a GET request because submitting\n # DELETE, PATCH or POST will raise errors when the URL is expecting\n # a GET request.\n end",
"def store_location\n # store last url as lon... | [
"0.69116175",
"0.6895489",
"0.6884959",
"0.6784313",
"0.6784313",
"0.6784313",
"0.6784313",
"0.6784313",
"0.6784313",
"0.6694612",
"0.66793954",
"0.6637457",
"0.6633661",
"0.66288584",
"0.6592983",
"0.6592983",
"0.6592983",
"0.6592983",
"0.6591829",
"0.6568926",
"0.6557964",
... | 0.0 | -1 |
Create Renderer object, while storing and autoexpanding params. | def initialize(template_string, options = {})
self.template = template_string
self.render_opts = if options[:blank]
{}
else
{ strict_variables: true }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(readRenderer, writeRenderer); @r = readRenderer; @w = writeRenderer end",
"def renderer r\n @renderer = r\n end",
"def renderer r\n @renderer = r\n end",
"def render opts = {}\n renderer.render opts\n end",
"def initialize(opts={})\n super RENDERER_CONFIG.merge opt... | [
"0.60914564",
"0.58979374",
"0.58979374",
"0.57752925",
"0.5770803",
"0.57525146",
"0.5738523",
"0.5678784",
"0.55729115",
"0.55514693",
"0.555095",
"0.5517902",
"0.543799",
"0.5419093",
"0.54158276",
"0.5405402",
"0.5395797",
"0.53925127",
"0.53654677",
"0.53409857",
"0.5336... | 0.0 | -1 |
Render given content using expanded params. | def render(params)
attributes = expand_arguments(Hashie.stringify_keys(params.to_h))
liquid_template = Liquid::Template.parse(template)
liquid_template.render(attributes, **render_opts).tap do
unless liquid_template.errors.empty?
raise LiquidTemplateError, "#{liquid_template.errors.map(&:message).join("\n")}"
end
end.gsub(/\n/, ' ').gsub(/\s{2,}/, ' ').strip
rescue ArgumentError => e
raise UnresolvedReferenceError.new(e)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render *args\n @content\n end",
"def render\n content\n end",
"def render\n content\n end",
"def render\n content\n end",
"def render\n content\n end",
"def render_tilt_in_context(ext, content, params={})\n context = ClosedStruct.new(params)\n context.extend(TiltHelp... | [
"0.6762337",
"0.64186317",
"0.64038885",
"0.64038885",
"0.64038885",
"0.6374741",
"0.6304433",
"0.62028253",
"0.62028253",
"0.6147886",
"0.6128065",
"0.60916626",
"0.6085663",
"0.6063959",
"0.60323113",
"0.5984489",
"0.59286773",
"0.5927354",
"0.58979404",
"0.588448",
"0.5880... | 0.0 | -1 |
Public: Returns extended information for a given device identified from its ID. id A String that represent the device ID. Returns Hashie The device. | def device_privates(id)
get("/devices/#{id}/privates")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(id)\n json = JSON.parse(http_client.get(\"mobiledevices/id/#{id}\"))\n MobileDevice.new(json.fetch(\"mobile_device\"))\n end",
"def get_device_code(id:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::GET,\n '/v2/devices/... | [
"0.6278499",
"0.5899005",
"0.5824389",
"0.5727963",
"0.57188344",
"0.56966084",
"0.5670527",
"0.56032974",
"0.5601152",
"0.55646217",
"0.55534625",
"0.55066746",
"0.5500693",
"0.549808",
"0.54604983",
"0.5454261",
"0.5454261",
"0.5454261",
"0.5454261",
"0.5426392",
"0.5423821... | 0.0 | -1 |
Public: Delete a device identified from its ID and returns extended information for it. id A String that represent the device ID. Returns Hashie The deleted device. | def delete_device(id)
delete("/devices/#{id}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_delete_with_http_info(device_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DevicesApi.device_delete ...'\n end\n # verify the required parameter 'device_id' is set\n if @api_client.config.client_side_validation && device_id.ni... | [
"0.706696",
"0.6747773",
"0.6450358",
"0.6395359",
"0.63531953",
"0.63499826",
"0.62946147",
"0.62417734",
"0.621277",
"0.61616445",
"0.6144659",
"0.60925066",
"0.6089806",
"0.6061808",
"0.60470915",
"0.6034126",
"0.59911007",
"0.59642756",
"0.59541017",
"0.59401846",
"0.5924... | 0.7385459 | 0 |
Public: Execute a function on a device identified from its ID and returns extended information for it. id A String that represent the device ID. params An Hash containing the function to execute and the device properties. Returns Hashie The device with the updated properties. | def execute(id, params={})
put("/devices/#{id}/functions", params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def function(id)\n case id\n when :base64\n Function::Base64\n when :join\n Function::Join\n when :if\n Function::If\n when :equals\n Function::Equals\n when :get_azs\n Function::GetAZs\n else\n raise ReferenceMissing.new(\"Invalid functi... | [
"0.5747767",
"0.54404277",
"0.5407123",
"0.52345455",
"0.51987773",
"0.5131614",
"0.5122811",
"0.5095572",
"0.5049419",
"0.50119597",
"0.4925688",
"0.48915923",
"0.4872124",
"0.47440344",
"0.47178397",
"0.4694589",
"0.4691115",
"0.4680102",
"0.46707568",
"0.46684727",
"0.4664... | 0.76885515 | 0 |
Public: Update properties on a device identified from its ID and returns extended information for it. id A String that represent the device ID. params An Hash containing the device properties. Returns Hashie The device with the updated properties. | def device_properties(id, params={})
put("/devices/#{id}/properties", params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_server_properties_with_http_info(did, device_properties, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DevicesManagementApi.update_server_properties ...\"\n end\n # verify the required parameter 'did' is set\n fail ArgumentError,... | [
"0.6242649",
"0.6184496",
"0.603213",
"0.599857",
"0.5963922",
"0.58891016",
"0.58891016",
"0.58825207",
"0.58167803",
"0.58167803",
"0.58167803",
"0.58167803",
"0.5797679",
"0.5726552",
"0.5686001",
"0.56814885",
"0.56804687",
"0.5652119",
"0.5613045",
"0.5586968",
"0.556869... | 0.7788911 | 0 |
Public: Activate a device and returns extended information for it. params A Hash containing the activation code. Returns Hashie The activated device. | def activate_device(params = {})
post('/activations', params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activate\n session.user = Merb::Authentication.user_class.find_with_activation_code(params[:activation_code])\n raise NotFound if session.user.nil?\n if session.authenticated? && !session.user.activated?\n session.user.activate!\n end\n \"\"\n end",
"def activate\n begin\n ... | [
"0.6003664",
"0.5730158",
"0.5728515",
"0.5728515",
"0.5728515",
"0.5700083",
"0.56749636",
"0.5642045",
"0.5606151",
"0.5478555",
"0.545605",
"0.54168123",
"0.54168123",
"0.54168123",
"0.54168123",
"0.54168123",
"0.54168123",
"0.54168123",
"0.54168123",
"0.54168123",
"0.5416... | 0.7771004 | 0 |
Public: Deactivate a device and returns extended information for it. activation_code A String that represents the activation_code. Returns Hashie The activated device. | def deactivate_device(activation_code)
delete("/activations/#{activation_code}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deactivate\n self.activation_code = 'DEACTIVATED'\n self.activated_at = nil\n end",
"def activation_code\n read_attribute(:activation_code) || reset_activation_code\n end",
"def deactivate(location_ext_key)\n debug(\"deactivate: #{location_ext_key}\")\n response = set_state(:deactivati... | [
"0.6384083",
"0.5801538",
"0.5521776",
"0.54925734",
"0.54872817",
"0.5380636",
"0.53296447",
"0.511751",
"0.5075956",
"0.5050942",
"0.4984423",
"0.49116826",
"0.49060392",
"0.48689207",
"0.48593888",
"0.4854213",
"0.48426405",
"0.48327956",
"0.48092848",
"0.48037478",
"0.479... | 0.8299589 | 0 |
after_create :on_bet_create around_update :around_bet_update def completed? Time.now > self.end_time ? true : false end def winner User.find(self.winner_id) end def loser if self.winner == self.friend self.user elsif self.winner self.friend else nil end end final point in time to accept the bet | def accept_deadline
start_time + ((end_time - start_time) * 0.1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n \t@bet = Bet.find(params[:bet_id])\n @winner = @bet.build_winner(winner_params)\n\n respond_to do |format|\n if @winner.save\n @bet.participations.each do |participation|\n if participation.choice == @winner.choice\n user = participation.user\n winning... | [
"0.71285564",
"0.6755693",
"0.6734272",
"0.66120464",
"0.6567798",
"0.65598863",
"0.638913",
"0.6358502",
"0.63567656",
"0.63104457",
"0.6302529",
"0.62972736",
"0.6289805",
"0.62076974",
"0.6151526",
"0.6140209",
"0.6140209",
"0.61268246",
"0.6115427",
"0.6111002",
"0.60376"... | 0.0 | -1 |
How many seconds are left to accept the bet | def time_to_accept
if Time.now > accept_deadline
0
else
accept_deadline - Time.now
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seconds_for_expedition\n possible_votes / 3 + 1\n end",
"def time_remaining\n end",
"def total_wait\n if cart.delivers\n if !cart.delivery_duration.blank?\n response = estimated_wait + cart.delivery_duration\n else\n response = estimated_wait + 20\n end\n else\n ... | [
"0.6983559",
"0.69120264",
"0.68995386",
"0.6872759",
"0.68473625",
"0.68096256",
"0.67486846",
"0.6734145",
"0.67326224",
"0.66330785",
"0.6587274",
"0.6536331",
"0.65294",
"0.6495829",
"0.6470923",
"0.64665645",
"0.6451815",
"0.6447557",
"0.64304304",
"0.63942593",
"0.63688... | 0.62980086 | 30 |
1. Let's write a method that prints out all the operators that exist in the tree. | def print_operators(node)
return if node == nil
print_operators(node.left) #starts recursion -- go left
if node.value.match(/\+|\-|\/|\%|\*/) #if operators included
print node.value + " " #print value of this node
end
print_operators(node.right) #recursion -- go right
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def operators(node)\n return if node == nil\n operators(node.left)\n if node.left != nil || node.right != nil\n print node.value + \" \"\n end\n operators(node.right)\nend",
"def operator_found(node, operator)\n return if node.nil?\n operator_found(node.left, operator)\n if !node.left.nil? || !node.left.... | [
"0.7498937",
"0.7153019",
"0.69883794",
"0.68657106",
"0.64857966",
"0.6437885",
"0.64306784",
"0.64034855",
"0.6377589",
"0.6376467",
"0.632214",
"0.6314827",
"0.6285554",
"0.62746894",
"0.62704957",
"0.6193964",
"0.6139754",
"0.6079628",
"0.59661967",
"0.5960549",
"0.594948... | 0.80119437 | 0 |
2. Write a method that returns the count of nonoperators (in this case, leaves) in the tree. | def print_non_operators(node)
return if node == nil
count_non_operators = 0
print_non_operators(node.left) #starts recursion -- go left
if node.value.match(/\d/) #if digits included
count_non_operators += 1
print node.value + " " #print value of this node
# print node.count
end
print_non_operators(node.right)#go right
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leaves(node)\n return 1 if /\\d+/.match(node.value)\n return (leaves(node.left) + leaves(node.right))\nend",
"def count_leaf_nodes(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_leaves = count_leaf_nodes(node.left_child)\n right... | [
"0.71677995",
"0.6906429",
"0.6696718",
"0.6619414",
"0.66083795",
"0.66016567",
"0.6597483",
"0.65328497",
"0.6360591",
"0.6296883",
"0.62443304",
"0.6239934",
"0.6179853",
"0.6157823",
"0.61504835",
"0.6101183",
"0.6018804",
"0.6004885",
"0.59771204",
"0.5931908",
"0.593025... | 0.7666825 | 0 |
3. Write methods to print the tree in prefix evaluates parent, then left, then right | def print_prefix(node)
return if node == nil
print node.value + " " #print contents of this node
print_prefix(node.left) #starts recursion -- go left
print_prefix(node.right) #go right
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_tree(tree)\n return \"-\" if tree.nil?\n puts \"#{tree.value}: \"\n print \"Left: \"\n puts \"#{print_tree(tree.children[0])}\"\n print \"Right: \"\n puts \"#{print_tree(tree.children[1])}\"\nend",
"def print_prefix(node)\n return if node.nil?\n print node.value + \" \"\n print_prefix(no... | [
"0.79165727",
"0.7536757",
"0.73575276",
"0.7350741",
"0.7350741",
"0.7307997",
"0.7307784",
"0.73027277",
"0.7264071",
"0.72597474",
"0.7231999",
"0.7225007",
"0.7180558",
"0.7175897",
"0.7169322",
"0.7158379",
"0.7157039",
"0.7045408",
"0.69790924",
"0.69536763",
"0.692792"... | 0.7629249 | 1 |
and postfix notations evaluates leaves from left, then right then parent | def print_postfix(node)
return if node == nil
print_postfix(node.left) #starts recursion -- go left
print_postfix(node.right) #go right
print node.value + " " #print contents of this node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postfix_conditional?(node); end",
"def print_postfix(node)\n return if node.nil?\n print_postfix(node.left)\n print_postfix(node.right)\n print node.value + \" \"\nend",
"def postorder(node)\n return if !node\n postorder(node.left_child)\n postorder(node.right_child)\n print node.value, \" ... | [
"0.69579077",
"0.64652264",
"0.6210294",
"0.6202911",
"0.6091456",
"0.608806",
"0.6070906",
"0.59679544",
"0.59643894",
"0.5953655",
"0.5896759",
"0.5889508",
"0.5832433",
"0.5832433",
"0.5832433",
"0.5819245",
"0.5801826",
"0.5799387",
"0.5794518",
"0.5790713",
"0.5790713",
... | 0.63869965 | 2 |
Write a method that returns whether or not a given operator exists in the tree. | def operator?(node, operator)
return if node == nil
operator?(node.left, operator) #starts recursion -- go left
if node.value.match(/\+|\-|\/|\%|\*/) && (node.value == operator.value) #if operators included
return true #true
end
operator?(node.right, operator) #recursion -- go right
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_operator?(operator)\n ops = operators\n foreigns.each do |f|\n foreign_dataset = self.class.dataset_from f\n if foreign_dataset\n ops.concat foreign_dataset.operators\n end\n end\n ops.include? operator\n end",
"def operator_found(nod... | [
"0.73924893",
"0.73590577",
"0.7309548",
"0.73080224",
"0.7211797",
"0.70572585",
"0.70470953",
"0.69723594",
"0.6940019",
"0.69350743",
"0.6931738",
"0.6931738",
"0.6681131",
"0.6663418",
"0.65802056",
"0.6549971",
"0.6541842",
"0.63167214",
"0.6246766",
"0.6244898",
"0.6238... | 0.7754181 | 0 |
Relay always fetches id so we mock this method out | def id
#NOOP
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def real_id\n @id\n end",
"def real_id\n @id\n end",
"def get_id\n @id\n end",
"def get_id\n @id\n end",
"def get_id\n @id\n end",
"def get_id\n @id\n end",
"def perform\n @id = client._retrieve(@options).id\n super\n end",
"def get_id()\n @id\n end",
"def g... | [
"0.64126515",
"0.64126515",
"0.62054175",
"0.62054175",
"0.62054175",
"0.62054175",
"0.6152018",
"0.61503196",
"0.61503196",
"0.60684925",
"0.5943427",
"0.58714443",
"0.5852645",
"0.5846793",
"0.5831746",
"0.57920074",
"0.57737875",
"0.5770373",
"0.574445",
"0.57348716",
"0.5... | 0.60174286 | 10 |
Convert Celsius to Fahrenheit | def ctof(celsius)
(celsius * 9/5.to_f) + 32
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def celsius_to_fahrenheit(temp)\n temp.to_f * 9/5 + 32\nend",
"def toCelsius(fahrenheit)\n return ((fahrenheit-32)*5.0/9.0).round\nend",
"def toCelsius(fahrenheit)\n return ((fahrenheit-32)*5.0/9.0).round\nend",
"def celsius_to_fahrenheit(celsius)\n (celsius.to_f * 9) / 5 + 32\nend",
"def convert_to_ce... | [
"0.8615795",
"0.8563028",
"0.8562177",
"0.85165095",
"0.8501501",
"0.849064",
"0.8444348",
"0.8375178",
"0.83190256",
"0.8316262",
"0.8315495",
"0.831419",
"0.828554",
"0.828039",
"0.8263582",
"0.8241819",
"0.8223092",
"0.82101804",
"0.820134",
"0.8200943",
"0.8200943",
"0.... | 0.744593 | 66 |
Define a composite element within this block, using a subblock for the subelements | def composite(*args, &block)
subelements = SegmentBodyDSL.new(&block).elements
add_element(Builder::Element(*(args + subelements)))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(composite_parent, opts = {}, &blk)\n @container = Swt::Widgets::Composite.new(composite_parent, Swt::SWT::NONE || Swt::SWT::BORDER)\n\n width, height = opts['width'] || DEFAULT_WIDTH, opts['height'] || DEFAULT_HEIGHT\n\n # RowLayout is horizontal by default, wrapping by default\... | [
"0.60163134",
"0.593982",
"0.57326734",
"0.5681709",
"0.5601466",
"0.5577559",
"0.5570554",
"0.5523915",
"0.5490617",
"0.5466417",
"0.54617035",
"0.5422767",
"0.5417158",
"0.5387058",
"0.5360209",
"0.5314207",
"0.5295693",
"0.5295693",
"0.5294494",
"0.5289574",
"0.524306",
... | 0.7664633 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.