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 |
|---|---|---|---|---|---|---|
Description Deletes definitively an element. found: removes the element and reloads the whole page compact: removes the element and reloads the whole page expanded: removes the element and reloads the whole page Mode Json Specific filters ApplicationControllerinitialize_media_element_with_owner ApplicationControllerinitialize_media_element_destination | def destroy
if @ok
if !@media_element.check_and_destroy
@ok = false
@error = @media_element.get_base_error
end
else
@error = I18n.t('activerecord.errors.models.media_element.problem_destroying')
end
render :json => {:ok => @ok, :msg => @error}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove\n @ok_msg = t('other_popup_messages.correct.remove.media_element')\n if @ok\n bookmark = Bookmark.where(:user_id => current_user.id, :bookmarkable_type => 'MediaElement', :bookmarkable_id => @media_element_id).first\n if bookmark.nil?\n @ok = false\n @error = I18n.t('active... | [
"0.6986065",
"0.6622753",
"0.6012976",
"0.6008559",
"0.6001347",
"0.59929854",
"0.5971298",
"0.5967435",
"0.5856683",
"0.58267295",
"0.5814241",
"0.58061194",
"0.5748924",
"0.5748924",
"0.57301205",
"0.5723308",
"0.57088876",
"0.5666997",
"0.56562436",
"0.5640187",
"0.563349"... | 0.6529948 | 2 |
Description Removes the link of this element from your section. found: reloads the element in compact mode compact: removes the element and reloads the whole page expanded: removes the element and reloads the whole page Mode Ajax + Json Specific filters ApplicationControllerinitialize_media_element ApplicationControllerinitialize_media_element_destination | def remove
@ok_msg = t('other_popup_messages.correct.remove.media_element')
if @ok
bookmark = Bookmark.where(:user_id => current_user.id, :bookmarkable_type => 'MediaElement', :bookmarkable_id => @media_element_id).first
if bookmark.nil?
@ok = false
@error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_media_element')
else
bookmark.destroy
if Bookmark.where(:user_id => current_user.id, :bookmarkable_type => 'MediaElement', :bookmarkable_id => @media_element_id).any?
@ok = false
@error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_media_element')
end
end
else
@error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_media_element')
end
if @destination == ButtonDestinations::FOUND_MEDIA_ELEMENT
prepare_media_element_for_js
render 'media_elements/reload.js'
else
render :json => {:ok => @ok, :msg => (@ok ? @ok_msg : @error)}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @element = @page.all_elements.find(params[:id])\n # Start by removing the element from the page\n page_element = Fe::PageElement.where(:element_id => @element.id, :page_id => @page.id).first\n page_element.destroy if page_element\n\n # If this element is not on any other pages, is not ... | [
"0.6071593",
"0.57807547",
"0.5600696",
"0.55835575",
"0.5526149",
"0.55047345",
"0.543671",
"0.5432676",
"0.5417777",
"0.53990537",
"0.5340022",
"0.5313041",
"0.5259157",
"0.52519363",
"0.5238161",
"0.5231691",
"0.52297837",
"0.5223814",
"0.5210044",
"0.5190807",
"0.5190292"... | 0.67451316 | 0 |
Description Updates the general information of the element (title, description and tags) Mode Ajax Specific filters ApplicationControllerinitialize_media_element_with_owner_and_private | def update
if @ok
@media_element.title = params[:title]
@media_element.description = params[:description]
@media_element.tags = params[:tags_value]
@media_element.save_tags = true
if !@media_element.save
@errors = convert_media_element_error_messages @media_element.errors
else
@media_element.set_status current_user.id
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_description\n self.div(:id=>\"contentmetadata_description_container\").fire_event \"onmouseover\"\n self.div(:id=>\"contentmetadata_description_container\").fire_event \"onclick\"\n end",
"def update\n params[:description][:author_ids] ||= []\n @description = Description.find(params[:id])\n... | [
"0.5705707",
"0.5652698",
"0.5647921",
"0.5594134",
"0.55600524",
"0.5498407",
"0.54231143",
"0.53772646",
"0.53547984",
"0.5341152",
"0.53327996",
"0.5322458",
"0.5298105",
"0.5264204",
"0.5262664",
"0.5225102",
"0.5189534",
"0.5179718",
"0.51662725",
"0.51457626",
"0.510787... | 0.6263109 | 0 |
Description Loads the preview of the element (to be shown inside a special popup) Mode Ajax | def load_preview
@media_element_id = correct_integer?(params[:media_element_id]) ? params[:media_element_id].to_i : 0
@media_element = MediaElement.find_by_id @media_element_id
if !@media_element.nil? && (@media_element.is_public || @media_element.user_id == current_user.id) && @media_element.converted
@ok = true
@media_element.set_status current_user.id
else
@ok = false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preview\n @text = params[:deliverable][:description]\n render :partial => 'common/preview'\n end",
"def content_preview\n self.description.present? ? self.description : self.main_content\n end",
"def preview\n end",
"def preview\n end",
"def preview() @page.find(input_elements[:preview]) e... | [
"0.677189",
"0.651203",
"0.6223139",
"0.6223139",
"0.61364055",
"0.6119763",
"0.6056621",
"0.60314924",
"0.6027012",
"0.6024347",
"0.6022112",
"0.5994158",
"0.5931087",
"0.59216595",
"0.57912004",
"0.5769556",
"0.5758151",
"0.5754315",
"0.5750362",
"0.574581",
"0.57400817",
... | 0.0 | -1 |
Description Reloads the element if it's in conversion Mode Ajax | def check_conversion
@mes = []
params.keys.each do |key|
if key[0, 2] == 'me'
id = key[2, key.length - 2]
media_element_id = correct_integer?(id) ? id.to_i : 0
media_element = MediaElement.find_by_id media_element_id
ok = (media_element && current_user.id == media_element.user_id && !media_element.is_public)
media_element.set_status current_user.id if ok
@mes << {
:ok => ok,
:media_element_id => media_element_id,
:media_element => media_element
}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh_part\n\n if params[:restream].nil?\n @msg = current_user.check_message\n render layout: false\n else\n @msg = current_user.check_message\n\n respond_to do |format|\n format.js\n end\n end\n\n end",
"def toggle_feedback\n product_idurl params[:product_id... | [
"0.5470013",
"0.54249144",
"0.5354219",
"0.5319931",
"0.52720785",
"0.5226924",
"0.5206482",
"0.51908624",
"0.5145297",
"0.5110697",
"0.51084536",
"0.5069864",
"0.5069537",
"0.5060468",
"0.505131",
"0.5040813",
"0.50330114",
"0.49955735",
"0.499359",
"0.4976219",
"0.49706966"... | 0.0 | -1 |
Description Deletes an element which has not been correctly converted Mode Json Specific filters ApplicationControllerinitialize_media_element_destination | def destroy_fake
render :json => {:ok => true, :msg => nil}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n if @ok\n if !@media_element.check_and_destroy\n @ok = false\n @error = @media_element.get_base_error\n end\n else\n @error = I18n.t('activerecord.errors.models.media_element.problem_destroying')\n end\n render :json => {:ok => @ok, :msg => @error}\n end",
"... | [
"0.6416994",
"0.6255369",
"0.58502597",
"0.5704979",
"0.56556714",
"0.56113976",
"0.5580223",
"0.5564969",
"0.5553642",
"0.5538928",
"0.54998577",
"0.54893374",
"0.5467149",
"0.5460922",
"0.54432493",
"0.54323936",
"0.54239345",
"0.54103184",
"0.5403993",
"0.54009694",
"0.537... | 0.0 | -1 |
Gets media elements using Userown_media_elements | def get_own_media_elements
current_user_own_media_elements = current_user.own_media_elements(@page, @for_page, @filter)
@media_elements = current_user_own_media_elements[:records]
@pages_amount = current_user_own_media_elements[:pages_amount]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_media_elements(page)\n MediaElement.joins(:taggings).where(:taggings => {:tag_id => self.id}).order('media_elements.updated_at DESC').page(page)\n end",
"def media_elements_at\n case self.kind\n when AUDIO, VIDEO1, VIDEO2\n resp = self.media_elements_slides.first\n resp.nil? ? n... | [
"0.71667904",
"0.69947106",
"0.6593392",
"0.65456766",
"0.6522452",
"0.6473865",
"0.646598",
"0.64359754",
"0.63486004",
"0.61855525",
"0.61852956",
"0.61313766",
"0.6085632",
"0.6076357",
"0.6076312",
"0.60489213",
"0.6029287",
"0.60000145",
"0.5949952",
"0.5942411",
"0.5934... | 0.79123586 | 0 |
Initializes pagination parameters and filters | def initialize_paginator
@page = correct_integer?(params[:page]) ? params[:page].to_i : 1
@display = [MediaElement::DISPLAY_MODES[:compact], MediaElement::DISPLAY_MODES[:expanded]].include?(params[:display]) ? params[:display] : MediaElement::DISPLAY_MODES[:expanded]
if @display == MediaElement::DISPLAY_MODES[:expanded]
@for_row = correct_integer?(params[:for_row]) ? params[:for_row].to_i : 1
@for_row = 1 if @for_row > 50
@for_page = @for_row * 2
else
@for_page = FOR_PAGE
end
@filter = params[:filter]
@filter = Filters::ALL_MEDIA_ELEMENTS if !Filters::MEDIA_ELEMENTS_SET.include?(@filter)
@just_resizing = params[:resizing].present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_paginator\n @page = correct_integer?(params[:page]) ? params[:page].to_i : 1\n @for_page = FOR_PAGE\n @filter = params[:filter]\n @filter = Filters::ALL_LESSONS if !Filters::LESSONS_SET.include?(@filter)\n end",
"def initialize_paginator\n @page = correct_integer?(params[:page]) ? ... | [
"0.81804955",
"0.7580574",
"0.75481284",
"0.73435843",
"0.7307405",
"0.72276783",
"0.70673984",
"0.70617324",
"0.6955872",
"0.6863854",
"0.68290067",
"0.6822881",
"0.6807381",
"0.6766881",
"0.67356074",
"0.6732658",
"0.67267615",
"0.6671169",
"0.6663352",
"0.6656369",
"0.6643... | 0.74732095 | 3 |
Convert the google cloud sql instance representation to "our" representation | def convert_instance(acct, i)
route = ApiResources::Instances.actions[:show].named_routes[:instance_href]
i['href'] = make_href(acct, i['instance'])
i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_instance(instance)\n state = @@INSTANCE_STATE_MAP[instance[\"status\"]]\n Instance.new(\n :id => instance[\"id\"],\n :owner_id => instance[\"owner\"],\n :image_id => instance[\"imageId\"],\n :name => instance[\"name\"],\n :realm_id => instance[\"location\"],\n :state... | [
"0.6233626",
"0.62113255",
"0.62113255",
"0.60122085",
"0.5929376",
"0.54381394",
"0.5413843",
"0.53734714",
"0.5343331",
"0.53222305",
"0.5285177",
"0.52780044",
"0.52780044",
"0.52780044",
"0.52718884",
"0.5271502",
"0.5270497",
"0.5235592",
"0.5227139",
"0.5199248",
"0.518... | 0.0 | -1 |
and returns the average of all numbers in the array. The array will never be empty and the numbers will always be positive integers. in: array of ints out: average of ints assume: array will not be empty, ints always pos logic: create sum variable and divide by length of array | def average(ary)
ary.sum / ary.length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average(array)\n sum = 0\n array.each do |int|\n sum += int\n end\n sum / array.length\nend",
"def average(integer_array)\n sum = integer_array.sum\n average = sum / integer_array.size\nend",
"def average(array)\n i = 0\n sum = 0\n while i < array.length\n sum += array[i].to_int\n ... | [
"0.8394138",
"0.83514893",
"0.8273032",
"0.82706636",
"0.82688683",
"0.8222824",
"0.8210271",
"0.81731826",
"0.81629723",
"0.81601846",
"0.81511325",
"0.81434655",
"0.8141863",
"0.8136513",
"0.8120261",
"0.8109243",
"0.8104943",
"0.81039983",
"0.8096044",
"0.809392",
"0.80931... | 0.75944585 | 92 |
GET /action_states GET /action_states.json | def index
@action_states = ActionState.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_states\n perform(:get, 'enum/states', nil, nonauth_headers).body\n end",
"def get_state\n @states = State.find_state(params[:id])\n respond_to do |format|\n format.json { render :json => @states }\n end\n end",
"def index\n @api_states = Api::State.all\n end",
"def... | [
"0.7573909",
"0.7290489",
"0.7100373",
"0.6914498",
"0.68387026",
"0.68236977",
"0.68236977",
"0.68236977",
"0.68236977",
"0.68236977",
"0.6608056",
"0.6543935",
"0.65251696",
"0.6519283",
"0.64381415",
"0.6428163",
"0.6417171",
"0.6399927",
"0.63791746",
"0.63791746",
"0.636... | 0.7819178 | 0 |
GET /action_states/1 GET /action_states/1.json | def show
respond_to do |format|
format.html { render :show }
format.text do
data = LuaScript::Dumper.dump_with_func('actionstate', @action_state.for_lua).encode('Shift_JIS')
name = @action_state.chara + '.lua'
send_data(data, filename: name)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state\n @states = State.find_state(params[:id])\n respond_to do |format|\n format.json { render :json => @states }\n end\n end",
"def index\n @action_states = ActionState.all\n end",
"def get_states\n perform(:get, 'enum/states', nil, nonauth_headers).body\n end",
... | [
"0.76807547",
"0.74640995",
"0.7050605",
"0.70203876",
"0.70077246",
"0.676901",
"0.676901",
"0.6731739",
"0.6731739",
"0.6731739",
"0.6731739",
"0.6731739",
"0.66922796",
"0.66896033",
"0.658945",
"0.64759487",
"0.6475215",
"0.6441073",
"0.6432022",
"0.632255",
"0.63185734",... | 0.0 | -1 |
POST /action_states POST /action_states.json | def create
@action_state = ActionState.new(action_state_params)
respond_to do |format|
if @action_state.save
format.html { redirect_to [project, @action_state], notice: 'Action state was successfully created.' }
format.json { render :show, status: :created, location: @action_state }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @action_states = ActionState.all\n end",
"def create\n @state = State.new(state_params)\n\n if @state.save\n render json: @state, status: :created, location: @state\n # 'state was successfully created.'\n else\n render json: @state.errors, status: :unprocessable_entity\n ... | [
"0.6681765",
"0.6533226",
"0.6487266",
"0.64165443",
"0.64110124",
"0.63889223",
"0.63889223",
"0.6381537",
"0.63767755",
"0.6347029",
"0.6346201",
"0.6326781",
"0.6256764",
"0.6248286",
"0.6225454",
"0.62234485",
"0.62085706",
"0.6071389",
"0.60122657",
"0.60032153",
"0.6002... | 0.68875045 | 0 |
PATCH/PUT /action_states/1 PATCH/PUT /action_states/1.json | def update
respond_to do |format|
if @action_state.update(action_state_params)
format.html { redirect_to [project, @action_state], notice: 'Action state was successfully updated.' }
format.json { render :show, status: :ok, location: @action_state }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @state.update(state_params)\n format.html { redirect_to @state, notice: 'State was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @state.errors,... | [
"0.68128395",
"0.67845887",
"0.67845887",
"0.67845887",
"0.67651767",
"0.67571896",
"0.67542475",
"0.66479415",
"0.66479415",
"0.6631263",
"0.6543808",
"0.6541712",
"0.64760345",
"0.63940316",
"0.6382878",
"0.6354047",
"0.62879497",
"0.62710017",
"0.6259483",
"0.62157136",
"0... | 0.71217287 | 0 |
DELETE /action_states/1 DELETE /action_states/1.json | def destroy
@action_state.destroy
respond_to do |format|
format.html { redirect_to project, notice: 'Action state was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @state.destroy\n respond_to do |format|\n format.html { redirect_to states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @state = State.find(params[:id])\n @state.destroy\n\n respond_to do |format|\n format.html { redirect_to states_url }\n ... | [
"0.75898534",
"0.75869477",
"0.75869477",
"0.742729",
"0.73140097",
"0.7312422",
"0.7312422",
"0.7297364",
"0.72574395",
"0.7200444",
"0.7171735",
"0.7147914",
"0.7121784",
"0.7097709",
"0.7046991",
"0.7040303",
"0.70086247",
"0.69935286",
"0.6973888",
"0.69417274",
"0.693345... | 0.7370482 | 4 |
Use callbacks to share common setup or constraints between actions. | def set_action_state
@action_state = ActionState.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.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def action_state_params
params.require(:action_state).permit(:project_id, :chara, :field, :freq, :precis)
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.6980384",
"0.6782743",
"0.6746196",
"0.6742575",
"0.6736",
"0.6594004",
"0.65037984",
"0.6496699",
"0.64819324",
"0.64791185",
"0.6456292",
"0.64403296",
"0.63795286",
"0.6375975",
"0.6365291",
"0.63210756",
"0.6300542",
"0.6299717",
"0.62943304",
"0.6292561",
"0.6290683",... | 0.0 | -1 |
Input: name and group assignment for new group list Output: new list with name and group to which the stduetns belong, with request to update one group that has too many students. Code is very simple steps: create new hash with information ofs student names with group assigned reassign student to a different group list the has of students and group assignment make a change for assignment and update the list | def add(list, student,group)
list[student] = group
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_groups list #hash or array\n updated=false\n if list.is_a? Array\n list.each do |grp|\n next if check_group grp\n @@groups[grp]=grp.to_s\n updated=true\n end\n else\n list.each_pair do |grp,name|\n next if check_group grp\n ... | [
"0.66360784",
"0.6237153",
"0.6188952",
"0.6026198",
"0.5886622",
"0.588282",
"0.5865376",
"0.5857002",
"0.5840385",
"0.57994574",
"0.5735701",
"0.5701173",
"0.5681672",
"0.5661645",
"0.564786",
"0.56250745",
"0.5588607",
"0.55875236",
"0.5578181",
"0.5568742",
"0.5551329",
... | 0.6117647 | 3 |
def scream(words) words = words + "!!!!" return puts words end scream("Yippeee") In exercise 5, the method will print to screen, but should return nil. | def scream(words)
words = words + "!!!!"
puts words
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scream(words) # Edited to output to STDOUT, returns nil (the last statement is 'puts words')\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\nwords = words + \"!!!!\"\nreturn #this makes the program return nothing.. because it has nothing next to the return method\nputs words\nend",
"de... | [
"0.8911424",
"0.88289773",
"0.875892",
"0.8719786",
"0.8719786",
"0.8719786",
"0.8719786",
"0.8719786",
"0.8719786",
"0.8719786",
"0.8719786",
"0.8719083",
"0.86863965",
"0.8631476",
"0.8600056",
"0.85801613",
"0.8578181",
"0.85728407",
"0.8542892",
"0.85354763",
"0.8523123",... | 0.7858081 | 64 |
current_organisation returns organisation obj for current organisation return nil if no current organisation defined | def current_organisation()
begin
organisation = (
Thread.current[:organisation_id].blank? ?
nil :
Organisation.find( Thread.current[:organisation_id] )
)
return organisation
rescue ActiveRecord::RecordNotFound
return nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_org\n current_user&.org\n end",
"def set_current_organisation( organisation )\n # able to handle organisation obj or organisation_id\n #case organisation\n # when Organisation then organisation_id = organisation.id\n # when Integer then organisation_id = organisation\n ... | [
"0.7711881",
"0.76772815",
"0.7624038",
"0.7284386",
"0.72407955",
"0.72248566",
"0.6995413",
"0.6935735",
"0.6915876",
"0.6709824",
"0.66519535",
"0.66405255",
"0.6632705",
"0.6632705",
"0.6558245",
"0.6423801",
"0.6405801",
"0.63878894",
"0.63841444",
"0.6370104",
"0.635101... | 0.8878894 | 0 |
current_organisation_id returns organisation_id for current organisation | def current_organisation_id()
return Thread.current[:organisation_id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_organisation()\n begin\n organisation = (\n Thread.current[:organisation_id].blank? ?\n nil :\n Organisation.find( Thread.current[:organisation_id] )\n )\n\n return organisation\n\n rescue ActiveRecord::RecordNotFound\n return nil\n ... | [
"0.81824243",
"0.80198395",
"0.75833",
"0.75296277",
"0.7467459",
"0.729725",
"0.72417474",
"0.6995078",
"0.6897121",
"0.68032783",
"0.6752774",
"0.67313534",
"0.6719804",
"0.6719804",
"0.6719804",
"0.67147934",
"0.6714425",
"0.65651304",
"0.6557183",
"0.6556622",
"0.6556622"... | 0.83400047 | 0 |
set_current_organisation modellevel ability to set the current organisation NOTE: USE WITH CAUTION normally this should NEVER be done from the models ... it's only useful and safe WHEN performed at the start of a background job (DelayedJobperform) | def set_current_organisation( organisation )
# able to handle organisation obj or organisation_id
#case organisation
# when Organisation then organisation_id = organisation.id
# when Integer then organisation_id = organisation
# when Array then organisation_id = organisation
# else
# raise ArgumentError, "invalid organisation object or id"
#end
#old_id = ( Thread.current[:organisation_id].nil? ? '%' : Thread.current[:organisation_id] )
if organisation.is_a? Integer
organisation = Organisation.where(id: organisation).first
end
Thread.current[:organisation_id] = organisation.present? ? organisation.root.subtree.map(&:id) : nil
Thread.current[:current_organisation_id] = organisation.present? ? organisation.subtree.map(&:id) : nil
Thread.current[:root_organisation_id] = organisation.present? ? organisation.root.id : nil
#organisation = Organisation.find(organisation_id) rescue nil
#Time.zone = organisation.time_zone || 'Singapore' rescue 'Singapore'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_organisation\n @organisation = Organisation.find(params[:organisation_id]) if params[:organisation_id]\n end",
"def set_organisation\n raise \"You must set the organisation\" if session[:organisation].blank?\n OrganisationSession.set session[:organisation]\n end",
"def set_organization\n... | [
"0.6453708",
"0.64062",
"0.62416416",
"0.6211622",
"0.6211622",
"0.6211622",
"0.6205148",
"0.60366184",
"0.58874464",
"0.57556295",
"0.57506716",
"0.5725723",
"0.5718173",
"0.56490356",
"0.56490356",
"0.56490356",
"0.5634117",
"0.56214094",
"0.5598364",
"0.5596463",
"0.557060... | 0.72130495 | 0 |
where_restrict_organisation gens organisation restrictive where clause for each klass NOTE: subordinate join tables will not get the default scope by Rails theoretically, the default scope on the master table alone should be sufficient in restricting answers to the current_organisation alone .. HOWEVER, it doesn't feel right. adding an additional .where( where_restrict_organisations(klass1, klass2,...)) for each of the subordinate models in the join seems like a nice safety issue. | def where_restrict_organisation(*args)
args.map{|klass| "#{klass.table_name}.organisation_id = #{Thread.current[:organisation_id]}"}.join(" AND ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_filter_by_associations_window_function_limit_strategy(ds)\n ds.where(filter_by_associations_limit_key=>apply_window_function_eager_limit_strategy(associated_eager_dataset.select(*filter_by_associations_limit_alias_key)).select(*filter_by_associations_limit_aliases))\n end",
"def apply_f... | [
"0.5719611",
"0.5646677",
"0.55646676",
"0.55289453",
"0.5404927",
"0.5376554",
"0.5335817",
"0.53332233",
"0.5321977",
"0.52638996",
"0.524178",
"0.5206978",
"0.52049476",
"0.52001715",
"0.51796716",
"0.5166633",
"0.5142932",
"0.5134657",
"0.5118139",
"0.5098712",
"0.5068207... | 0.8168442 | 0 |
Raise translation missing errors in controllers too | def t(key, options = {})
options[:raise] = true
translate(key, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def i18n\n begin\n render :text=>I18n.translate(params[:id], :raise => I18n::MissingTranslationData)\n rescue I18n::MissingTranslationData\n render :text=>\"No translation for #{params[:id]}\", :status => 404\n end\n end",
"def translated_message\n lookups = []\n lookups << ... | [
"0.6910341",
"0.65263426",
"0.6345843",
"0.6310607",
"0.6286313",
"0.6267601",
"0.62420213",
"0.6116496",
"0.60855496",
"0.60322857",
"0.6016841",
"0.59965885",
"0.5939262",
"0.5896123",
"0.58781415",
"0.5869944",
"0.58476675",
"0.58470523",
"0.5843066",
"0.58353645",
"0.5817... | 0.0 | -1 |
FIXTHIS could just take in options never gets called? | def contains?(variant, options = {})
find_line_item_by_variant(variant, options).present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_a... | [
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.730953",
"0.730953",
"0.730953",
"0.730953",
"0.730953",
"0.730953",
"0.730953",
"0.730953",
"0.730953",
"0.72237... | 0.0 | -1 |
I think the new line_item_options_match will cover this | def find_line_item_by_variant(variant, options = {})
ad_hoc_option_value_ids = ( !!options[:ad_hoc_option_values] ? options[:ad_hoc_option_values] : [] )
ad_hoc_option_value_customizations = ( !!options[:ad_hoc_option_value_customizations] ? options[:ad_hoc_option_value_customizations] : [] )
product_customizations = ( !!options[:product_customizations] ? options[:product_customizations].map{|ids| ids.first.to_i} : [] )
line_items.detect do |li|
li.variant_id == variant.id &&
matching_configurations(li.ad_hoc_option_values, ad_hoc_option_value_ids) &&
matching_customizations(li.product_customizations, product_customizations) &&
matching_ad_hoc_customizations(li.ad_hoc_option_values_line_items, ad_hoc_option_value_customizations)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product_customizations_match(line_item, options)\n # comparing_form = line_item.order_form.attributes.dup\n # comparing_form.reject!{ |key| %w\"line_item_id id created_at updated_at\".include? key }\n #\n # #needs more special cases, we'll leave this for now and just always create a new line item\n... | [
"0.6987668",
"0.6207636",
"0.590106",
"0.5772114",
"0.5678291",
"0.56076723",
"0.5562139",
"0.54378706",
"0.54196066",
"0.5405235",
"0.53974706",
"0.5396856",
"0.53934205",
"0.53560835",
"0.53523767",
"0.534459",
"0.532823",
"0.5300918",
"0.5289832",
"0.5265834",
"0.52484924"... | 0.59335464 | 2 |
produces a list of [customizable_product_option.id,value] pairs for subsequent comparison def customization_pairs(product_customizations) pairs= product_customizations.map(&:customized_product_options).flatten.map do |m| [m.customizable_product_option.id, m.value.present? ? m.value : m.customization_image.to_s ] end Set.new pairs end | def destroy_or_save(line_item, line_item_quantity)
line_item_quantity.zero? ? line_item.destroy! : line_item.save!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def customization_pairs(product_customizations)\n pairs = product_customizations.map(&:customized_product_options).flatten.map do |m|\n [m.customizable_product_option.id, m.value.present? ? m.value : m.customization_image.to_s ]\n end\n\n Set.new pairs\n end",
"def customization_pairs(product_cust... | [
"0.9526344",
"0.9512058",
"0.5494813",
"0.5373909",
"0.5344353",
"0.5288939",
"0.5255836",
"0.5206483",
"0.5201266",
"0.51862",
"0.5159777",
"0.5141207",
"0.50949556",
"0.508601",
"0.50718814",
"0.5064807",
"0.5036138",
"0.50183845",
"0.49604815",
"0.49518102",
"0.49469858",
... | 0.0 | -1 |
Pass target to the scope handler of the specified type and name. If `name` is not specified then `:default` name is used. If `type` is not specified then we try to infer the type from the target class. | def apply_scope(target, type:, name: :default, scope_options: nil)
raise ActionPolicy::UnknownScopeType.new(self.class, type) unless
self.class.scoping_handlers.key?(type)
raise ActionPolicy::UnknownNamedScope.new(self.class, type, name) unless
self.class.scoping_handlers[type].key?(name)
mid = :"__scoping__#{type}__#{name}"
scope_options ? send(mid, target, **scope_options) : send(mid, target)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bind_name(name, type)\n @names[name.to_sym] = type unless name.nil?\n end",
"def authorization_scope_type_for(policy, target)\n policy.resolve_scope_type(target)\n end",
"def target\n @target ||= case scope\n when '#'\n klass\n when '.'\n klass && klass.... | [
"0.5854092",
"0.54851234",
"0.54614395",
"0.5429654",
"0.5369638",
"0.53256947",
"0.52948576",
"0.5201738",
"0.5185947",
"0.5157362",
"0.51186293",
"0.50766975",
"0.5053053",
"0.5030344",
"0.500551",
"0.4995355",
"0.49022508",
"0.48995999",
"0.48943287",
"0.48399782",
"0.4834... | 0.7343106 | 0 |
Define scope type matcher. Scope matcher is an object that implements `===` (_case equality_) or a Proc. When no type is provided when applying a scope we try to infer a type from the target object by calling matchers one by one until we find a matching type (i.e. there is a matcher which returns `true` when applying it to the target). | def scope_matcher(type, class_or_proc)
scope_matchers << [type, class_or_proc]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def applies_type?(scope, type); end",
"def type_matcher(mod)\n TypeMatcher.new(mod)\n end",
"def scope_type(node); end",
"def call_scope_by_type(type, scope, target, value, options) #:nodoc:\n if type == :boolean\n target.send(scope)\n elsif value && options.key?(:using)\n ... | [
"0.6947657",
"0.6124443",
"0.5949851",
"0.58142024",
"0.56766033",
"0.5673048",
"0.5441659",
"0.53827775",
"0.5366719",
"0.5353178",
"0.5302973",
"0.5300918",
"0.5299004",
"0.5231972",
"0.52060634",
"0.5149539",
"0.5135744",
"0.5116606",
"0.51091224",
"0.5091886",
"0.5006744"... | 0.7371604 | 0 |
POST /promotions POST /promotions.json | def create
@promotion = Promotion.new(promotion_params)
@render_hidden_input = true if request.xhr?
respond_to do |format|
if @promotion.save
format.html { render :partial => "row_table", :locals => { :promotion => @promotion, :render_hidden_input => @render_hidden_input } }
else
format.json { render :json => { :errors => @promotion.errors }, :status => 409 }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_promotions\n @new_promotions ||= []\n end",
"def index\n if params[:product_id]\n @promotions = Product.find(params[:product_id]).promotions\n else\n @promotions = Promotion.all\n end\n\n render json: @promotions\n end",
"def create\n @promotion = Promotion.new(params[:pro... | [
"0.61129576",
"0.6003724",
"0.5930134",
"0.5900632",
"0.5900632",
"0.5900632",
"0.5849472",
"0.5800277",
"0.5748506",
"0.573991",
"0.5670667",
"0.56652546",
"0.558862",
"0.555045",
"0.55195886",
"0.5505017",
"0.550316",
"0.54850113",
"0.5484974",
"0.54847103",
"0.5421864",
... | 0.0 | -1 |
PATCH/PUT /promotions/1 PATCH/PUT /promotions/1.json | def update
respond_to do |format|
if @promotion.update(promotion_params)
format.html { render :partial => "row_table", :locals => {:promotion => @promotion} }
else
format.json { render :json => { :errors => @promotion.errors }, :status => 409 }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @promoter.update(promoter_params)\n format.html { redirect_to root_url, notice: 'Promoter was successfully updated.' }\n format.json { render :show, status: :ok, location: @promoter }\n else\n format.html { render :e... | [
"0.64262766",
"0.5897429",
"0.5888983",
"0.5867228",
"0.5845862",
"0.57179004",
"0.57116723",
"0.57031745",
"0.56938875",
"0.5689369",
"0.5674687",
"0.565174",
"0.56474644",
"0.5639727",
"0.56024885",
"0.560112",
"0.5590115",
"0.55484325",
"0.55484325",
"0.5515639",
"0.550576... | 0.0 | -1 |
DELETE /promotions/1 DELETE /promotions/1.json | def destroy
if @promotion.delete
render :nothing => true, :status => 200
else
render :nothing => true, :status => 503
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @promotion = Promotion.find(params[:id])\n @promotion.destroy\n\n respond_to do |format|\n format.html { redirect_to promotions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @promotion = Promotion.find(params[:id])\n @promotion.destroy\n\n respond_to ... | [
"0.6877458",
"0.6866245",
"0.68379396",
"0.67688173",
"0.66865426",
"0.66132736",
"0.6602949",
"0.6602193",
"0.6586116",
"0.65849304",
"0.651903",
"0.65147084",
"0.65147084",
"0.65147084",
"0.64873075",
"0.645483",
"0.6425896",
"0.641855",
"0.641855",
"0.6402804",
"0.6391263"... | 0.60768455 | 51 |
Use callbacks to share common setup or constraints between actions. | def set_promotion
@promotion = Promotion.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.6163821",
"0.6045432",
"0.5945441",
"0.5916224",
"0.58894575",
"0.5834073",
"0.57764685",
"0.5702474",
"0.5702474",
"0.5653258",
"0.56211996",
"0.54235053",
"0.5410683",
"0.5410683",
"0.5410683",
"0.53948104",
"0.5378064",
"0.5356684",
"0.53400385",
"0.53399503",
"0.533122... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def promotion_params
params.require(:promotion).permit(:condition_id, :quota, :bin, :bank_id, :credit_card_id, :start_date, :end_date, :observations,:observationsb2c, :comerce_number, :active)
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 |
So we can construct these ourselves | def net_sales_as_decimal
net_sales[1..-1].to_d
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def initialize() end",
"def initialize\n \n end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def construct\n ... | [
"0.66957146",
"0.61343545",
"0.6075207",
"0.6074894",
"0.6074894",
"0.6074894",
"0.6074894",
"0.6074894",
"0.6038585",
"0.6038585",
"0.6038585",
"0.6038585",
"0.59377253",
"0.5905793",
"0.5905793",
"0.5905793",
"0.5905793",
"0.5905793",
"0.5905793",
"0.5905793",
"0.5905793",
... | 0.0 | -1 |
Load from Link Records | def load(links, o = {})
i = 0.0
links.each do |l|
if l[1] >= l[2] && !o[:force]
info "Inconsistent Input #{l.inspect}, skipping..." if l[0] != 'e'
next
end
v[l[0]] = {} if !v[l[0]]
v[l[0]][l[1]] = {} if !v[l[0]][l[1]]
v[l[0]][l[2]] = {} if !v[l[0]][l[2]]
v[l[0]][l[2]][l[1]] = l[3].to_f
v[l[0]][l[1]][l[2]] = l[3].to_f
i += 1
end
#debug "[LinkFeatures::load] #{i} links loaded"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load record\n end",
"def load\n records.load\n end",
"def load\n records.__send__(:load)\n end",
"def load_record(rid, mid)\n url = Configuration::PROPERTIES.get_property :url\n url_get_records = Configuration::PROPERTIES.get_property :url_ge... | [
"0.68154955",
"0.66979676",
"0.6455902",
"0.6243837",
"0.6213146",
"0.6065446",
"0.60491234",
"0.5975796",
"0.596967",
"0.59458137",
"0.59071857",
"0.5899719",
"0.57650113",
"0.574955",
"0.5698174",
"0.5668693",
"0.5617649",
"0.5556709",
"0.5551922",
"0.55441046",
"0.55355024... | 0.49777573 | 64 |
Read the links associated with given item | def read_links(ltype, id)
return {} if !v[ltype]
return {} if !v[ltype][id]
v[ltype][id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def links\n return nil unless @item and self.type == :query and @item['entry']['link']\n @item['entry']['link']\n end",
"def read_link(item)\n link = item.search(\"link:first\")\n unless link.nil?\n post_url = link.text\n post_url = link.to_s.scan(/href=['\"]?([^'\"]*)['\" ]/).to_s i... | [
"0.72134143",
"0.7042375",
"0.6786516",
"0.6618375",
"0.64442897",
"0.6409303",
"0.6408033",
"0.6408033",
"0.64064795",
"0.6405543",
"0.6400688",
"0.6391095",
"0.6391001",
"0.6389038",
"0.6377273",
"0.635115",
"0.63477886",
"0.6341332",
"0.6341332",
"0.6341332",
"0.63182056",... | 0.5709783 | 71 |
Main method for getting all Available TimeBlock(s) for a given date. +:base_time: DateTime used for determining the base scan date range. | def available_on(base_time)
# Stash this for future use, as we will be using it to set a
# baseline date in order to derive a bunch of different appointments
# from.
set_base_time(base_time)
# Fetch all TimeEntris related for this date query.
time_entries = time_entries_for(base)
# Transform TimeEntry(s) -> TimeSlot(s).
available_slots = generate_time_slots(time_entries)
# Combine all sequential linear slots to into a single window.
# This produces multiple windows
windows = combine_linear_slots(available_slots)
# Generate TimeBlocks from the Available Slot ranges
open_time_blocks = generate_time_blocks(windows)
# Optimize & Filter our wide collection of TimeBlocks.
optimized_blocks = optimize_time_blocks(open_time_blocks)
# Finally, present the TimeBlock(s) as Appointment records
# to the Customer.
final = transform_blocks_to_appointments(optimized_blocks)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_blocks(base_time)\n set_base_time(base_time)\n time_entries = time_entries_for(base)\n end",
"def available_delivery_blocks(time)\n\n unless opens_today\n return []\n end\n\n # Reset date to compare with Postgres Time\n time = time.change(:month => 1, :day => 1, :yea... | [
"0.70361656",
"0.67197216",
"0.6327685",
"0.5927963",
"0.5920603",
"0.58066165",
"0.57762384",
"0.5687271",
"0.5667841",
"0.56143665",
"0.5585009",
"0.5533882",
"0.55060583",
"0.55009145",
"0.5492323",
"0.5470167",
"0.54546696",
"0.5426355",
"0.5423387",
"0.53829724",
"0.5328... | 0.718394 | 0 |
Public api for returning all collisions for a given Range. The Range is transformed into a TimeBlock, and then pushed through the pipeline for natural detection of any collisions. | def collisions_for(range)
collider.detect TimeBlock.new(
start_time: range.begin,
end_time: range.end,
session: @session)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collide_hash_all(hash_rects)\n hash_rects.select { |key,value|\n value.collide_rect?+(self)\n }\n end",
"def collisions(rect)\n remain = visible_sprites(rect).to_a\n coll = remain.select { |item| item.intersect_rect? rect }\n [coll, coll - remain]\n end",
"def collisions\n ... | [
"0.6032244",
"0.5861564",
"0.5708567",
"0.56075084",
"0.5579013",
"0.5519869",
"0.54588366",
"0.5458093",
"0.5350583",
"0.52792895",
"0.5246726",
"0.5141044",
"0.50969744",
"0.5044568",
"0.5018214",
"0.49943906",
"0.49637446",
"0.49148008",
"0.49016166",
"0.48722035",
"0.4865... | 0.78286237 | 0 |
Generate TimeSlots over a given range using the minimum service duration | def time_slots_for(time_entry)
count = (duration_for(time_entry.range) / block_size).floor.to_i
time = time_entry.start_time
slots = count.times.map do |i|
# Instantiate a new TimeSlot out of thin air (no backing store)
slot = TimeSlot.new time, time + block_size.minutes, time_entry
# Stash the current session onto the slot as well, so it may handle
# some of it's own session based logic.
slot.session = session
# finally increment the time for the next iteration
time = time + block_size.minutes
slot
end
# Detect deadspace at the TimeSlot layer.
# If found, we add a final TimeSlot to make up the difference.
if time < time_entry.end_time
slots << TimeSlot.new(time, time_entry.end_time, time_entry)
end
# Return the aggregated slot collection
slots
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_time_slots\n return unless params[:start_time]\n\n start_time = Time.from_picker(params.delete(:start_time))\n end_time = Time.from_picker(params.delete(:end_time))\n\n return if end_time < start_time # Prevent infinite loop\n\n shift_length = params.delete(:shift_length).to_i\n shift_... | [
"0.7170792",
"0.6663513",
"0.6558084",
"0.6462332",
"0.64136404",
"0.6384976",
"0.6365225",
"0.63063604",
"0.6271311",
"0.6268339",
"0.61531085",
"0.6131482",
"0.6111703",
"0.597443",
"0.59514713",
"0.59509254",
"0.5946872",
"0.58817",
"0.5870683",
"0.58646303",
"0.5817582",
... | 0.63567793 | 7 |
Return all valid TimeBlock(s) for a given base time. | def valid_blocks(base_time)
set_base_time(base_time)
time_entries = time_entries_for(base)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_time_blocks(time_blocks)\n b = time_blocks.select(&:collision_free?)\n\n # Test environment has unreliable data entry for start times.\n b = b.select(&:in_future?) unless Rails.env.test?\n\n b\n end",
"def available_delivery_blocks(time)\n\n unless opens_today\n ... | [
"0.6995972",
"0.666866",
"0.61515516",
"0.60989684",
"0.6043392",
"0.6019025",
"0.57999414",
"0.5793993",
"0.5751547",
"0.56786937",
"0.5677315",
"0.5637624",
"0.5597517",
"0.55707026",
"0.55529094",
"0.5491499",
"0.5484656",
"0.5475232",
"0.54654413",
"0.5422617",
"0.5392022... | 0.8538772 | 0 |
Returns all valid Appointments for a given base time. | def valid_appointments(base_time)
transform_blocks_to_appointments(valid_blocks(base_time))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_appointments\n # Appointment\n return unless current_user\n @appointments = current_user.appointments\n\n clean_open_appointments = sanatize_open_appointments(current_user.open_appointments)\n @pending_requests = clean_open_appointments.group_by do |d|\n start_date = set_in_timezone(d.... | [
"0.7045828",
"0.6885598",
"0.6717285",
"0.6605498",
"0.6413851",
"0.63946986",
"0.63369745",
"0.6309198",
"0.6276353",
"0.6226337",
"0.61962336",
"0.61922294",
"0.6171634",
"0.6166286",
"0.6164967",
"0.616016",
"0.60806805",
"0.60776097",
"0.6060947",
"0.60355353",
"0.6013217... | 0.8377896 | 0 |
Returns the amount of minutes that occur between a DateTime range | def duration_for(range)
raise "Range cannot be nil" if range.nil?
raise "Durations can only be calculated for ranges" unless range.kind_of? Range
((range.end - range.begin) * 24 * 60).to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_work_minutes\n @date_range.inject(0) do |minutes, date|\n # Do not count days off\n minutes += get_minutes_in_day(date) unless day_off?(date)\n minutes\n end\n end",
"def get_minutes\n de = self.string_to_datetime(@from)\n a = self.string_to_datetime(@to)\n \n total = ... | [
"0.711077",
"0.68749887",
"0.67467177",
"0.6497978",
"0.6446701",
"0.64376456",
"0.6242228",
"0.61701834",
"0.600537",
"0.5982471",
"0.59077907",
"0.58859533",
"0.5776286",
"0.5773847",
"0.5755307",
"0.57261384",
"0.5721615",
"0.5717158",
"0.57100457",
"0.57046914",
"0.566914... | 0.60406035 | 8 |
Get all TimeEntry(s) that match the current session properties. +:target_date+ A DateTime to base the TimeEntry collection query from. | def time_entries_for(target_date)
target_day = Skej::NLP.parse(session, target_date.to_s)
.strftime('%A')
.downcase
.to_sym
TimeEntry.where(build_query_params).with_day(target_day).map do |entry|
entry.session = session and entry
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_entries\n get_ticket_property_list(\"time_entries\" , Unfuddled::TimeEntry)\n end",
"def get_time_entries(start_date=nil, end_date=nil)\n options = Hash.new\n options[\"start_date\"] = iso8601_date(start_date) if start_date\n options[\"end_date\"] = iso8601_date(end_date) if... | [
"0.5922868",
"0.5683903",
"0.5566405",
"0.53385276",
"0.5298395",
"0.52521545",
"0.5115447",
"0.50400954",
"0.48718688",
"0.48286006",
"0.48045316",
"0.48045316",
"0.4798784",
"0.47657496",
"0.47596595",
"0.4755274",
"0.4742012",
"0.4742012",
"0.4742012",
"0.47243476",
"0.471... | 0.8224443 | 0 |
Produces TimeSlot(s) from a collection of TimeEntries | def generate_time_slots(time_entries)
time_entries.map { |entry| extract_available_slots(entry) }.flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_slots_for(time_entry)\n count = (duration_for(time_entry.range) / block_size).floor.to_i\n time = time_entry.start_time\n\n slots = count.times.map do |i|\n # Instantiate a new TimeSlot out of thin air (no backing store)\n slot = TimeSlot.new time, time + block_size.... | [
"0.73997855",
"0.7293364",
"0.6935869",
"0.6710855",
"0.65502787",
"0.6529408",
"0.62408537",
"0.6206863",
"0.60246116",
"0.60169065",
"0.6007946",
"0.6006138",
"0.59570074",
"0.59515446",
"0.5933802",
"0.5849529",
"0.5832255",
"0.57931644",
"0.57828283",
"0.57533526",
"0.573... | 0.7823904 | 0 |
Produces TimeSlot(s) from a collection of TimeSlotWindows | def generate_time_blocks(windows)
results = windows.map do |window|
# Create a date based n todays date, but with the time changed to
# that of the entry start/end.
entry_start = base.change(
hour: window.start_time.hour,
min: window.start_time.minute)
# By rounding off with #floor, we go the easy route (no partial time blocks)
# Note: iterator is zero based.
blocks = (window.duration / block_size).floor.times.map { |i|
start_time = Skej::Warp.zone(
entry_start + (i * block_size).minutes,
session.chosen_office.time_zone)
end_time = Skej::Warp.zone(
start_time + block_size.minutes,
session.chosen_office.time_zone)
target_day = Skej::NLP.parse(session, window.day)
.strftime('%A')
.downcase
.to_sym
TimeBlock.new(
session: session,
time_entry_id: window.time_entry.id,
business_id: session.business_id,
time_sheet_id: window.time_sheet_id,
office_id: window.office_id,
day: target_day,
start_time: start_time,
end_time: end_time)
}
end.flatten # results
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_slots\n collection=[]\n start_time=Time.now.beginning_of_hour\n end_time=Time.now.tomorrow.midnight-1.hour\n time=start_time\n\n while time < end_time\n collection<<[time.beginning_of_hour.hour, time.beginning_of_hour]\n time=time+1.hour\n end\n\n collection\n end",
"def ... | [
"0.69684774",
"0.66403735",
"0.6522786",
"0.64842707",
"0.64607245",
"0.6315037",
"0.6260561",
"0.61152977",
"0.5953129",
"0.5904408",
"0.5851289",
"0.57530767",
"0.5634359",
"0.5601106",
"0.5556569",
"0.55542845",
"0.5491609",
"0.5475066",
"0.54636014",
"0.5437108",
"0.54204... | 0.64953905 | 3 |
Responsible combining a collection of slots into common groups, defined by touching boundaries. +:slots: Array / Collection of TimeSlot(s) | def combine_linear_slots(slots)
last_slot = false
end_time = false
start_time = false
flushed = false # Tracks the current continuity chain
count = 0
aggregate = []
debug = []
slots.sort_by(&:start_time).each_with_index do |slot, i|
# Very close to each other, mark it as a continuation
# to the end_time.
start_time = slot.start_time unless last_slot
end_time = slot.end_time unless last_slot
if slot.start_time < (end_time + 30.seconds)
debug << "slot:#{slot.start_time} - neighbor detected"
end_time = slot.end_time
elsif last_slot
debug << "slot:#{slot.start_time} - gap detected"
aggregate << TimeSlot.new(start_time, end_time, slot.time_entry)
start_time = slot.start_time
end_time = slot.end_time
end
last_slot = slot
end
aggregate << TimeSlot.new(start_time, end_time, last_slot.time_entry) if last_slot
aggregate.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_ranges(schedule)\n merged_schedule = []\n\n schedule.each do |meeting|\n overlapping_time_slots = check_times(meeting, merged_schedule)\n merged_schedule -= overlapping_time_slots if merged_schedule.include?(overlapping_time_slots)\n merged_schedule << slot_merger(overlapping_time_slots)\n en... | [
"0.6928598",
"0.6598432",
"0.6556763",
"0.62836176",
"0.61598545",
"0.61425924",
"0.61248326",
"0.59110165",
"0.5904596",
"0.5904228",
"0.5902116",
"0.58843243",
"0.58529955",
"0.5809075",
"0.5797486",
"0.57824683",
"0.57600373",
"0.57475156",
"0.56936073",
"0.56116503",
"0.5... | 0.7387607 | 0 |
Given a collection of TimeBlock(s), return only the ones that have no detectable collisions (and thus are valid). +:time_blocks+ All extracted TimeBlock(s) you wish to have validated. | def validate_time_blocks(time_blocks)
b = time_blocks.select(&:collision_free?)
# Test environment has unreliable data entry for start times.
b = b.select(&:in_future?) unless Rails.env.test?
b
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_blocks(base_time)\n set_base_time(base_time)\n time_entries = time_entries_for(base)\n end",
"def valid_schedule?(time_blocks)\n time_blocks = quicksort_timeblocks(time_blocks)\n return !exists_overlap?(time_blocks)\n end",
"def validate_time_slots times\n time_models = [... | [
"0.6731134",
"0.60678077",
"0.5977046",
"0.58140635",
"0.5484393",
"0.5484328",
"0.54600245",
"0.534294",
"0.5336923",
"0.5301098",
"0.5291553",
"0.52813506",
"0.52577484",
"0.52175826",
"0.52076405",
"0.5142211",
"0.5131774",
"0.50770044",
"0.507346",
"0.5050142",
"0.5046692... | 0.7842012 | 0 |
Given a collection of TimeBlock(s), return a more optimized subset of the given collection. +:time_blocks: Collection of TimeBlock(s) to be filtered and optimized. | def optimize_time_blocks(time_blocks)
Optimizer.new.optimize(time_blocks)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quicksort_timeblocks(time_blocks)\n if (time_blocks.size <= 1)\n return time_blocks\n end\n\n pivot = time_blocks[0]\n left = []\n right = []\n\n time_blocks[1..time_blocks.size-1].each do |tb|\n if (tb.term.to_i < pivot.term.to_i)\n left.push(tb)\n elsif (pivot.term.to_... | [
"0.5368214",
"0.5326802",
"0.53122807",
"0.52685475",
"0.5181944",
"0.5129373",
"0.5116508",
"0.5077676",
"0.5031447",
"0.49094605",
"0.48733032",
"0.4859573",
"0.48289484",
"0.4816768",
"0.4806716",
"0.47583252",
"0.47385758",
"0.46988118",
"0.46612123",
"0.46600792",
"0.464... | 0.67573684 | 0 |
The size of a TimeBlock. Based on the minute duration of the chosen Service. | def block_size
session.chosen_service.duration rescue session.business.services.first.duration
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size_time(base = self.date_from)\n\t\t\t\t\t@sizes = {} if @sizes.nil?\n\t\t\t\t\tif @sizes[base.to_s].nil?\n\t\t\t\t\t\tsize = DateTime.parse(\"2000-01-01 00:00:00 +0000\")\n\t\t\t\t\t\tself.reservations(base).each do |reservation|\n\t\t\t\t\t\t\tif reservation.above_line?\n\t\t\t\t\t\t\t\tsize += reservation... | [
"0.6852872",
"0.6738088",
"0.66986936",
"0.6645414",
"0.6619052",
"0.64590394",
"0.64569837",
"0.644224",
"0.6386727",
"0.6282654",
"0.6222423",
"0.6215486",
"0.6212822",
"0.616994",
"0.616994",
"0.6114185",
"0.61123925",
"0.61122954",
"0.6108511",
"0.6100553",
"0.6090947",
... | 0.7701602 | 0 |
Fetch the timezone for the chosen office. While also memoizing the time_zone result as | def time_zone
return @time_zone_cache if @time_zone_cache
# Get the office id from the session json store
id = @session.store[:chosen_office_id]
office = Office
.where(business_id: @session.business_id, id: id)
.first
if office.present?
@time_zone_cache = office.time_zone
end
@time_zone_cache
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_zone\n @session.chosen_office.time_zone if @session.chosen_office.present?\n end",
"def timezone!\n if @timezone.nil?\n\n tz = get_country! \n # if country have only one zone then return that zone\n if tz.zones.count == 1\n @timezone = TZInfo::Timezone.get... | [
"0.750561",
"0.7415016",
"0.73211753",
"0.68303543",
"0.67889184",
"0.67746866",
"0.6667891",
"0.6656611",
"0.6656611",
"0.65952057",
"0.6561896",
"0.6533011",
"0.64766604",
"0.64741546",
"0.646192",
"0.6433686",
"0.6433686",
"0.6433686",
"0.6433686",
"0.6433686",
"0.64171845... | 0.8218083 | 0 |
Generate a random range to start with. | def random_range_start
base.to_datetime + (rand(1..30) * 30).minutes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rand_in_range(from, to); end",
"def sample_range(range, seed=nil)\n srand seed if seed\n rand * (range.end - range.begin) + range.begin\n end",
"def random_within_range\n\t\t\trand(self.start_num..self.end_num)\n\t\tend",
"def rand_range(min,max)\n return min + (max-min)*rand\nend",
"def ... | [
"0.8118395",
"0.80711424",
"0.8059874",
"0.7765297",
"0.7765144",
"0.76988673",
"0.76519865",
"0.75728106",
"0.7521159",
"0.7463479",
"0.7462913",
"0.7447883",
"0.73770154",
"0.7324872",
"0.7288438",
"0.7275461",
"0.7215375",
"0.71746296",
"0.7169924",
"0.7105601",
"0.7036547... | 0.7592986 | 7 |
Add a random amount of blocks (30min per block) to the end of an existing start. | def random_range_end(start)
start + (rand(1..5) * 30).minutes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_range_start\n base.to_datetime + (rand(1..30) * 30).minutes\n end",
"def add_block block\n block.at self.length\n @blocks << block\n end",
"def add_for_num_blocks(words)\n # We just add to the single block, and we split this when we call\n # #blocks\n @s... | [
"0.6101411",
"0.58748794",
"0.578914",
"0.5707435",
"0.57006514",
"0.5687463",
"0.5662635",
"0.56504726",
"0.5633058",
"0.56010556",
"0.55987895",
"0.5523075",
"0.5510154",
"0.5418222",
"0.5354336",
"0.531994",
"0.5262501",
"0.52583444",
"0.52465177",
"0.5210932",
"0.5204403"... | 0.66548526 | 0 |
The date baseline we are going to be working off of. | def base
@base_time
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def effective_age_calculation_base_date\n age_calculation_base_date || start_date\n end",
"def history_start\n start_dt = case QaServer.config.historical_datatable_default_time_period\n when :month\n history_end_dt - 1.month\n when :year\n ... | [
"0.71690583",
"0.6747204",
"0.6735025",
"0.6399079",
"0.6387229",
"0.63734704",
"0.6343958",
"0.6306791",
"0.62846375",
"0.625235",
"0.6228262",
"0.61988795",
"0.6190504",
"0.6190504",
"0.6183809",
"0.617929",
"0.617929",
"0.617929",
"0.617929",
"0.6167889",
"0.6158597",
"0... | 0.64064115 | 3 |
def stakes stks = Stake.where( asset_id: self.id, asset_type: 'Recording' ) stks += Stake.where( asset_id: self.common_work_id, asset_type: 'CommonWork') end | def contributors_share
ps = 0.0
self.recording_ipis.each do |recording_ipi|
ps += recording_ipi.share
end
ps
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recordings\n recording_ids = self.instrument_tags.where(instrument_tagable_type: 'Recording').pluck(:instrument_tagable_id)\n Recording.where(id: recording_ids)\n end",
"def take_winnings(winnings)\n\t\t@bankroll += winnings\n\t\t@net_winnings += winnings\n\tend",
"def add_common_work common_work\n ... | [
"0.5652778",
"0.54892915",
"0.54211086",
"0.53996325",
"0.52879304",
"0.52835196",
"0.5278367",
"0.52241725",
"0.51919407",
"0.5156141",
"0.51478046",
"0.5129152",
"0.512909",
"0.5113019",
"0.5103297",
"0.5094018",
"0.50792295",
"0.5079123",
"0.5034905",
"0.5028437",
"0.50279... | 0.48773545 | 40 |
def validate_splits total = 0.0 self.stakes.each do |stake| total += stake.split_in_percent end return total == 1.0 end | def uniqify_fields
begin
self.uniq_title = self.title.to_uniq
self.uniq_position = self.position.to_uniq
self.uniq_playbacks_count = self.playbacks_count.to_uniq
self.uniq_likes_count = self.likes_count.to_uniq
self.uuid = UUIDTools::UUID.timestamp_create().to_s if self.uuid.nil?
rescue
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_total_split\n dinner = Checksplitter.new(20, 20, 4)\n \n assert_equal(dinner.total_split, (dinner.total_cost / dinner.number_of_people))\n end",
"def split_total_amount\n total=0\n reim_split_details.each do |split|\n next if split.marked_for_destruction?\n total+=split.percent... | [
"0.7098094",
"0.6871112",
"0.68087304",
"0.6792518",
"0.67121935",
"0.66255325",
"0.656732",
"0.65660715",
"0.6357939",
"0.63392276",
"0.63392276",
"0.63287264",
"0.6299747",
"0.62961155",
"0.6229482",
"0.622237",
"0.6183262",
"0.6158475",
"0.6116033",
"0.6082158",
"0.6032678... | 0.0 | -1 |
for some reason this is not working forget about it until elastic transcoding is implemented | def update_thumbs
File.open(self.cover_art) do |f|
self.default_cover_art = f
self.default_cover_art.recreate_versions!
self.save!
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_es_mapping\n return nil\n end",
"def external_encoding()\n #This is a stub, used for indexing\n end",
"def encoder; end",
"def encoder; end",
"def internal_encoding()\n #This is a stub, used for indexing\n end",
"def transact; end",
"def transcoder\n @transcoder ||= Aw... | [
"0.5891478",
"0.5870499",
"0.56851023",
"0.56851023",
"0.5649199",
"0.56312656",
"0.5546684",
"0.55393493",
"0.5523018",
"0.54984546",
"0.54984546",
"0.5470984",
"0.5461203",
"0.5437177",
"0.54277074",
"0.53655803",
"0.53655803",
"0.53377247",
"0.53213644",
"0.5319038",
"0.53... | 0.0 | -1 |
remove disk_number, disk_count, track_count, available_date | def update_completeness
RecordingCompleteness.update self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_from_disk; end",
"def remove_check_disk(opts)\n opts = check_params(opts,[:disk_info])\n super(opts)\n end",
"def trim_avail(condensed)\n\t condensed.each do |loc|\n\t ##Rails.logger.debug \"\\nes287_debug line(#{__LINE__}) copies = \" + loc[\"copies\"].count.inspect\n\t #... | [
"0.6063606",
"0.59914505",
"0.56213367",
"0.55551034",
"0.55313075",
"0.5529581",
"0.5519742",
"0.54886246",
"0.54834944",
"0.54627603",
"0.54540735",
"0.5408326",
"0.5401871",
"0.5400049",
"0.5396402",
"0.5373724",
"0.53664243",
"0.52615726",
"0.52565914",
"0.5238672",
"0.52... | 0.0 | -1 |
add this to environment variables read from yaml file | def download_url(style = nil, expires_in = 90.minutes)
s3 = Aws::S3::Resource.new
secure_url = self.mp3
unless Rails.env.test?
begin
if self.mp3.include?("https://s3-us-west-1.amazonaws.com/digiramp/")
secure_url = self.mp3.gsub('https://s3-us-west-1.amazonaws.com/digiramp/', '')
else
secure_url = self.mp3.gsub('https://digiramp.s3.amazonaws.com/', '')
end
bucket = s3.bucket(Rails.application.secrets.aws_s3_bucket)
s3_obj = bucket.object(secure_url)
secure_url = s3_obj.presigned_url(:get, expires_in: 600)
rescue => e
secure_url = self.mp3
end
end
secure_url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_file file\n @config.merge!(YAML::load_file \"#{@@env_dir}/#{file}\")\n end",
"def load_env!(options = {})\n source = load_yaml_file(\"env.yml\")\n source = source.fetch(options[:env_section] || env_section, {})\n \n source.each do |key, value|\n if !ENV.has_ke... | [
"0.74099374",
"0.6782808",
"0.66513526",
"0.65029156",
"0.6471585",
"0.6404137",
"0.62664926",
"0.62444943",
"0.62345785",
"0.6156607",
"0.6081455",
"0.6052262",
"0.60515046",
"0.604998",
"0.60393715",
"0.6034629",
"0.6008228",
"0.60052973",
"0.59906244",
"0.5987529",
"0.5944... | 0.0 | -1 |
def update_counter_cache self.content_type = document.file.content_type end | def convertToTwoDigitString inInt
if inInt < 10
return "0" + inInt.to_s;
end
inInt.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_content_type\n if file.present? && file_changed?\n self.content_type = file.file.content_type\n end\n end",
"def update_cache_counters\n target.update_column(:reports_counter, target.reports.count) if target_type == 'Content'\n end",
"def cache!(document) \n if document.is_a?(Hash... | [
"0.68738395",
"0.6633051",
"0.6375145",
"0.62822866",
"0.61433023",
"0.6141906",
"0.6043013",
"0.59969115",
"0.5993716",
"0.5977373",
"0.594908",
"0.59289515",
"0.58197963",
"0.5747973",
"0.5738938",
"0.56505215",
"0.5622825",
"0.5615247",
"0.5613524",
"0.5610799",
"0.560218"... | 0.0 | -1 |
def try_extract_id3_tags if extract_id3_tags && audio_file.present? extract_id3_tags_from_audio_file end end | def check_title
if title.to_s == '' && audio_file.present?
str = File.basename(audio_file_url).gsub(/[_]/, ' ')
self.title = str.gsub(/[.mp3]/, '')
self.save
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_tag(p_audio_file)\n begin\n\n # Log progress\n log.debug \"[Reader] '#{p_audio_file}' :\"\n\n # Read ID3 Tags from the given file, abort if empty\n id3_tag = ID3LiteWrapper.new(p_audio_file)\n return nil if id3_tag.empty?\n\n # Sanitize the newly read ID3 Tag... | [
"0.68592495",
"0.6494725",
"0.6494725",
"0.6465142",
"0.63511527",
"0.6302102",
"0.6200568",
"0.6193943",
"0.6111035",
"0.60735345",
"0.60433966",
"0.5947027",
"0.59442955",
"0.59060854",
"0.5891916",
"0.58830315",
"0.5879336",
"0.5844284",
"0.5783888",
"0.5780949",
"0.573407... | 0.48618716 | 85 |
add hvac Add the daylighting controls for lobby, cafe, dinning and banquet | def add_daylighting_controls(building_vintage)
space_names = ['Banquet_Flr_6','Dining_Flr_6','Cafe_Flr_1','Lobby_Flr_1']
space_names.each do |space_name|
space = self.getSpaceByName(space_name).get
space.addDaylightingControls(building_vintage, false, false)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addDaylightingControls()\n \n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started adding daylighting controls.')\n \n # Add daylighting controls to each space\n self.getSpaces.sort.each do |space|\n added = space.addDaylightingControls(self.template, false, false)\n ... | [
"0.71322644",
"0.5209009",
"0.5202599",
"0.5136928",
"0.5112874",
"0.5109905",
"0.4953279",
"0.49216655",
"0.49124262",
"0.48623702",
"0.4854162",
"0.48344964",
"0.47726038",
"0.4744203",
"0.47417986",
"0.47315714",
"0.47222507",
"0.46913967",
"0.4673408",
"0.46558735",
"0.46... | 0.70055264 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_recipe
@recipe = Recipe.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 recipe_params
params.require(:recipe).permit(:title, :ingredients, :instructions, :category_id, :image)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
Generate a planet based on user's inputs | def generate_planet
puts "\nLet's create a planet from scratch."
print "Please enter its name first: "
name = gets.chomp
print "What's its diameter of this planet in km? "
diameter = gets.chomp.to_f
print "What's its mass in kg? (example of input format: 3.30 x 10^23 ) "
mass = gets.chomp
print "What's the year length of this planet in days? "
yr_length = gets.chomp.to_f
print "What's the distance from the sun to this planet in km? "
dis_from_sun = gets.chomp.to_f
print "How many moons does this planet have? Enter 0 if there is none. "
moons = gets.chomp.to_i
planet = Planet.new({"name" => name, "diameter" => diameter, "mass" => mass, "yr_length" => yr_length, "dis_from_sun" => dis_from_sun, "moons" => moons})
return planet
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_planet()\n puts \"\\nAdding planet. Please tell me more about this planet.\"\n \n print \"Enter the planet name: \"\n name = gets.chomp.capitalize\n \n print \"\\nEnter the planet color: \"\n color = gets.chomp.downcase\n \n print \"\\nEnter planet mass in kg: \"\n mass_kg =... | [
"0.78234327",
"0.7657574",
"0.7433642",
"0.7393319",
"0.7371366",
"0.71264064",
"0.70756966",
"0.7057372",
"0.70562917",
"0.70562917",
"0.70562917",
"0.70562917",
"0.70562917",
"0.7000872",
"0.69893163",
"0.6938458",
"0.6905905",
"0.68091875",
"0.67716867",
"0.67657614",
"0.6... | 0.79343444 | 0 |
Helper method to collect and validate user's choice | def valid_choice(range)
choice = gets.chomp.to_i
until (1..range).include?(choice)
print "Please enter a valid choice: "
choice = gets.chomp.to_i
end
return choice
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_choice\n @user_choice = gets.chomp\n end",
"def get_valid_user_choice ###\n print \"\\nWhat would you like to do next? \\n(Enter 'list planets', 'planet details', 'add planet', or 'exit'.) \"\n @user_choice = gets.chomp.downcase\n\n until @user_choice == \"list planets\" || @user_choice... | [
"0.7081809",
"0.70805854",
"0.69184625",
"0.68849957",
"0.68595177",
"0.67581433",
"0.67222863",
"0.67005074",
"0.66769475",
"0.66724885",
"0.66682655",
"0.666798",
"0.66641414",
"0.6626478",
"0.6576982",
"0.6561172",
"0.6539722",
"0.651585",
"0.6501375",
"0.64915645",
"0.646... | 0.0 | -1 |
Helper method to print out planet list | def print_list(solar_system)
solar_system.planet_list.each_index do |i|
print "#{i + 1}. #{solar_system.planet_list[i]} "
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_planets\n list = \"Planets orbiting #{@star_name}:\\n\"\n @planets.each do |planet|\n list += \"* #{planet.name}\\n\"\n end\n list += \"\\n\"\n return list\n end",
"def print_planets\n puts \"\\n#{@name} has #{@planets.length} planets and was formed #{@formation_year} years ago.... | [
"0.81896716",
"0.8164517",
"0.8155885",
"0.80787927",
"0.80470777",
"0.802067",
"0.8012752",
"0.79885644",
"0.7977885",
"0.79235756",
"0.7829433",
"0.78271127",
"0.77807397",
"0.7678786",
"0.76606923",
"0.76065415",
"0.7598233",
"0.7573457",
"0.7567897",
"0.7555762",
"0.74802... | 0.78889024 | 10 |
that has the number of digits specified as an argument. (The first Fibonacci number has index 1.) | def find_fibonacci_index_by_length_bk(digits_num)
fib_position = 1
first_fib = 1
second_fib = 1
decimal_position = decimal_base(digits_num)
loop do
break if first_fib >= decimal_position
first_fib, second_fib = second_fib, first_fib + second_fib
fib_position += 1
end
fib_position
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_fibonacci_index_by_length(digits)\n index = 1\n last_fib_number = 0\n fib_number = 1\n loop do\n break if fib_number >= 10 ** (digits - 1)\n\n fib_number += last_fib_number\n last_fib_number = fib_number - last_fib_number\n index += 1\n end\n\n index\nend",
"def find_fibonacci_index_by... | [
"0.80817133",
"0.7976853",
"0.7937612",
"0.7924988",
"0.79147226",
"0.7909445",
"0.7904327",
"0.78173935",
"0.78128386",
"0.778339",
"0.77623636",
"0.77336115",
"0.76942456",
"0.76265967",
"0.76265967",
"0.76014495",
"0.7590078",
"0.75671375",
"0.75468105",
"0.7531966",
"0.75... | 0.752822 | 20 |
def decimal_base(n) ten_to_position = 1 loop do n = 1 break if n == 0 ten_to_position = 10 end ten_to_position end | def decimal_base(n)
10**(n-1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toBase(n, base)\n return n.to_s(base) if base > 0\n return '0' if n.zero?\n\n digits = []\n while n != 0\n n, remainder = n.divmod(base)\n if remainder < 0\n n += 1\n remainder -= base\n end\n digits << remainder\n end\n digits.join.reverse\nend",
"def super_digit(n)\n while n >=... | [
"0.74928284",
"0.7391296",
"0.73467326",
"0.7299868",
"0.72959495",
"0.7256317",
"0.72488725",
"0.7213806",
"0.71847534",
"0.7150823",
"0.7109661",
"0.7091952",
"0.7083971",
"0.705517",
"0.7028662",
"0.7022338",
"0.70145804",
"0.700829",
"0.6998789",
"0.6951361",
"0.6947307",... | 0.8483405 | 0 |
2835 pixels per meter is basically 72dpi | def initialize(width, height)
@width, @height = width, height
@pixels = Array.new(@height) { Array.new(@width) { "00" } }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dpi\n {:x=>dpi_x,:y=>dpi_y}\n end",
"def i2p(inches)\n (inches * @target_dpi).to_i\n end",
"def dpi_y\n self.class.dpm_to_dpi(dpm_y)\n end",
"def zoom\n `#@native.devicePixelRatio`\n end",
"def image_dpi id\n image = get_image(id)\n raise \"Surprising non-symetrical dpi\" if image... | [
"0.7078284",
"0.6549018",
"0.6362042",
"0.63123435",
"0.6292032",
"0.62706035",
"0.6225801",
"0.62146026",
"0.6120312",
"0.6119724",
"0.6097993",
"0.59607846",
"0.59418887",
"0.5921663",
"0.5875648",
"0.58702224",
"0.5837363",
"0.5796204",
"0.5796204",
"0.5796204",
"0.5753857... | 0.0 | -1 |
Note: the 'right' pattern to use is actually "Vl<2v2V2l<2V2", but that only works on 1.9.3 | def write_dib_header(file)
file << [DIB_HEADER_SIZE, @width, @height, 1, BITS_PER_PIXEL,
0, pixel_array_size, PIXELS_PER_METER, PIXELS_PER_METER,
0, 0].pack("V3v2V6")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tr_s(p0, p1) end",
"def tag_pattern\n @tag_pattern || 'v%s'\n end",
"def difftype() [1, \"s\"] end",
"def test_verse_range_and_separated_verse\n text = 'Ruth 2,1-3.11'\n t1, t2 = text.split(dot)\n assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 3... | [
"0.57544446",
"0.5624163",
"0.5485726",
"0.53944135",
"0.5366539",
"0.5281899",
"0.527217",
"0.5216387",
"0.5179667",
"0.5121564",
"0.5022791",
"0.50056535",
"0.49941632",
"0.49561542",
"0.4916982",
"0.49066222",
"0.4893566",
"0.48844594",
"0.48839042",
"0.48837075",
"0.48604... | 0.0 | -1 |
The attributes of a PhidgetStepper | def attributes
super.merge({
:inputs => inputs.size,
:steppers => steppers.size,
})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_steps\n self.steps\n end",
"def attrs\n @attrs\n end",
"def attr_info; end",
"def attributes\n instance_values\n end",
"def attributes\n data[:attributes]\n end",
"def attributes\n instance_values\n end",
"def attributes\n end",
"def attributes\n ... | [
"0.59020156",
"0.5777914",
"0.5753583",
"0.57328516",
"0.57256657",
"0.57071215",
"0.57026625",
"0.5694358",
"0.5684938",
"0.5680471",
"0.5680448",
"0.56314987",
"0.56223154",
"0.5595958",
"0.55880994",
"0.55880994",
"0.55880994",
"0.55880994",
"0.55880994",
"0.55880994",
"0.... | 0.54992485 | 33 |
Displays data for the digital input | def inspect
"#<#{self.class} @index=#{index}, @state=#{state}>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n if @input.devolucion\n @es_devolucion = \"Devolución\"\n else\n @es_devolucion = [\"Remito: \",@input.remito].join\n end\n end",
"def display_data\n\t\t\t\"#{@model} #{@color} #{@horsepower} #{@year} #{@brand} #{@mpg}\"\n\t\tend",
"def d(data)\n data.send :display \n \"\\n\".se... | [
"0.6648387",
"0.6565481",
"0.6255316",
"0.62418574",
"0.6169812",
"0.6112287",
"0.6083041",
"0.60418856",
"0.5982994",
"0.5953679",
"0.58847886",
"0.5870912",
"0.5865864",
"0.58593875",
"0.5847815",
"0.5846593",
"0.5845567",
"0.57900524",
"0.57850885",
"0.5766434",
"0.5764228... | 0.0 | -1 |
Displays data for the stepper | def inspect
"#<#{self.class} @index=#{index}, @acceleration_min=#{acceleration_min}, @acceleration_max=#{acceleration_max}, @current_min=#{current_min}, @current_max=#{current_max}, @engaged=#{engaged}, @position_min=#{position_min}, @position_max=#{position_max}, @velocity_min=#{velocity_min}, @velocity_max=#{velocity_max}>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n\t#@step = user_information\n end",
"def do_next\n update_screen(get_step_content(@step + 1, @editor.value, @output.value))\n end",
"def show\n case step\n when :parameters\n # Create an initial input parameter if there is none\n @algorithm.input_parameters.build if @algorithm.in... | [
"0.64014983",
"0.6322269",
"0.61051285",
"0.61007094",
"0.60106134",
"0.60051566",
"0.5974355",
"0.5900076",
"0.5835587",
"0.5776174",
"0.57733434",
"0.5734561",
"0.5703235",
"0.56873846",
"0.56829464",
"0.5676335",
"0.5670373",
"0.5670327",
"0.5655762",
"0.5652419",
"0.56070... | 0.0 | -1 |
Sets the acceleration of a stepper, in (micro)steps per second squared, or raises an error. | def acceleration=(new_acceleration)
Klass.setAcceleration(@handle, @index, new_acceleration.to_f)
new_acceleration
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accelerate (rateOfAcceleration)\n @speed = @speed + rateOfAcceleration\n end",
"def accel\n @speed += 7\n end",
"def accelerate\n @speed = @speed + @accelerator\n end",
"def acceleration(state_object, t)\n k = 10\n b = 1\n (- k * state_object.position) - (b * state_object.velocity)\nend",
... | [
"0.6187451",
"0.61048514",
"0.60582536",
"0.60556734",
"0.6005321",
"0.5939681",
"0.59366953",
"0.58714765",
"0.5864271",
"0.5863374",
"0.5802886",
"0.58006376",
"0.57577443",
"0.5673338",
"0.5644646",
"0.5620917",
"0.5570925",
"0.555828",
"0.55382943",
"0.55382943",
"0.55065... | 0.6707642 | 1 |
Sets the stepper's current usage limit, in Amps, or raises an error. | def current_limit=(new_current_limit)
Klass.setCurrentLimit(@handle, @index, new_current_limit.to_f)
new_current_limit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def... | [
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466"... | 0.6615679 | 29 |
Sets the current position of a stepper, in (micro)steps, or raises an error. | def current_position=(new_current_position)
Klass.setCurrentPosition(@handle, @index, new_current_position.to_i)
new_current_position
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current=(new_value)\n value = (new_value)%steps\n @dirty = @current != value\n @current = value\n end",
"def progressSetPosition _obj, _args\n \"_obj progressSetPosition _args;\" \n end",
"def set_invalid_steps(steps)\n self.invalid_steps = steps\n end",
"def pt_step _value, _force=... | [
"0.5806139",
"0.56053126",
"0.55437475",
"0.5539134",
"0.55381596",
"0.5532316",
"0.55119836",
"0.54062337",
"0.5401332",
"0.5385979",
"0.53545046",
"0.5323149",
"0.5322548",
"0.5318022",
"0.5297276",
"0.52906615",
"0.52874625",
"0.52843904",
"0.5279208",
"0.5277352",
"0.5270... | 0.5665552 | 1 |
Returns the engaged state of the stepper. | def engaged
ptr = ::FFI::MemoryPointer.new(:int)
Klass.getEngaged(@handle, @index, ptr)
(ptr.get_int(0) == 0) ? false : true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state\n @current_state\n end",
"def current_step\n\t\t@current_step || steps.first\t\n\tend",
"def current_step \n @current_step || steps.first\n end",
"def current_step\r\n\t @current_step || steps.first\r\n\tend",
"def current_step\n @current_step || steps.first\n end",
"def curre... | [
"0.6736628",
"0.65314066",
"0.648196",
"0.6467491",
"0.64334285",
"0.6423051",
"0.62574077",
"0.624839",
"0.6177428",
"0.617205",
"0.617205",
"0.617205",
"0.617205",
"0.617205",
"0.617205",
"0.617205",
"0.617205",
"0.617205",
"0.617205",
"0.6163447",
"0.6140183",
"0.6139224... | 0.0 | -1 |
Sets the engaged state of the Phidget. | def engaged=(new_state)
tmp = new_state ? 1 : 0
Klass.setEngaged(@handle, @index, tmp)
new_state
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end"... | [
"0.61920553",
"0.61920553",
"0.6154074",
"0.6154074",
"0.6154074",
"0.6154074",
"0.6154074",
"0.6154074",
"0.6154074",
"0.60919803",
"0.60879356",
"0.60879356",
"0.60879356",
"0.60879356",
"0.60879356",
"0.60879356",
"0.60879356",
"0.6069289",
"0.5995986",
"0.5988838",
"0.589... | 0.7006594 | 1 |
Sets the target position of a stepper, in (micro)steps, or raises an error. | def target_position=(new_target_position)
Klass.setTargetPosition(@handle, @index, new_target_position.to_i)
new_target_position
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_move_to_target\n return unless PONY::ERRNO.check_sequence(current_act)\n stop_all_movements\n xpos = target.x + (flip ? -@acts[1] : @acts[1])\n ypos = target.y + @acts[2]\n goto(xpos, ypos, @acts[3], @acts[4], @acts[5] || 0)\n end",
"def setpoint_to_target\n @setpoint = @freq_tar... | [
"0.62203336",
"0.5957737",
"0.587027",
"0.5716573",
"0.55401325",
"0.5535329",
"0.5513744",
"0.5488356",
"0.54202664",
"0.53962225",
"0.5392546",
"0.5384767",
"0.5373468",
"0.53674364",
"0.53669",
"0.53264296",
"0.53110605",
"0.53110605",
"0.53110605",
"0.53110605",
"0.531106... | 0.6607499 | 0 |
Sets the velocity limit of a stepper, in (micro)steps per second, or raises an error. | def velocity_limit=(new_velocity_limit)
Klass.setVelocityLimit(@handle, @index, new_velocity_limit.to_f)
new_velocity_limit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def velocity_limit=(new_velocity_limit)\n Klass.setVelocityLimit(@handle, @index, new_velocity_limit.to_f)\n new_velocity_limit\n end",
"def set_velocity action = :increment\n if action == :increment and @velocity <= 3\n @velocity += 1\n\n elsif action == :decrement and @velocity > 1\n ... | [
"0.7112307",
"0.6255239",
"0.6249731",
"0.6048269",
"0.59822744",
"0.59822744",
"0.5972854",
"0.589134",
"0.57726794",
"0.5745471",
"0.5715279",
"0.57056004",
"0.5559399",
"0.5486125",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
... | 0.72637236 | 0 |
Create a NxN grid of points on a face of the cube. Note that this will generate (N+1)(N+1) points. Each point is projected on the sphere and stored in an array. Note that all these are points on the unit sphere, and so their distance to the origin is 1, and so each point can be used as its own normal. | def grid(face, n)
dx = 2.0/n
dy = 2.0/n
a = Array.new
n += 1
n.times do |j|
y = -1.0 + j*dy
n.times do |i|
x = -1.0 + i*dx
lon, lat = QuadSphere::CSC.inverse(face, x, y)
sx = Math::cos(lat) * Math::cos(lon)
sy = Math::cos(lat) * Math::sin(lon)
sz = Math::sin(lat)
a << [sx,sy,sz]
end
end
a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_points(u_count, v_count)\n points = []\n v_count.times do |iv|\n row = []\n u_count.times do |iu|\n u = map1d(iu, (0..u_count), U_RANGE)\n v = map1d(iv, (0..v_count), V_RANGE)\n # default scale: 50, param: Array.new(12, 1) and mesh_distortion: 0\n row << superformula(u: u, ... | [
"0.5928719",
"0.570356",
"0.56557053",
"0.56169516",
"0.56094754",
"0.5591064",
"0.55714774",
"0.5485938",
"0.54362124",
"0.5412299",
"0.5383223",
"0.5371151",
"0.53186864",
"0.52793384",
"0.5258932",
"0.52141297",
"0.52060217",
"0.5205415",
"0.517512",
"0.51573133",
"0.51541... | 0.7749322 | 0 |
p grid(0, 3) Create triangle strips to represent a NxN mesh. The given array should then contain (N+1)2 points, arranged as N+1 rows of N+1 points. | def mesh2strips(n,a)
dx = 2.0/n
dy = 2.0/n
row = n+1
n.times do |j|
glBegin(GL_TRIANGLE_STRIP)
rowi = j*row
row.times do |x|
add_vertex(a[rowi+x])
add_vertex(a[rowi+row+x])
end
glEnd
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_grid(board_array)\n\t# split into triplets\n\ttriplets_array = []\n board_array.each { |array| triplets_array << array.each_slice(3).to_a }\n\n # shuffle the triplets\n shuffle_container = [[], [], []]\n 9.times do |row|\n 3.times do |column|\n current_array = triplets_array[row][column]\n ... | [
"0.62033063",
"0.60679984",
"0.6010272",
"0.58452564",
"0.58127",
"0.5795336",
"0.5707064",
"0.57053405",
"0.56979764",
"0.5663744",
"0.55985594",
"0.5590872",
"0.55771965",
"0.55767393",
"0.5552159",
"0.55489373",
"0.553704",
"0.5499699",
"0.5486645",
"0.54455215",
"0.532118... | 0.7099372 | 0 |
Initialize Author: Puneet Date: 02/02/2018 Reviewed By: Sunil | def initialize(data)
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(title, author)\n @title = title\n @author = author\nend",
"def initialize(title, author,year=\"unknown\", edition=\"unknown\")\n @title = title\n @author = author\n @checked_out = false\n @current_patron = nil\n @year_published = year\n @edition = edition\n @reviews = {}\n ... | [
"0.7232199",
"0.7211749",
"0.71372503",
"0.7125025",
"0.70742327",
"0.7046248",
"0.6949262",
"0.6947915",
"0.69212437",
"0.6879615",
"0.68517184",
"0.6827688",
"0.67746025",
"0.675069",
"0.67459995",
"0.6734091",
"0.67256474",
"0.67256474",
"0.6716489",
"0.66928846",
"0.66817... | 0.0 | -1 |
Perform Author: Puneet Date: 02/02/2018 Reviewed By: Sunil | def perform
set_user(@data['user'])
set_client_token(@data['client_token'])
set_oracle_price_points(@data['oracle_price_points'])
set_pending_critical_interactions(@data['pending_critical_interactions']) if @data['pending_critical_interactions'].present?
set_client_token_planner(@data['client_token_planner']) if @data['client_token_planner'].present?
set_chain_interaction_params(@data['chain_interaction_params']) if @data['chain_interaction_params'].present?
set_client_balances(@data['client_balances']) if @data['client_balances'].present?
set_token_supply_details(@data['token_supply_details']) if @data['token_supply_details'].present?
set_client_stats(@data['client_stats']) if @data['client_stats'].present?
set_api_console_data(@data['api_console_data']) if @data['api_console_data'].present?
set_client_bt_addresses_data(@data['client_bt_addresses']) if @data['client_bt_addresses'].present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paper\n reviewer_recommendations_task.paper\n end",
"def pre_submission_date_status\n 'New Announcement'\n end",
"def review_committee_decision\n application_review_decision_type.title if application_review_decision_type\n end",
"def description_complexity(pr)\n pull_req = pull_req_ent... | [
"0.56016713",
"0.5492883",
"0.5434874",
"0.5431683",
"0.536855",
"0.5357148",
"0.5353368",
"0.53416604",
"0.53150004",
"0.5254495",
"0.5253263",
"0.52373445",
"0.5222971",
"0.52184725",
"0.5191292",
"0.5188476",
"0.5155466",
"0.5154289",
"0.515212",
"0.5150933",
"0.51405525",... | 0.0 | -1 |
Set client stats details Author: Puneet Date: 02/02/2018 Reviewed By: | def set_client_stats(client_stats_data)
@client_stats = CompanyApi::Response::Entity::ClientStats.new(client_stats_data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate_client_usage(client)\n client_id = client.id\n registration_count = User.using_client_shard(client: client).where(client_id: client_id).count\n kyc_submissions_count = UserKycDetail.using_client_shard(client: client).\n where(client_id: client_id).sum(:submission_count)\n\n ... | [
"0.632931",
"0.609067",
"0.60432386",
"0.60432386",
"0.6000351",
"0.59391373",
"0.58106226",
"0.5807779",
"0.57885337",
"0.5697464",
"0.569321",
"0.5660587",
"0.5552315",
"0.5550092",
"0.5515177",
"0.5488684",
"0.5468579",
"0.546816",
"0.546816",
"0.54330796",
"0.53912634",
... | 0.73293805 | 0 |
Set API Console details Author: Puneet Date: 02/02/2018 Reviewed By: | def set_api_console_data(api_console_data)
@api_console_data = CompanyApi::Response::Entity::ApiConsoleData.new(api_console_data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def author\n @info[:Author]\n end",
"def set_AuthorUsername(value)\n set_input(\"AuthorUsername\", value)\n end",
"def set_AuthorName(value)\n set_input(\"AuthorName\", value)\n end",
"def author\n @author_data ||= read(\"/user/#{@author}/about.json\", :handler =>... | [
"0.62011385",
"0.5934105",
"0.58770674",
"0.57877433",
"0.5744884",
"0.5721576",
"0.57034785",
"0.5681357",
"0.5681357",
"0.5675775",
"0.56682366",
"0.56624544",
"0.5658912",
"0.5618394",
"0.5610826",
"0.5599454",
"0.55768776",
"0.55716026",
"0.55566204",
"0.55275494",
"0.552... | 0.5188679 | 71 |
Set Client BT Addresss Data Author: Puneet Date: 02/02/2018 Reviewed By: | def set_client_bt_addresses_data(client_bt_addresses_data)
@client_bt_addresses = CompanyApi::Response::Entity::ClientBrandedTokenAddresses.new(client_bt_addresses_data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_address\n end",
"def set_client_address\n @client_address = ClientAddress.find(params[:id])\n end",
"def set_addresses=(v)\n self.addresses = build_addresses(v)\n end",
"def update_contact_info txn\n AddressManager::set_user_address txn.user, txn\n end",
"def set_client\n @cli... | [
"0.6881441",
"0.6312769",
"0.60506237",
"0.6017915",
"0.59968686",
"0.5966925",
"0.59465563",
"0.59386486",
"0.59386486",
"0.59386486",
"0.591972",
"0.5915055",
"0.5915055",
"0.59133244",
"0.59031093",
"0.58883625",
"0.58808154",
"0.58808154",
"0.58686054",
"0.5835885",
"0.58... | 0.7541487 | 0 |
get(Symbol) method that returns a node by the id returns | def get id
@nodes[id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_node(id)\n @nodes[id.to_i]\n end",
"def get_node(id)\n get_object('node', id)\n end",
"def node_by_id(id)\r\n @nodes.each do |n|\r\n return n if n.attributes['id'] == id \r\n end\r\n end",
"def get_node_by_id(id, options={})\n options[:exac... | [
"0.77852273",
"0.7746689",
"0.74849606",
"0.7415566",
"0.7203441",
"0.6996068",
"0.6890222",
"0.6885043",
"0.6787701",
"0.6758027",
"0.66858804",
"0.66643023",
"0.66091704",
"0.6607736",
"0.6528776",
"0.65238875",
"0.65092194",
"0.6489196",
"0.64593965",
"0.64387286",
"0.6398... | 0.79646957 | 0 |
add(Symbol) method that initialize a node | def add id
return unless @nodes[id].nil?
@nodes[id] = Array.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_node(node); end",
"def add_node(node)\n if node.respond_to?(:to_sym)\n node = Woodhouse::Layout::Node.new(node.to_sym) \n end\n expect_arg :node, Woodhouse::Layout::Node, node\n @nodes << node\n node\n end",
"def init_node\n end",
"def init_node\n end",
"def ad... | [
"0.7198449",
"0.68868583",
"0.6852834",
"0.6852834",
"0.67188424",
"0.66785353",
"0.64642626",
"0.6371331",
"0.6333908",
"0.6322772",
"0.63000983",
"0.6280861",
"0.62774485",
"0.6263306",
"0.6238344",
"0.6218626",
"0.6192438",
"0.6153654",
"0.6151166",
"0.6151166",
"0.6116891... | 0.0 | -1 |
connect(Edge) method that adds a connection to the list of nodes returns | def connect edge
self.add edge.src
self.add edge.dst
@nodes[edge.src] << edge
edge
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect_nodes(node1, node2)\n # node1.connect(node2)\n end",
"def __connect__(node)\n raise \"Cannot connect to a node which is not on the same graph!\" if node.graph != @this.graph\n node.in.instance_exec(@this) { |n| @others << n }\n @graph.instance_eval { @changed = true }\n end",
"def con... | [
"0.7149291",
"0.7143974",
"0.7126218",
"0.69445294",
"0.68873805",
"0.68495196",
"0.672731",
"0.67185426",
"0.6711184",
"0.6705357",
"0.6662451",
"0.65780455",
"0.65737826",
"0.65538955",
"0.6543518",
"0.65326816",
"0.6487913",
"0.6485545",
"0.6385783",
"0.635903",
"0.6352993... | 0.8483913 | 0 |
distance(List) return the cost of a given route returns | def distance *path
cost, edge_exists = 0, false
# Adds the cost of the next move
neighbors = @nodes[path.shift]
neighbors.each do |node|
if node.dst == path.first
edge_exists = true
cost += node.length
break
end
end
# Iterates in depth when neighbor exists
return -1 unless edge_exists
if path.length > 1
sub_cost = distance *path
return -1 if sub_cost == -1
cost += sub_cost
end
cost
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate(route)\n dist = 0\n route.each_cons(2) { |points| dist = dist + points[0].distance(points[1])}\n dist\nend",
"def distance\n distance = 0\n @solution.each { |route| distance += route.distance }\n return distance\n end",
"def distance\n if valid\n route[:distance].... | [
"0.7838013",
"0.7424868",
"0.7113017",
"0.70428985",
"0.6720807",
"0.67075056",
"0.66964525",
"0.66530675",
"0.6548845",
"0.64613354",
"0.642989",
"0.6380129",
"0.63785625",
"0.6377925",
"0.6353721",
"0.6333371",
"0.6329722",
"0.6329722",
"0.6278009",
"0.62769645",
"0.6270872... | 0.6151295 | 26 |
step_number(List, Symbol, Hash, String) return the number of steps from the first route returns | def step_number visit_path, dst, limits, condition=nil
return route(visit_path, dst, limits, UNTIL).first.nodes.length - 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def opinion_wizard_step_number(step)\n step.to_s.split(\"_\").last.to_i\n end",
"def number_of_steps\n case current_instruction.opcode\n when 3, 4\n 2\n else\n 4\n end\n end",
"def number_of_steps\n case current_instruction.opcode\n when 3, 4\n 2\n else\n 4... | [
"0.69344",
"0.67370206",
"0.67370206",
"0.67370206",
"0.65958005",
"0.65727234",
"0.65630835",
"0.6475925",
"0.64521587",
"0.63310933",
"0.63210225",
"0.6263403",
"0.62130374",
"0.62116575",
"0.6207247",
"0.61998117",
"0.61928505",
"0.61400825",
"0.61400825",
"0.6122192",
"0.... | 0.6662546 | 4 |
path_number(List, Symbol, Hash, String) return the number of paths with in the limits returns | def path_number visit_path, dst, limits, condition=EG
paths = route(visit_path, dst, limits, condition)
select_condition = condition == EG ? EG : condition == UNTIL ? LESS : UNTIL
return (paths.select {|path| eval final_eval( select_condition, limits )}).length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path_count(*args)\n path_rels(*args).size\n end",
"def get_num_paths(grid_width)\n n, r = grid_width * 2, grid_width\n ((n - r + 1)..n).inject(:*) / (1..r).inject(:*)\nend",
"def count_paths(grid_size)\n factorial(2*grid_size) / (factorial(grid_size) * factorial(grid_size))\nend",
"def path_count(... | [
"0.7148266",
"0.7054428",
"0.6922436",
"0.6717221",
"0.6602749",
"0.6582553",
"0.65792847",
"0.62654996",
"0.6254104",
"0.623642",
"0.62050784",
"0.61050344",
"0.610447",
"0.60559106",
"0.60262126",
"0.6015799",
"0.6009623",
"0.5996869",
"0.58924735",
"0.57638484",
"0.5754598... | 0.7635548 | 0 |
step_number(List, Symbol, String) return cost of the shortest route returns | def shortest_route visit_path, dst, condition=nil
return route(visit_path, dst).first.cost
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solver(flights)\n (p all_paths(flights)).min_by { |path| cost_of_path(path) }\nend",
"def min_cost_climbing_stairs(cost)\n [step(cost, 0), step(cost, 1)].min\nend",
"def min_cost(stairs)\n min_step_cost = [stairs[0], stairs[1]]\n idx = 2\n while idx < stairs.length\n min_step_cost[idx] = stairs[idx... | [
"0.64945066",
"0.63051593",
"0.62998176",
"0.62081134",
"0.6085776",
"0.6065148",
"0.6048964",
"0.60050386",
"0.5935265",
"0.5918307",
"0.58405596",
"0.5838905",
"0.57887113",
"0.57626945",
"0.57612133",
"0.5753281",
"0.575032",
"0.57486767",
"0.5683631",
"0.5676609",
"0.5644... | 0.60641307 | 6 |
route(List, Symbol, Hash, String) return a list of routes returns | def route visit_path, dst=nil, limits=nil, condition=UNTIL
paths = trips(visit_path, dst, limits, condition)
return paths
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def routes_list\n response = RestClient.get(\n BASE_URL,\n params: {command: 'routeList', a: AGENCY}\n )\n\n parse_routes_response(response.body)\n end",
"def routes(&block); end",
"def routes(&block); end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def routes=(_arg0); en... | [
"0.7126989",
"0.707113",
"0.707113",
"0.6921695",
"0.6921695",
"0.6921695",
"0.685512",
"0.685512",
"0.67470664",
"0.6745525",
"0.67106533",
"0.6656632",
"0.6656632",
"0.6656632",
"0.6656632",
"0.6656632",
"0.6656632",
"0.6656632",
"0.6656632",
"0.6656632",
"0.6656632",
"0.... | 0.0 | -1 |
route(List, Symbol, Hash, String) method that calculate all the possible routs from a source to a destination params: visit_path: A list of nodes that represent a path that is been visit dst: The end node limits There are two types of limits that restrict the search by cost and by depth condition The conditions that the limits need to valid paths Paths to explore dst_paths Path that reached condition | def trips visit_path, dst, limits, condition, paths=Array.new, dst_paths=Array.new
node = visit_path.nodes.last
neighbors = @nodes[node]
if neighbors.empty?
visit_path.fanal = true
paths << visit_path
return paths
end
neighbors = neighbors.sort_by {|node| node.length}
neighbors.each do |neighbor|
path = Path.new visit_path.nodes.clone
path.cost = visit_path.cost + neighbor.length
path.final = path.nodes.include? neighbor.dst
path.final = eval final_eval( condition, limits ) unless limits.nil?
path.nodes << neighbor.dst
if (neighbor.dst == dst && !path.final)
d_path = Path.new path.nodes.clone
d_path.cost = path.cost
d_path.final = true
dst_paths << d_path
end
paths << path
end
while(paths.length > 0 && paths.map {|path| path.final}.include?(false))
path = paths.shift
unless path.final
trips( path, dst, limits, condition, paths, dst_paths)
else
dst_paths << path
end
end
paths = (dst_paths + paths).select { |path| path.nodes.last == dst && path.final == true }
return paths
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def route visit_path, dst=nil, limits=nil, condition=UNTIL\n paths = trips(visit_path, dst, limits, condition)\n return paths\n end",
"def get_routes(params)\n graph_data = create_data(params)\n if graph_data.is_a?(Array)\n graph_data.each do |data|\n add_vertex(data[0][0], data[0][1])\n... | [
"0.7423867",
"0.68454725",
"0.6655849",
"0.6323839",
"0.60121167",
"0.58929586",
"0.5879709",
"0.57561725",
"0.5721653",
"0.57182723",
"0.56451654",
"0.56361437",
"0.55888575",
"0.5572061",
"0.5567938",
"0.5552057",
"0.5552057",
"0.5552057",
"0.5524382",
"0.5513683",
"0.55053... | 0.6666883 | 2 |
step_number(Hash, String) return the eval expression for the conditions returns | def final_eval condition, limits
return "#{condition[:steps]}#{limits[:steps]}" if limits.has_key? :steps
return "#{condition[:cost]}#{limits[:cost]}" if limits.has_key? :cost
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculation\n wizard_step(nil) { { next_step: :calculate_next_step, cache_index: LbttController } }\n end",
"def opinion_wizard_step_number(step)\n step.to_s.split(\"_\").last.to_i\n end",
"def next_step\n (history.keys.last.to_i + 1).to_s\n end",
"def step_result; end",
"de... | [
"0.5798169",
"0.56881636",
"0.5677804",
"0.5475534",
"0.54139423",
"0.53727996",
"0.5353041",
"0.5338501",
"0.53065944",
"0.53065944",
"0.53065944",
"0.5299751",
"0.5289309",
"0.52679855",
"0.52373195",
"0.5217548",
"0.5089139",
"0.50588447",
"0.50575215",
"0.50575215",
"0.50... | 0.5814103 | 0 |
Sends password reset email. | def send_reset_email
UserMailer.password_reset(self).deliver_now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_password_reset_email\n\t\tUserMailer.password_reset(id, self.reset_token).deliver_later\n \tend",
"def send_password_reset_email\r\n UserMailer.password_reset(self).deliver_now\r\n end",
"def send_password_reset_email\r\n UserMailer.password_reset(self).deliver_now\r\n end",
"de... | [
"0.8788405",
"0.8677096",
"0.8677096",
"0.8661554",
"0.86603385",
"0.86603385",
"0.86603385",
"0.86603385",
"0.86603385",
"0.86603385",
"0.86603385",
"0.86603385",
"0.86603385",
"0.86564267",
"0.8650267",
"0.86485726",
"0.8646728",
"0.8630811",
"0.8630811",
"0.8630811",
"0.86... | 0.0 | -1 |
two below methods are in this section because they are callbacks called during particular time during user object's life | def downcase_email
self.email = email.downcase
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callbacks; end",
"def callbacks; end",
"def callback\n end",
"def callback\n\n end",
"def callback_phase\n super\n end",
"def callback\n\tend",
"def after_set_callback; end",
"def after_update; end",
"def after_update; end",
"def after_generate_callbacks; end",
"def ready; e... | [
"0.7751526",
"0.7751526",
"0.6975495",
"0.6904932",
"0.68906814",
"0.68224365",
"0.6565693",
"0.64858997",
"0.64858997",
"0.64770776",
"0.64602613",
"0.64602613",
"0.6431811",
"0.6431811",
"0.63858294",
"0.63858294",
"0.63473094",
"0.6336997",
"0.6336997",
"0.6336997",
"0.633... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.