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 |
|---|---|---|---|---|---|---|
PATCH/PUT /preparar_mates/1 PATCH/PUT /preparar_mates/1.json | def update
@empresa = Empresa.find(params[:empresa_id])
@producto = @empresa.productos.find(params[:producto_id])
@preparar_mate = @producto.preparar_mates.find(params[:id])
respond_to do |format|
if @preparar_mate.update(preparar_mate_params)
format.html { redirect_to empresa_producto_preparar_mates_path, notice: 'Preparar mate was successfully updated.' }
format.json { render :show, status: :ok, location: @preparar_mate }
else
format.html { render :edit }
format.json { render json: @preparar_mate.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @person.seat\n render json: {errors: 'Cannot update a seated person'}, status: 422\n else\n @person.update person_params\n render json: @person\n end\n end",
"def update\n @mate = Mate.find(params[:id])\n\n respond_to do |format|\n if @mate.update_attributes(pa... | [
"0.60174227",
"0.5998688",
"0.5731182",
"0.5701388",
"0.5689525",
"0.56807256",
"0.56611806",
"0.565699",
"0.5638485",
"0.5633029",
"0.56301004",
"0.56210715",
"0.5616712",
"0.5614435",
"0.5582845",
"0.5559411",
"0.5553166",
"0.55479866",
"0.55236256",
"0.55137575",
"0.550263... | 0.62828004 | 0 |
DELETE /preparar_mates/1 DELETE /preparar_mates/1.json | def destroy
@empresa = Empresa.find(params[:empresa_id])
@producto = @empresa.productos.find(params[:producto_id])
@preparar_mate = @producto.preparar_mates.find(params[:id])
@preparar_mate.destroy
respond_to do |format|
format.html { redirect_to empresa_producto_preparar_mates_path, notice: 'Preparar mate was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @mld_mate.destroy\n respond_to do |format|\n format.html { redirect_to mld_mates_url, notice: \"Mld mate was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mate = Mate.find(params[:id])\n @mate.destroy\n\n respond_to do |for... | [
"0.688922",
"0.671094",
"0.6630015",
"0.6618255",
"0.6605488",
"0.65292263",
"0.65272784",
"0.6520473",
"0.64592975",
"0.6458089",
"0.6454195",
"0.64133364",
"0.63949627",
"0.63940597",
"0.63857144",
"0.63722825",
"0.6369918",
"0.63647854",
"0.6321003",
"0.63159484",
"0.63141... | 0.6569586 | 5 |
Use callbacks to share common setup or constraints between actions. Never trust parameters from the scary internet, only allow the white list through. | def preparar_mate_params
params.require(:preparar_mate).permit(:título, :descrición)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_hook; end",
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def before_action \n end",
"def before_setup; end",
"def my_action_params\n params.require(:my_action).permit(:name, :url, :active, :provider_id)\n end",
"def define_a... | [
"0.60899144",
"0.6081489",
"0.6010213",
"0.5874203",
"0.579901",
"0.57524973",
"0.5592823",
"0.5515582",
"0.5515582",
"0.5515582",
"0.5406058",
"0.54022133",
"0.53855455",
"0.53680074",
"0.53510565",
"0.5347828",
"0.5346682",
"0.53387135",
"0.53360146",
"0.5315981",
"0.530345... | 0.0 | -1 |
Before filters Confirms an admin user. | def admin_user
redirect_to(root_url) unless current_user.admin?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorize_admin\n return if current_customer.admin?\n redirect_to root_path, alert: 'Admins only!' unless current_customer and current_customer.admin?\n end",
"def admin_user\n redirect_to(root_url) and flash[:danger] = \"Only admins can do that!\" unless current_user.admin?\n\n end",
"def v... | [
"0.713229",
"0.710992",
"0.7098981",
"0.70898515",
"0.7083098",
"0.7023689",
"0.7018312",
"0.701766",
"0.701766",
"0.699869",
"0.699869",
"0.69962054",
"0.69962054",
"0.6994126",
"0.69935423",
"0.69934475",
"0.6989941",
"0.6962073",
"0.69528276",
"0.6946117",
"0.6945809",
"... | 0.0 | -1 |
Retrieve all the tag guids for a provided service entry and tag group | def tag_guids_for_tag_group(service_entry, tag_group)
guids = service_entry['TagGuids']
return [] if guids.blank?
# The first element of the tag strings ARE the tag group. We'll group
# by that value and return the requested group. This saves a fair amount
# of logic from having to be copy and pasted sifting out only the guids we
# need for a particular operation
Array.wrap(guids).group_by { |guid| service_tag_parts(guid).first }[tag_group] || []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tags\n get.tagGuids\n end",
"def get_tags() tag_ids.inject([]) { |l, tag_id| l << get_tag_from_id(tag_id) } end",
"def add_tag_return_IDs(tag)\n # Split and strip the tags\n tags = tag.split(\",\").collect{|x| x.strip}\n i = 0\n iDs = []\n while i < tags.count do\n # Check if... | [
"0.68090504",
"0.6358161",
"0.58911306",
"0.57307017",
"0.56719035",
"0.56540555",
"0.5642764",
"0.5616005",
"0.5607584",
"0.55675405",
"0.55518913",
"0.55439836",
"0.5536333",
"0.55092025",
"0.547324",
"0.546704",
"0.5419871",
"0.5419157",
"0.5414881",
"0.5395047",
"0.538184... | 0.8447853 | 0 |
Provided a service entry this will pull out concept ids from tag guids and request the collections from CMR | def collections_from_service_entry_tags(service_entry)
concept_ids = concept_ids_from_service_entry_tags(service_entry)
return [] if concept_ids.blank?
response = cmr_client.get_collections_by_post({ concept_id: concept_ids, page_size: concept_ids.size }, token)
if response.success?
response.body.fetch('items', [])
else
[]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_datasets_for_service_implementation(params = {})\n # service_interface_guid is not a permitted param for CMR but we need it for this call\n # so we'll use delete to pop the value from the params hash\n response = echo_client.get_service_entries(echo_provider_token, params.delete('service_interface... | [
"0.67045355",
"0.5408727",
"0.52200097",
"0.5209009",
"0.5118803",
"0.5095901",
"0.5079721",
"0.5060224",
"0.4980422",
"0.4968335",
"0.492527",
"0.49205932",
"0.49064764",
"0.48901784",
"0.48868728",
"0.48775038",
"0.48773345",
"0.48670405",
"0.48604652",
"0.4857313",
"0.4841... | 0.7808586 | 0 |
Delete the user's connections deletes all connections of the user given his hash | def hash_delete(opts = {})
hash_delete_with_http_info(opts)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_connection\n\n\t\t# Set A and B\n\t\ta = self.current_user.id\n\t\tb = params[:user_id]\n\n\t\t# Delete both A -> B and B -> A (If we missed any duplicated records)\n\t\tConnection.where('(`owned_by` = ? && `user_id` = ?) || (`user_id` = ? && `owned_by` = ?)', a, b, a, b).each do |x|\n\t\t\tx.destroy\n\... | [
"0.7291358",
"0.7119551",
"0.70424676",
"0.69227475",
"0.68673384",
"0.6829997",
"0.6545845",
"0.64653",
"0.64640343",
"0.64288175",
"0.6352213",
"0.6336974",
"0.63357735",
"0.6302564",
"0.62957335",
"0.627434",
"0.62651306",
"0.6263058",
"0.62563527",
"0.62464637",
"0.624132... | 0.0 | -1 |
Delete the user&39;s connections deletes all connections of the user given his hash | def hash_delete_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: UsersManagementApi.hash_delete ...'
end
# resource path
local_var_path = '/hash'
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['api_key']
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UsersManagementApi#hash_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_connection\n\n\t\t# Set A and B\n\t\ta = self.current_user.id\n\t\tb = params[:user_id]\n\n\t\t# Delete both A -> B and B -> A (If we missed any duplicated records)\n\t\tConnection.where('(`owned_by` = ? && `user_id` = ?) || (`user_id` = ? && `owned_by` = ?)', a, b, a, b).each do |x|\n\t\t\tx.destroy\n\... | [
"0.71147436",
"0.7039122",
"0.684653",
"0.6843536",
"0.6751942",
"0.6667826",
"0.6588732",
"0.6472285",
"0.64481276",
"0.64242244",
"0.6418976",
"0.6407883",
"0.6344136",
"0.6292175",
"0.6284981",
"0.62649214",
"0.62378716",
"0.6226134",
"0.6214355",
"0.6202315",
"0.61889744"... | 0.0 | -1 |
Delete the given user configurations. deletions on keys prefixed by 'biapi.' (except callback_url) are ignored keys (string): list of coma separated keys to be deleted. | def users_id_user_config_delete(id_user, opts = {})
users_id_user_config_delete_with_http_info(id_user, opts)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @userconfig.destroy\n respond_to do |format|\n format.html { redirect_to userconfigs_url, notice: \"Userconfig was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete_by_id(user_id)\n Iterable.request(conf, \"/users/byUserId/#{user_id}\"... | [
"0.6190237",
"0.60056967",
"0.5939117",
"0.58024246",
"0.5745868",
"0.56886286",
"0.56784123",
"0.567366",
"0.5672965",
"0.56620175",
"0.5642824",
"0.5607411",
"0.5581179",
"0.5533959",
"0.5527929",
"0.55043656",
"0.54897654",
"0.5470818",
"0.5467372",
"0.54495454",
"0.543773... | 0.6246653 | 0 |
Delete the given user configurations. deletions on keys prefixed by &39;biapi.&39; (except callback_url) are ignored keys (string): list of coma separated keys to be deleted. | def users_id_user_config_delete_with_http_info(id_user, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: UsersManagementApi.users_id_user_config_delete ...'
end
# verify the required parameter 'id_user' is set
if @api_client.config.client_side_validation && id_user.nil?
fail ArgumentError, "Missing the required parameter 'id_user' when calling UsersManagementApi.users_id_user_config_delete"
end
# resource path
local_var_path = '/users/{id_user}/config'.sub('{' + 'id_user' + '}', id_user.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['api_key']
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UsersManagementApi#users_id_user_config_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users_id_user_config_delete(id_user, opts = {})\n users_id_user_config_delete_with_http_info(id_user, opts)\n nil\n end",
"def destroy\n @userconfig.destroy\n respond_to do |format|\n format.html { redirect_to userconfigs_url, notice: \"Userconfig was successfully destroyed.\" }\n ... | [
"0.63192755",
"0.6188074",
"0.6020709",
"0.57504666",
"0.5740285",
"0.5730853",
"0.5721952",
"0.5720881",
"0.56811994",
"0.5675205",
"0.56726784",
"0.56510687",
"0.5618423",
"0.560963",
"0.55755097",
"0.55283844",
"0.5501779",
"0.5474209",
"0.5467514",
"0.54620034",
"0.545994... | 0.58200103 | 3 |
Get configuration of a user. | def users_id_user_config_get(id_user, opts = {})
data, _status_code, _headers = users_id_user_config_get_with_http_info(id_user, opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user\n return @user ? @user : Dotfu.config_user\n end",
"def get_user_conf(name, profile = 'default')\n return @config.find(name, profile) if @config\n @config = make_user_conf\n msg = 'Run the command `configure`'\n raise Idcf::Cli::CliError, msg unles... | [
"0.7608732",
"0.69656116",
"0.695211",
"0.6923802",
"0.6881822",
"0.68037903",
"0.66993177",
"0.6683868",
"0.659677",
"0.6588131",
"0.6494486",
"0.6449822",
"0.63754636",
"0.63709944",
"0.63602316",
"0.63568",
"0.63528556",
"0.63398063",
"0.6335",
"0.6328503",
"0.6317483",
... | 0.65630186 | 10 |
Get configuration of a user. | def users_id_user_config_get_with_http_info(id_user, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: UsersManagementApi.users_id_user_config_get ...'
end
# verify the required parameter 'id_user' is set
if @api_client.config.client_side_validation && id_user.nil?
fail ArgumentError, "Missing the required parameter 'id_user' when calling UsersManagementApi.users_id_user_config_get"
end
# resource path
local_var_path = '/users/{id_user}/config'.sub('{' + 'id_user' + '}', id_user.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['api_key']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'Object')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UsersManagementApi#users_id_user_config_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user\n return @user ? @user : Dotfu.config_user\n end",
"def get_user_conf(name, profile = 'default')\n return @config.find(name, profile) if @config\n @config = make_user_conf\n msg = 'Run the command `configure`'\n raise Idcf::Cli::CliError, msg unles... | [
"0.7609335",
"0.6966791",
"0.69535536",
"0.692331",
"0.6881345",
"0.6804492",
"0.6700519",
"0.66837746",
"0.65965873",
"0.65890956",
"0.65634537",
"0.6495379",
"0.64509004",
"0.6375615",
"0.63716185",
"0.6361218",
"0.63578093",
"0.63537747",
"0.6339722",
"0.63357955",
"0.6328... | 0.5954582 | 34 |
Change configuration of a user. modifications on keys prefixed by 'biapi.' (except callback_url) are ignored | def users_id_user_config_post(id_user, opts = {})
users_id_user_config_post_with_http_info(id_user, opts)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user=(value)\n conf['api']['user'] = value\n end",
"def config_user\n atts = {}\n u = @device.user\n unless params[:name].blank?\n return render json: {:status=>11, :message=>'用户名已经设置,不能修改'} if u.name\n return render json: {:status=>12, :message=>'用户名已存在'} if User.find_by_name params[:... | [
"0.7109322",
"0.6529216",
"0.6244948",
"0.6223898",
"0.6085352",
"0.6064649",
"0.5969934",
"0.5936848",
"0.59160584",
"0.5885103",
"0.58494216",
"0.5841188",
"0.58111435",
"0.5807677",
"0.5742263",
"0.574219",
"0.57405156",
"0.5706894",
"0.5702117",
"0.56985927",
"0.56782925"... | 0.0 | -1 |
Change configuration of a user. modifications on keys prefixed by &39;biapi.&39; (except callback_url) are ignored | def users_id_user_config_post_with_http_info(id_user, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: UsersManagementApi.users_id_user_config_post ...'
end
# verify the required parameter 'id_user' is set
if @api_client.config.client_side_validation && id_user.nil?
fail ArgumentError, "Missing the required parameter 'id_user' when calling UsersManagementApi.users_id_user_config_post"
end
# resource path
local_var_path = '/users/{id_user}/config'.sub('{' + 'id_user' + '}', id_user.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['api_key']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UsersManagementApi#users_id_user_config_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user=(value)\n conf['api']['user'] = value\n end",
"def config_user\n atts = {}\n u = @device.user\n unless params[:name].blank?\n return render json: {:status=>11, :message=>'用户名已经设置,不能修改'} if u.name\n return render json: {:status=>12, :message=>'用户名已存在'} if User.find_by_name params[:... | [
"0.69964856",
"0.6478783",
"0.61852056",
"0.5980127",
"0.5947022",
"0.59314996",
"0.58462554",
"0.5830617",
"0.58166987",
"0.5806823",
"0.5792529",
"0.57718337",
"0.57278264",
"0.57106036",
"0.57029784",
"0.56980497",
"0.5697889",
"0.5694463",
"0.5691392",
"0.5691392",
"0.569... | 0.0 | -1 |
Delete the user This endpoint deletes the user. | def users_id_user_delete(id_user, opts = {})
data, _status_code, _headers = users_id_user_delete_with_http_info(id_user, opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_user\n client.delete(user)\n end",
"def delete_user(user)\n delete user_path(user)\n end",
"def destroy\n @user.destroy\n render json: {message: 'User was Deleted'}\n end",
"def destroy\n @user.destroy\n\n head :no_content\n end",
"def destroy\... | [
"0.8994034",
"0.83634824",
"0.831132",
"0.8307018",
"0.8307018",
"0.830556",
"0.8278325",
"0.82694113",
"0.8266111",
"0.8265773",
"0.82599425",
"0.8257647",
"0.82379633",
"0.81614834",
"0.81159216",
"0.8096064",
"0.8054096",
"0.80469877",
"0.8036824",
"0.80363715",
"0.8027458... | 0.0 | -1 |
Delete the user This endpoint deletes the user. | def users_id_user_delete_with_http_info(id_user, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: UsersManagementApi.users_id_user_delete ...'
end
# verify the required parameter 'id_user' is set
if @api_client.config.client_side_validation && id_user.nil?
fail ArgumentError, "Missing the required parameter 'id_user' when calling UsersManagementApi.users_id_user_delete"
end
# resource path
local_var_path = '/users/{id_user}'.sub('{' + 'id_user' + '}', id_user.to_s)
# query parameters
query_params = {}
query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].nil?
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['api_key']
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'User')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UsersManagementApi#users_id_user_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_user\n client.delete(user)\n end",
"def delete_user(user)\n delete user_path(user)\n end",
"def destroy\n @user.destroy\n render json: {message: 'User was Deleted'}\n end",
"def destroy\n @user.destroy\n\n head :no_content\n end",
"def destroy\... | [
"0.89939404",
"0.8363811",
"0.8311711",
"0.8307197",
"0.8307197",
"0.83056855",
"0.8277762",
"0.8269919",
"0.8266554",
"0.8266329",
"0.82593787",
"0.8258428",
"0.8237813",
"0.81619376",
"0.811557",
"0.8096101",
"0.8053589",
"0.804691",
"0.8036841",
"0.803655",
"0.8028147",
... | 0.0 | -1 |
Get the main profile | def users_id_user_profiles_main_get(id_user, opts = {})
data, _status_code, _headers = users_id_user_profiles_main_get_with_http_info(id_user, opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile\n @property[:profile]\n end",
"def current_profile\n current_session.profile\n end",
"def profile; Profile.get(self.profile_id); end",
"def profile\n @profile ||= GATEWAY.get_profile_details(self.profile_id) unless profile_id.nil?\n end",
"def profile\n threaded[:profil... | [
"0.77435035",
"0.7699092",
"0.76730734",
"0.7653545",
"0.7648848",
"0.7648848",
"0.74617994",
"0.74278915",
"0.74256885",
"0.7421994",
"0.7342259",
"0.7243791",
"0.7160768",
"0.71177125",
"0.7114089",
"0.7097658",
"0.7097658",
"0.7089299",
"0.702054",
"0.6997733",
"0.6988198"... | 0.0 | -1 |
Get the main profile | def users_id_user_profiles_main_get_with_http_info(id_user, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: UsersManagementApi.users_id_user_profiles_main_get ...'
end
# verify the required parameter 'id_user' is set
if @api_client.config.client_side_validation && id_user.nil?
fail ArgumentError, "Missing the required parameter 'id_user' when calling UsersManagementApi.users_id_user_profiles_main_get"
end
# resource path
local_var_path = '/users/{id_user}/profiles/main'.sub('{' + 'id_user' + '}', id_user.to_s)
# query parameters
query_params = {}
query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].nil?
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['api_key']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'Profile')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UsersManagementApi#users_id_user_profiles_main_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile\n @property[:profile]\n end",
"def current_profile\n current_session.profile\n end",
"def profile; Profile.get(self.profile_id); end",
"def profile\n @profile ||= GATEWAY.get_profile_details(self.profile_id) unless profile_id.nil?\n end",
"def profile\n threaded[:profil... | [
"0.77435035",
"0.7699092",
"0.76730734",
"0.7653545",
"0.7648848",
"0.7648848",
"0.74617994",
"0.74278915",
"0.74256885",
"0.7421994",
"0.7342259",
"0.7243791",
"0.7160768",
"0.71177125",
"0.7114089",
"0.7097658",
"0.7097658",
"0.7089299",
"0.702054",
"0.6997733",
"0.6988198"... | 0.0 | -1 |
Create a token Create an access_token for this user and get it. | def users_id_user_token_post(id_user, application, opts = {})
data, _status_code, _headers = users_id_user_token_post_with_http_info(id_user, application, opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def access_token\n User.create_access_token(self)\n end",
"def generate_access_token\n self.access_token ||= self.create_access_token\n save && access_token\n end",
"def create\n require 'digest/sha1'\n \n @access_token = AccessToken.new\n @access_token.user_id = current_user.id\n @ac... | [
"0.837983",
"0.7738527",
"0.7649867",
"0.7432391",
"0.7368562",
"0.73682564",
"0.73682564",
"0.73566306",
"0.72725546",
"0.7208799",
"0.7194847",
"0.7132002",
"0.7124675",
"0.7063991",
"0.7047327",
"0.7031162",
"0.7015049",
"0.70109236",
"0.7001952",
"0.69994843",
"0.69932663... | 0.0 | -1 |
Create a token Create an access_token for this user and get it. | def users_id_user_token_post_with_http_info(id_user, application, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: UsersManagementApi.users_id_user_token_post ...'
end
# verify the required parameter 'id_user' is set
if @api_client.config.client_side_validation && id_user.nil?
fail ArgumentError, "Missing the required parameter 'id_user' when calling UsersManagementApi.users_id_user_token_post"
end
# verify the required parameter 'application' is set
if @api_client.config.client_side_validation && application.nil?
fail ArgumentError, "Missing the required parameter 'application' when calling UsersManagementApi.users_id_user_token_post"
end
# resource path
local_var_path = '/users/{id_user}/token'.sub('{' + 'id_user' + '}', id_user.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
# form parameters
form_params = {}
form_params['application'] = application
# http body (model)
post_body = nil
auth_names = ['api_key']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'Object')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UsersManagementApi#users_id_user_token_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def access_token\n User.create_access_token(self)\n end",
"def generate_access_token\n self.access_token ||= self.create_access_token\n save && access_token\n end",
"def create\n require 'digest/sha1'\n \n @access_token = AccessToken.new\n @access_token.user_id = current_user.id\n @ac... | [
"0.837982",
"0.7739091",
"0.7649804",
"0.74348253",
"0.7369935",
"0.7369935",
"0.7369023",
"0.735615",
"0.7272942",
"0.7210471",
"0.7195461",
"0.71338403",
"0.7125111",
"0.7064586",
"0.70482475",
"0.7031742",
"0.7016605",
"0.7011514",
"0.7003396",
"0.6998269",
"0.6992987",
... | 0.0 | -1 |
Find the sum of all the primes below two million. ======Slower brute force method======= def is_prime?(number) is_prime = true 2.upto(Math.sqrt(number).floor) do |num| if number % num == 0 is_prime = false break end end is_prime end def find_primes(limit) primes_array = [] (2...limit).each do |x| primes_array << x if is_prime?(x) end primes_array end using the Sieve of Eratosthenes | def find_primes(limit)
num_array = (2...limit).to_a
num_array.each_with_index do |val, index|
if val
index += val
while index < limit-2
num_array[index] = nil
index += val
end
else
next
end
end
num_array.compact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def brute_force_primes(limit)\n \n primes = []\n complexity = 0\n # we know that 0,1 can't be prime\n # start at 2 and create a Range upto the limit\n (2..limit).each{|number|\n complexity += 1\n is_prime = true\n \n # any number is divisible by 1\n # so start at 2\n (2..number).each{|n|\n ... | [
"0.813076",
"0.80596143",
"0.7968878",
"0.7820366",
"0.77713615",
"0.77585334",
"0.76862514",
"0.7626614",
"0.7622976",
"0.7612283",
"0.755954",
"0.7521138",
"0.7521138",
"0.750969",
"0.74998975",
"0.7493728",
"0.74544764",
"0.7450481",
"0.7421679",
"0.73789036",
"0.7355006",... | 0.74824417 | 16 |
Create a recurrence from the given frequency | def every(frequency, options = {})
branch options.merge(every: frequency)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_recurrences\n # remove all already scheduled occurrences in the future\n Occurrence.where('event_id = ? AND date >= ?', self.id, Date.current).delete_all\n \n if read_attribute(:recurrence).empty?\n Occurrence.create(event: self, date: self.date)\n else\n # schedule events for... | [
"0.65145075",
"0.6428962",
"0.6237867",
"0.6183278",
"0.6152973",
"0.6152973",
"0.61239976",
"0.60252553",
"0.5992055",
"0.59302026",
"0.59113914",
"0.5873501",
"0.58342814",
"0.5833177",
"0.5823272",
"0.58088017",
"0.57808685",
"0.5740985",
"0.57049984",
"0.570419",
"0.56684... | 0.48806503 | 88 |
Create a minutely recurrence. | def minutely(options = {})
branch options.merge(every: :minute)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_recurrences\n # remove all already scheduled occurrences in the future\n Occurrence.where('event_id = ? AND date >= ?', self.id, Date.current).delete_all\n \n if read_attribute(:recurrence).empty?\n Occurrence.create(event: self, date: self.date)\n else\n # schedule events for... | [
"0.66744834",
"0.6583623",
"0.6312478",
"0.6312478",
"0.6079936",
"0.60001713",
"0.5985342",
"0.595669",
"0.5955776",
"0.5936313",
"0.57971424",
"0.57487583",
"0.57210255",
"0.5664733",
"0.56121784",
"0.56121784",
"0.56100047",
"0.5603608",
"0.55753374",
"0.5529704",
"0.55257... | 0.0 | -1 |
Create a hourly recurrence. | def hourly(options = {})
branch options.merge(every: :hour)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_recurrences\n # remove all already scheduled occurrences in the future\n Occurrence.where('event_id = ? AND date >= ?', self.id, Date.current).delete_all\n \n if read_attribute(:recurrence).empty?\n Occurrence.create(event: self, date: self.date)\n else\n # schedule events for... | [
"0.6487369",
"0.6236406",
"0.62175435",
"0.6142382",
"0.59277886",
"0.58617777",
"0.5800348",
"0.5797229",
"0.5793554",
"0.5763702",
"0.5737585",
"0.5731232",
"0.5694806",
"0.5694206",
"0.56823105",
"0.565393",
"0.56336975",
"0.56027997",
"0.5570435",
"0.55280983",
"0.5527060... | 0.59106463 | 6 |
Create a daily recurrence. | def daily(options = {})
branch options.merge(every: :day)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_recurrences\n # remove all already scheduled occurrences in the future\n Occurrence.where('event_id = ? AND date >= ?', self.id, Date.current).delete_all\n \n if read_attribute(:recurrence).empty?\n Occurrence.create(event: self, date: self.date)\n else\n # schedule events for... | [
"0.73362285",
"0.7017756",
"0.65977263",
"0.6593396",
"0.62268525",
"0.62245",
"0.62103426",
"0.6174135",
"0.6157488",
"0.6111112",
"0.6105825",
"0.6092715",
"0.6059412",
"0.59560364",
"0.5940169",
"0.5940169",
"0.5919528",
"0.5911028",
"0.59017324",
"0.5893936",
"0.58616406"... | 0.60408163 | 14 |
Create a weekly recurrence. | def weekly(options = {})
branch options.merge(every: :week)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_recurrence_from_params\n on = recurrence_on.map(&:to_sym)\n at = transform_string_to_times(recurrence_at)\n clear_schedule\n add_recurrence(type: :week, on: on, at: at)\n end",
"def weeks() 7 * days end",
"def new_schedule(*args)\n if !args.all? { |e| e.is_a?(Integer) && e >= 0 && e <= ... | [
"0.7258167",
"0.70177436",
"0.6931422",
"0.6872182",
"0.669048",
"0.66295546",
"0.65753394",
"0.65362185",
"0.64588416",
"0.6399074",
"0.63694876",
"0.63147646",
"0.6279019",
"0.62297064",
"0.62051916",
"0.6201109",
"0.61874104",
"0.61564213",
"0.6124599",
"0.6124599",
"0.608... | 0.68449664 | 5 |
Create a monthly recurrence. | def monthly(options = {})
branch options.merge(every: :month)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_recurrences\n # remove all already scheduled occurrences in the future\n Occurrence.where('event_id = ? AND date >= ?', self.id, Date.current).delete_all\n \n if read_attribute(:recurrence).empty?\n Occurrence.create(event: self, date: self.date)\n else\n # schedule events for... | [
"0.7131427",
"0.67616975",
"0.6515934",
"0.6245374",
"0.6135469",
"0.6029013",
"0.59832036",
"0.58939636",
"0.58793277",
"0.58254385",
"0.5818626",
"0.5780765",
"0.5768481",
"0.57178134",
"0.56691515",
"0.56400436",
"0.56400436",
"0.56329787",
"0.5617006",
"0.5615539",
"0.561... | 0.60182357 | 7 |
Create a yearly recurrence. | def yearly(options = {})
branch options.merge(every: :year)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_yr\n\tset_cur_year(get_cur_year+1)\nend",
"def no_repeat_years(first_year, last_year)\nend",
"def generate_recurrences\n # remove all already scheduled occurrences in the future\n Occurrence.where('event_id = ? AND date >= ?', self.id, Date.current).delete_all\n \n if read_attribute(:r... | [
"0.6312094",
"0.6305786",
"0.6294956",
"0.6265978",
"0.6024861",
"0.6016748",
"0.5953853",
"0.59454286",
"0.5941457",
"0.5908073",
"0.5851626",
"0.5850015",
"0.583518",
"0.5827798",
"0.5819018",
"0.577236",
"0.5748866",
"0.57324785",
"0.5728791",
"0.5721094",
"0.5694056",
"... | 0.59366906 | 10 |
Create a recurrence starting at given timestamp. | def starts(starts_at)
merge(starts: starts_at)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_recurrences\n # remove all already scheduled occurrences in the future\n Occurrence.where('event_id = ? AND date >= ?', self.id, Date.current).delete_all\n \n if read_attribute(:recurrence).empty?\n Occurrence.create(event: self, date: self.date)\n else\n # schedule events for... | [
"0.6322667",
"0.62188363",
"0.6202473",
"0.6152839",
"0.5794456",
"0.5517323",
"0.5511164",
"0.55008435",
"0.54777026",
"0.53675365",
"0.52858794",
"0.5264492",
"0.5209583",
"0.5198844",
"0.5134599",
"0.5128384",
"0.511203",
"0.51014197",
"0.5084017",
"0.50579745",
"0.5035719... | 0.0 | -1 |
Create a recurrence ending at given timestamp. | def until(ends_at)
merge(until: ends_at)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recurrence_to_events!(now = Time.now.utc)\n return unless recurrence\n pid = parent_id || id # if parent_id is nil then we're generating from the parent\n duration = (self.end - self.start).to_i\n t_start = end_of_chain.start.midnight.tomorrow # Every day after the ... | [
"0.5763601",
"0.5387704",
"0.53857356",
"0.5185503",
"0.5135289",
"0.5082209",
"0.5046865",
"0.49230257",
"0.49175847",
"0.48854795",
"0.48763958",
"0.48498565",
"0.47798568",
"0.47605047",
"0.47566348",
"0.47039258",
"0.46834975",
"0.46650645",
"0.46538442",
"0.4641134",
"0.... | 0.0 | -1 |
Create a recurrence occurring between the start and end of a given date range; :between is shorthand for separate :starts and :until options. When used with explicit :start and/or :until options, those will take precedence. | def between(date_range)
merge(between: date_range)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def for_date_range(beginning:, ending:)\n new_with_date_range(beginning, ending)\n end",
"def date_between (min, max)\n Predicate.new(:date_between, { min: min, max: max}) do |o|\n o >= min && o <= max\n end\n end",
"def between_dates(start, finish)\n start = start.chronify(gue... | [
"0.66740245",
"0.6222435",
"0.6163396",
"0.6138086",
"0.60597354",
"0.60344845",
"0.5962342",
"0.5943898",
"0.5922531",
"0.58850247",
"0.584501",
"0.57890815",
"0.5779814",
"0.5774257",
"0.57710946",
"0.57087713",
"0.5700853",
"0.5680202",
"0.56705374",
"0.56635654",
"0.56595... | 0.65354955 | 2 |
Create a recurrence which will only emit values within the date range, also called "masking." | def covering(date_range)
merge(covering: date_range)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_recurrences\n # remove all already scheduled occurrences in the future\n Occurrence.where('event_id = ? AND date >= ?', self.id, Date.current).delete_all\n \n if read_attribute(:recurrence).empty?\n Occurrence.create(event: self, date: self.date)\n else\n # schedule events for... | [
"0.5772766",
"0.57313657",
"0.5722943",
"0.57097423",
"0.567828",
"0.56194764",
"0.5584516",
"0.5511722",
"0.55078065",
"0.54709476",
"0.5457419",
"0.542211",
"0.5421099",
"0.5386382",
"0.53843",
"0.53743654",
"0.53717947",
"0.53642535",
"0.53174984",
"0.5309649",
"0.52733326... | 0.5876295 | 0 |
Create a recurrence occurring within a timeofday range or ranges. Given time ranges will parse as timesofday and ignore given dates. | def during(time_of_day, *extras)
merge(during: time_of_day.array_concat(extras))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_events_time(range_begin_in_secs, range_end_in_secs)\n #\n # collect from_time beginning of day (in seconds)\n #\n frt = self.from_time.beginning_of_day.to_i\n\n case self.recurrence_type\n when \"NO_RECURRENCE\"\n self.no_recurrence_dates(range_begin_in_... | [
"0.60084087",
"0.55073476",
"0.5393154",
"0.5291464",
"0.5277832",
"0.52732146",
"0.5257287",
"0.520492",
"0.5191614",
"0.5173576",
"0.51333153",
"0.50888205",
"0.50587213",
"0.50401884",
"0.50280565",
"0.5011395",
"0.49947196",
"0.49723914",
"0.497119",
"0.49693468",
"0.4946... | 0.0 | -1 |
Create a recurrence at given time | def at(time)
merge(at: time)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_recurrences\n # remove all already scheduled occurrences in the future\n Occurrence.where('event_id = ? AND date >= ?', self.id, Date.current).delete_all\n \n if read_attribute(:recurrence).empty?\n Occurrence.create(event: self, date: self.date)\n else\n # schedule events for... | [
"0.6596704",
"0.65345025",
"0.63191724",
"0.6300665",
"0.6257965",
"0.61090726",
"0.6005817",
"0.5987461",
"0.59022444",
"0.59022444",
"0.5860779",
"0.5807715",
"0.5760633",
"0.5742953",
"0.5735306",
"0.5671758",
"0.55982333",
"0.55778056",
"0.55713254",
"0.55325234",
"0.5504... | 0.0 | -1 |
Create a recurrence with dates except dates given | def except(date)
merge(except: date)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_recurrences\n # remove all already scheduled occurrences in the future\n Occurrence.where('event_id = ? AND date >= ?', self.id, Date.current).delete_all\n \n if read_attribute(:recurrence).empty?\n Occurrence.create(event: self, date: self.date)\n else\n # schedule events for... | [
"0.64138234",
"0.63034934",
"0.62600774",
"0.61709964",
"0.614366",
"0.610442",
"0.60958767",
"0.60365075",
"0.595503",
"0.5881428",
"0.58470994",
"0.5805628",
"0.57816535",
"0.5770195",
"0.57643354",
"0.5682022",
"0.56628776",
"0.5660224",
"0.5619742",
"0.5619656",
"0.556568... | 0.54822737 | 22 |
Create a recurrence for given days of month | def day_of_month(days, *extras)
merge(mday: days.array_concat(extras))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_recurrences\n # remove all already scheduled occurrences in the future\n Occurrence.where('event_id = ? AND date >= ?', self.id, Date.current).delete_all\n \n if read_attribute(:recurrence).empty?\n Occurrence.create(event: self, date: self.date)\n else\n # schedule events for... | [
"0.6826446",
"0.65125054",
"0.6494034",
"0.63091743",
"0.6279078",
"0.62042826",
"0.6191677",
"0.6129483",
"0.5998871",
"0.5978166",
"0.5939013",
"0.59051806",
"0.5902541",
"0.58404195",
"0.583018",
"0.5819257",
"0.5808279",
"0.5802486",
"0.58024275",
"0.577403",
"0.57650954"... | 0.5536428 | 43 |
Create a recurrence for given days of week | def day_of_week(weekdays, *extras)
merge(day: weekdays.array_concat(extras))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weeks() 7 * days end",
"def solver(from_date, to_date, weekday)\n result = 0\n days_to_sunday = 7 - weekday\n new_date = from_date.increment_by_days days_to_sunday\n if (new_date.day == 1)\n result = result + 1\n end\n while new_date <= to_date\n if (new_date.day == 1)\n result = result + 1\... | [
"0.7141109",
"0.67687577",
"0.6705868",
"0.66671085",
"0.66387415",
"0.65931875",
"0.65390134",
"0.65236366",
"0.65086555",
"0.64433205",
"0.6415727",
"0.6401179",
"0.6380372",
"0.636482",
"0.6303574",
"0.6299422",
"0.6268097",
"0.6265568",
"0.6252682",
"0.62521726",
"0.62183... | 0.5557375 | 97 |
Create a recurrence for given days of year | def day_of_year(days, *extras)
merge(yday: days.array_concat(extras))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def advent_days(year:)\n min_day .. max_day(year: year)\n end",
"def increment_by_days count\n new_day = @day\n new_month = @month\n new_year = @year \n \n while count > 0\n days_to_next_month = days_in_month(new_month, new_year) - new_day + 1\n \n if (days_to_next_... | [
"0.6317235",
"0.6261399",
"0.6261066",
"0.624109",
"0.622821",
"0.6200521",
"0.61757034",
"0.61427826",
"0.6092044",
"0.6035289",
"0.60295033",
"0.6023175",
"0.6008881",
"0.5977193",
"0.59730315",
"0.59266484",
"0.5899192",
"0.5872805",
"0.5840942",
"0.58381826",
"0.5830785",... | 0.60654324 | 9 |
Create a recurrence for given hours of day | def hour_of_day(hours, *extras)
merge(hour: hours.array_concat(extras))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_calc(start,day_start,day_duration,round)\n time=start;schedule=[]\n round.size.times do |r|\n#print day_start+day_duration;print \"\\n\"\n if time >= day_start + day_duration\n#print time;print \"\\n\"\n time=day_start+1.day\n day_start = time\n end\n schedule[r] = time\... | [
"0.66313756",
"0.63422376",
"0.6170693",
"0.6160254",
"0.61066705",
"0.600784",
"0.59787303",
"0.5962829",
"0.59465677",
"0.58838624",
"0.58235955",
"0.5812365",
"0.57726127",
"0.5766004",
"0.5765195",
"0.57523894",
"0.5750591",
"0.571505",
"0.5705398",
"0.5690481",
"0.568969... | 0.57158464 | 17 |
Create a recurrence for given months of year | def month_of_year(months, *extras)
merge(month: months.array_concat(extras))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_april( n=1); each_monthnum(self.Apr,n); end",
"def each_july( n=1); each_monthnum(self.Jul,n); end",
"def calculate_month_and_next_month(year, month)\n check_date = Time.new(year, month)\n {:actual => check_date, :next => check_date.next_month}\n end",
"def each_march( n... | [
"0.6542906",
"0.65370196",
"0.63910246",
"0.63830227",
"0.6307242",
"0.6290549",
"0.6285185",
"0.62744427",
"0.6267703",
"0.6240375",
"0.62143344",
"0.6159275",
"0.61251575",
"0.6118346",
"0.6113192",
"0.6103073",
"0.6101565",
"0.60980743",
"0.6083123",
"0.60818",
"0.6059043"... | 0.5870216 | 35 |
Create a recurrence for given weeks of year | def week_of_year(weeks, *extras)
merge(week: weeks.array_concat(extras))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def week_pattern\n year_weeks == 53 ? [5,4,5]+[4,4,5]*3 : [4,4,5]*4\n end",
"def weeks() 7 * days end",
"def weeks_in_year(year)\n date_calc.weeks_in_year(year)\n end",
"def year_week\n @year_week ||= (((date-start_of_year)+1)/7.0).ceil\n end",
"def week_of_year(*weeks)\n merge(wee... | [
"0.70631766",
"0.6972198",
"0.6892188",
"0.6822872",
"0.6808188",
"0.6724527",
"0.6658759",
"0.64955956",
"0.6405919",
"0.6402313",
"0.6290028",
"0.6271715",
"0.6264065",
"0.6254238",
"0.6254238",
"0.6236377",
"0.62134016",
"0.62010384",
"0.61955124",
"0.6183571",
"0.6181045"... | 0.673022 | 5 |
Create a recurrence that ends after given number of occurrences | def total(total)
merge(total: total)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_recurrence(number)\n if old_num == number\n self.recc += 1\n else\n apply_recurrence\n self.old_num = number\n self.recc = 1\n end\n end",
"def pattern_repeat(n)\n last = [1, 1]\n counter = 0\n loop do\n last = [last.last, (last.first + last.last) % 10... | [
"0.61601716",
"0.6080025",
"0.59530854",
"0.5885252",
"0.5822106",
"0.5789838",
"0.57532483",
"0.57367927",
"0.5723179",
"0.56007063",
"0.55828875",
"0.5572156",
"0.55542475",
"0.54669666",
"0.5391866",
"0.53671384",
"0.53671384",
"0.53411204",
"0.5340492",
"0.5318625",
"0.53... | 0.0 | -1 |
Create a new recurrence combining options of self and other. The value of entries with duplicate keys will be those of other | def merge(other = {})
branch default_options.merge(other)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge!(other)\n\t\tALL.each do |key|\n\t\t\tincrement(key, other.get(key))\n\t\tend\n\t\tself\n\tend",
"def join(other)\n new(entries.merge(other.entries) { |_name, old, new| old + new })\n end",
"def merge_info(parent, child, opt1, opt2)\n result = TemporalConstraintSet.new\n ... | [
"0.56236005",
"0.55999064",
"0.55021197",
"0.5483281",
"0.53406495",
"0.53396297",
"0.5334312",
"0.5278847",
"0.5250876",
"0.5205176",
"0.5188635",
"0.517613",
"0.51285815",
"0.5121691",
"0.5067655",
"0.5063546",
"0.5050378",
"0.50281185",
"0.5025045",
"0.50207466",
"0.501041... | 0.0 | -1 |
Takes an array of three integers to add to VERSION and three integers to multiply to VERSION | def bump(by,reset)
version_triplet.zip(by, reset).collect{|x,y,z| (x+y)*z}.join(".")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bump_numeric\n value_ = ::Versionomy.create([1, 9, 2, 'a2'], :semver)\n value_ = value_.bump(:patch)\n assert_equal([1, 9, 3, ''], value_.values_array)\n end",
"def custom_multiply(array, number)\n result = []\n number.times { array.each { |element| result << element}}\n res... | [
"0.60821146",
"0.6035046",
"0.5951242",
"0.5840144",
"0.58135456",
"0.5794542",
"0.5758383",
"0.57424957",
"0.5730996",
"0.5718913",
"0.5711211",
"0.57071185",
"0.5693568",
"0.56609046",
"0.56587124",
"0.5647613",
"0.5642471",
"0.56391037",
"0.5638697",
"0.5625911",
"0.559904... | 0.6652467 | 0 |
Returns a partial SPARQL grammar for this operator. | def to_sparql(**options)
"isNumeric(" + operands.first.to_sparql(**options) + ")"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_sparql(**options)\n \"(!\" + operands.first.to_sparql(**options) + \")\"\n end",
"def to_sparql(**options)\n '(' + operands.to_sparql(delimiter: '/', **options) + ')'\n end",
"def to_sparql(**options)\n operands.first.to_sparql(reduced: true, **options)\n end",
"def... | [
"0.64040565",
"0.6321709",
"0.631144",
"0.6310281",
"0.62468004",
"0.6241794",
"0.6177385",
"0.5945824",
"0.5944844",
"0.59406114",
"0.5841583",
"0.57748723",
"0.5691575",
"0.5639666",
"0.55992645",
"0.5555632",
"0.5552082",
"0.55493504",
"0.5544813",
"0.5524246",
"0.55005145... | 0.0 | -1 |
Add data on spreadsheet | def data_to_excel(data_hash, worksheet_hash, row_max)
ws = init_spreadsheet(worksheet_hash)
(row_max..data_hash[data_hash.keys[0]].length + row_max).each_with_index do |col, index|
worksheet_hash['titles'].length.times do |i|
ws[col, i + 1] = data_hash[data_hash.keys[i]][index]
end
end
save_excel(ws)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_new_record(h, ws)\n row_array = []\n @excel_row.each do |a|\n row_array.push(h[a])\n end\n ws.add_row row_array\nend",
"def add_as_sheet(book:)\n\n sheet = book.create_worksheet\n\n sheet.name = \"#{name} #{date.strftime('%F')}\"\n row = sheet.row(1)\n row.push \"Event: \"\n row.pus... | [
"0.7351838",
"0.6927981",
"0.6913316",
"0.6859386",
"0.68364173",
"0.6580632",
"0.636083",
"0.6313194",
"0.6261162",
"0.61709356",
"0.61571294",
"0.61534846",
"0.61332995",
"0.6123624",
"0.6101902",
"0.602228",
"0.60148335",
"0.5997898",
"0.5995702",
"0.59706223",
"0.59587747... | 0.539653 | 91 |
Returns a key that will be used to group ids into batches. | def group_key(id)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_key\n [id.to_s]\n end",
"def to_key\n [id]\n end",
"def to_key\n key = id\n [key] if key\n end",
"def batch_key(_record)\n raise \"Implement in child\"\n end",
"def redis_key_for(id)\n \"#{redis_prefix}:#{Array(id).join(':')}\"\n end",
"def to... | [
"0.6898292",
"0.68468094",
"0.6801638",
"0.6737686",
"0.65537804",
"0.6535845",
"0.649238",
"0.64242184",
"0.63658416",
"0.635251",
"0.6320878",
"0.63197047",
"0.6316198",
"0.626829",
"0.6267376",
"0.6253607",
"0.6253607",
"0.62518734",
"0.6230364",
"0.62069833",
"0.61809623"... | 0.6976525 | 0 |
Returns a new enumerable collection than responds to :<<. Deferred values will be aggregated into these collections by group key. | def new_group(key)
[]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect!\n block_given? or return enum_for(__method__)\n set = self.class.new\n each { |o| set << yield(o) }\n replace(set)\n end",
"def push_all(enumerable)\n enumerable.each do |item|\n push(item)\n end\n self\n end",
"def mappend\n result = []\n self.each { |a| b = yiel... | [
"0.55238044",
"0.5398791",
"0.5371102",
"0.5361916",
"0.5331594",
"0.5328977",
"0.5316539",
"0.5292373",
"0.5287342",
"0.5193399",
"0.518639",
"0.5137206",
"0.51040167",
"0.5054244",
"0.5030129",
"0.5020475",
"0.5019767",
"0.5018616",
"0.50144035",
"0.49533525",
"0.4927352",
... | 0.4782574 | 34 |
Indicates whether its possible to capture the payment | def can_capture?(payment)
['checkout', 'pending'].include?(payment.state)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_capture?(payment)\n payment.pending? || payment.checkout?\n end",
"def can_capture?(payment)\n payment.pending? || payment.checkout?\n end",
"def can_capture?(payment)\n payment.pending? || payment.checkout?\n end",
"def can_capture?(payment)\n payment.pending? || payment... | [
"0.8574391",
"0.8574391",
"0.8574391",
"0.8574391",
"0.8574391",
"0.8421634",
"0.840692",
"0.83986884",
"0.8374448",
"0.83426374",
"0.83426374",
"0.8285566",
"0.82840663",
"0.8245142",
"0.76958513",
"0.72335327",
"0.71325046",
"0.71325046",
"0.71179265",
"0.7106526",
"0.71065... | 0.83002377 | 11 |
Indicates whether its possible to void the payment. | def can_void?(payment)
payment.state != 'void'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_void?(payment)\n !payment.void?\n end",
"def can_void?(payment)\n !payment.void?\n end",
"def can_void?(payment)\n !payment.failed? && !payment.void?\n end",
"def can_void?(payment)\n !payment.failed? && !payment.void?\n end",
"def can_void?(payment)\n !payment.... | [
"0.8414637",
"0.8414637",
"0.83615565",
"0.83615565",
"0.8343824",
"0.83381695",
"0.83381695",
"0.8314558",
"0.82425183",
"0.82425183",
"0.7034634",
"0.67792964",
"0.6753569",
"0.66845626",
"0.6645172",
"0.655368",
"0.6535386",
"0.6432738",
"0.6413752",
"0.6403974",
"0.637227... | 0.8435381 | 6 |
this is smelly. IMO there's a 'bug' in spree in the admin payment view. Whey are we asking about sources with profile I filed: | def sources_with_profile(order)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def associate_payment_profile\n order = Spree::Order.where(\"email = ?\", @user.email).order(\"created_at\").last\n if order.try(:payments).present?\n payment_source = order.payments.last.source\n payment_source.update_attributes(user_id: @user.id)\n end\n end",
"def payment_source_class\n ... | [
"0.6521839",
"0.63903046",
"0.6331863",
"0.632724",
"0.62157273",
"0.60296845",
"0.60243315",
"0.60243315",
"0.5974015",
"0.5944873",
"0.5898278",
"0.58730257",
"0.5835857",
"0.5832085",
"0.5814041",
"0.57760257",
"0.57676846",
"0.5728966",
"0.5662179",
"0.5631374",
"0.561983... | 0.0 | -1 |
Public: Creates a new Group. name The name of the group as a Symbol. plugin The FeverFacade::Manager to which the group belongs. Returns a Group. | def initialize(name, plugin)
@name = name
@context = Context.new(plugin, plugin.graph)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_group(name, sub_group_path = nil)\n group = project.new(PBXGroup)\n group.name = name\n\n target = find_subpath(sub_group_path, true)\n target.children << group\n group\n end",
"def new_group(name, sub_group_path = nil)\n group = project.new(PB... | [
"0.71094185",
"0.71094185",
"0.7012829",
"0.686723",
"0.686723",
"0.6831943",
"0.6715615",
"0.66910833",
"0.66452456",
"0.6613371",
"0.6594258",
"0.65823054",
"0.6572937",
"0.6572216",
"0.65611136",
"0.6554566",
"0.65385073",
"0.65264416",
"0.65257215",
"0.65136707",
"0.64718... | 0.0 | -1 |
Public: The Fever calculation which will compute the group. | def calculator
@calculator ||= Fever::Calculator.new(consumer, activities)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_fines\n []\n end",
"def evaluate_group(grp)\n true\n end",
"def calc_group\n GROUP_MAPPINGS.keys.each do |group_id|\n # return the details, and include the id for reference\n return group_details(group_id) if self.in_group?(group_id)\n end\n ... | [
"0.57707494",
"0.5635831",
"0.55958277",
"0.55887777",
"0.55579996",
"0.5512065",
"0.5482379",
"0.5464107",
"0.54468966",
"0.5434748",
"0.5386438",
"0.5375116",
"0.5367701",
"0.53619194",
"0.53467554",
"0.5342817",
"0.5340674",
"0.53394413",
"0.53033537",
"0.52810824",
"0.526... | 0.0 | -1 |
Public: Returns a curve which describes the demand for electricity caused by the activities within the calculator. | def elec_demand_curve
@elec_demand_curve ||= ElectricityDemandCurve.from_adapters(adapters)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def demand_curve\n load_curve('demand.csv')\n end",
"def demand_curve\n @demand_curve ||= begin\n unlimited_carrier_curve.map do |value|\n value < @carrier_capacity ? value : @carrier_capacity\n end\n end\n end",
"def calculate_carrier_demand\n ... | [
"0.7033966",
"0.70048326",
"0.6853632",
"0.67025465",
"0.65962905",
"0.6502511",
"0.6428135",
"0.6428135",
"0.6353733",
"0.6330756",
"0.6001785",
"0.59905463",
"0.59339285",
"0.57778776",
"0.5752317",
"0.5727273",
"0.55787647",
"0.55787647",
"0.5575891",
"0.5567091",
"0.55669... | 0.73674726 | 0 |
Public: Returns the adapter for the node matching `key` or nil if the node is not a participant in the group. | def adapter(key)
if (config = @context.graph.node(key).fever)
adapters_by_type[config.type].find { |a| a.node.key == key }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def [](key)\n @adapter[key.to_s]\n end",
"def get_node(key); end",
"def [](key)\n\t\t\treturn dial!(key)\n\t\tend",
"def fetch_node(key)\n node = fetch_node_nt(key)\n raise unless node\n node\n end",
"def node_for(path_or_key)\n key = PathEx::Key.new(path_or_key)\n return ni... | [
"0.55878437",
"0.55456716",
"0.5412625",
"0.5281771",
"0.52773225",
"0.5255326",
"0.5246342",
"0.5224118",
"0.5180288",
"0.5157669",
"0.51574326",
"0.5157236",
"0.5137",
"0.5110948",
"0.5108243",
"0.50745267",
"0.503432",
"0.5034296",
"0.5025054",
"0.50127786",
"0.50102276",
... | 0.71893305 | 0 |
Internal: The adapters which map nodes from the graph to activities within Fever. | def adapters
adapters_by_type.values.flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adapters\n @adapters ||=\n @nodes.transform_values do |convs|\n convs.map { |conv| Adapter.adapter_for(conv, @context) }\n end\n end",
"def activity\n @root.xpath('Events/Event').map do |act|\n Activity.new(act)\n end\n end",
"def... | [
"0.61826605",
"0.57532585",
"0.55151004",
"0.5497104",
"0.527428",
"0.527428",
"0.51466423",
"0.5059942",
"0.5015169",
"0.49789783",
"0.49622956",
"0.4945211",
"0.4930157",
"0.4930157",
"0.490244",
"0.48882315",
"0.48597562",
"0.48274285",
"0.4813186",
"0.4805733",
"0.4801861... | 0.44988528 | 74 |
Internal: Maps Fever types (:consumer, :storage, etc) to adapters. | def adapters_by_type
return @adapters if @adapters
@adapters =
Manager::TYPES.each_with_object({}) do |type, data|
data[type] =
Etsource::Fever.group(@name).keys(type).map do |node_key|
Adapter.adapter_for(
@context.graph.node(node_key), @context
)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adapters\n adapters_by_type.values.flatten\n end",
"def adapters\n @adapters ||= {}\n end",
"def adapters\n @adapters ||= {}\n end",
"def register_adapter(type, adapter); end",
"def adapters\n @adapters ||=\n @nodes.transform_values do |convs|\n ... | [
"0.6957223",
"0.64922756",
"0.6475926",
"0.615097",
"0.6124453",
"0.60587054",
"0.590596",
"0.5777547",
"0.5777547",
"0.56655526",
"0.55141914",
"0.54472643",
"0.54305834",
"0.53451043",
"0.53404623",
"0.53288406",
"0.52990973",
"0.5272447",
"0.5253847",
"0.5224774",
"0.52136... | 0.72373736 | 0 |
The resource method returns the instance of a resource based upon the route path. For example, the route /learning_paths/:learning_path_id/custom_content would return the LearningPath instance with an id of :learning_path_id | def resource
klass, param = resource_class
klass&.find(params[param.to_sym])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource(path)\n Resource.new(self, path)\n end",
"def resource(path, params={})\n r = Resource.process_detailed(self, *do_get(path, params))\n\n # note that process_detailed will make a best-effort to return an already\n # detailed resource or array of detailed resources but there may... | [
"0.72713137",
"0.69367135",
"0.6685142",
"0.6670331",
"0.6457288",
"0.64116126",
"0.635408",
"0.6289022",
"0.62704146",
"0.6264048",
"0.6199893",
"0.6184447",
"0.6167844",
"0.6167844",
"0.6159838",
"0.6128533",
"0.60493964",
"0.6038231",
"0.60155505",
"0.6000513",
"0.59613323... | 0.6229239 | 10 |
This method looks at the params hash. Its looking for a param that ends in '_id'. Once found it removes the id and then returns the class and the id to look up. For example in the route /learning_paths/:learning_path_id/custom_content the method would find `learning_path_id` and then return the class LearningPath and learning_path_id | def resource_class
params.each do |name, _value|
if /(.+)_id$/.match?(name)
model = name.match(%r{([^\/.]*)_id$})
return model[1].classify.constantize, name
end
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_klass_and_id\n klass = params[:commentable].constantize\n commentable_id = \"#{klass}_id\".downcase.to_sym\n return klass, commentable_id\n end",
"def get_id(path, user, classname)\n begin \n if classname == \"person\"\n return People.all.first.to_param\n end\n \n ... | [
"0.6184204",
"0.5998596",
"0.59538954",
"0.5832948",
"0.5788657",
"0.57686955",
"0.5625831",
"0.5625831",
"0.56169355",
"0.55943364",
"0.5585347",
"0.549406",
"0.54765767",
"0.54430145",
"0.54159385",
"0.5381057",
"0.53735405",
"0.5333437",
"0.5329433",
"0.52723914",
"0.52720... | 0.60759187 | 1 |
Adds +action_names+ to the list of valid actions for this resource. Does not include superclass's action list when appending. | def actions(*action_names)
action_names = action_names.flatten
if !action_names.empty? && !@allowed_actions
self.allowed_actions = ([ :nothing ] + action_names).uniq
else
allowed_actions(*action_names)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_actions(actions)\n # Remove the empty action (dead pokemon)\n actions.delete_if(&:empty?)\n # Merge the actions\n @actions.concat(actions)\n end",
"def include_actions(*actions)\n self.actions ||= []\n self.actions.push(*actions)\n end",
"def add_action(a... | [
"0.6996415",
"0.6754788",
"0.6661041",
"0.6623624",
"0.65538853",
"0.63702375",
"0.6365066",
"0.63529104",
"0.6340668",
"0.6312769",
"0.62622046",
"0.6175846",
"0.61708295",
"0.6154739",
"0.61301893",
"0.6121649",
"0.61059654",
"0.6072857",
"0.603807",
"0.6031886",
"0.6025334... | 0.7872911 | 0 |
a book title. First word in a title should always be capitalized. Do not capitalize words like 'a', 'and', 'of', 'over' or 'the'. | def titleize(title)
#test
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title=(book_title)\n little_words = %w{a an and the in of for}\n title = book_title.split.map do |word|\n if little_words.include? word\n word\n else\n word = word[0].upcase + word[1..-1]\n end\n end.join(' ')\n\n if title[0] == title[0].downcase\n title = title[0]... | [
"0.8359545",
"0.8349746",
"0.83100075",
"0.80901784",
"0.7852844",
"0.77563936",
"0.7745889",
"0.7630952",
"0.7600611",
"0.7583136",
"0.753964",
"0.75297165",
"0.751997",
"0.7509409",
"0.7508735",
"0.74927",
"0.7492536",
"0.7445897",
"0.74411136",
"0.7408913",
"0.7407508",
... | 0.0 | -1 |
A palindrome is a word or sequence of words that reads the same backwards as forwards. Write a method that returns the length of the longest palindrome in a given string. If there is no palindrome longer than two letters, return false. | def longest_palindrome(string)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def longest_palindrome(string)\n string.length.downto(3) do |length|\n string.chars.each_cons(length) do |substr_arr|\n return substr_arr.length if palindrome?(substr_arr.join)\n end\n end\n false\nend",
"def longest_palindrome(string)\n\tcurrent_longest = \"\"\n\tif string.length < 3\n\t\treturn f... | [
"0.8752934",
"0.8530597",
"0.8502323",
"0.8410809",
"0.8396968",
"0.83964324",
"0.83857787",
"0.83709925",
"0.83709925",
"0.83675176",
"0.8297208",
"0.8292763",
"0.82502997",
"0.82332367",
"0.8233189",
"0.8228377",
"0.8207186",
"0.8176335",
"0.81715465",
"0.8167062",
"0.81586... | 0.8286128 | 14 |
Write a function `anagrams(str1, str2)` that takes in two words and returns a boolean indicating whether or not the words are anagrams. Anagrams are words that contain the same characters but not necessarily in the same order. Solve this without using `Arraysort` or `Arraysort_by`. | def anagrams(str1, str2)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anagrams?(str1, str2)\n return false unless str1.length == str2.length\n\n str1.each_char do |chr|\n return false unless str2.count(chr) == str1.count(chr)\n end\n\n true\nend",
"def are_anagrams?(str1, str2)\n # if different length, then can't possibly match\n return false if str1.length != str2.le... | [
"0.9070155",
"0.9026226",
"0.9014158",
"0.8991528",
"0.89730996",
"0.8948751",
"0.8903333",
"0.8874652",
"0.88339776",
"0.8830037",
"0.88141763",
"0.8813923",
"0.88133454",
"0.8797188",
"0.87943155",
"0.87943155",
"0.87934756",
"0.8783717",
"0.87818086",
"0.87818086",
"0.8781... | 0.8277312 | 57 |
Define a recursive method `permutations(array)` that returns all of the permutations of an array example => permutations([1,2,3]) should return => [ [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1] ] You CANNOT use call Ruby's builtin `Arraypermutation` method. | def permutations(array)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permutations(array)\n\treturn array.permutation\nend",
"def permutations(array)\n return [array] if array.length == 1\n\n perms = []\n array.each do |el|\n dupped = array.dup\n dupped.delete(el)\n permutations(dupped).each { |perm| perms << [el] + perm }\n end\n\n perms\nend",
"def permutatio... | [
"0.8647117",
"0.8589345",
"0.8478354",
"0.84593046",
"0.8430611",
"0.8413266",
"0.8404853",
"0.8382999",
"0.83511484",
"0.8347155",
"0.83425707",
"0.830749",
"0.83056116",
"0.82848465",
"0.817577",
"0.8171826",
"0.81556547",
"0.81370294",
"0.8060257",
"0.80356085",
"0.7976874... | 0.84100753 | 9 |
Back in the good old days, you used to be able to write a darn near uncrackable code by simply taking each letter of a message and incrementing it by a fixed number, so "abc" by 2 would look like "cde", wrapping around back to "a" when you pass "z". Write a function, `caesar_cipher(str, shift)` which will take a message and an increment amount and outputs the encoded message. Assume lowercase and no punctuation. Preserve spaces. To get an array of letters "a" to "z", you may use `("a".."z").to_a`. To find the position of a letter in the array, you may use `Arrayfind_index`. | def caesar_cipher(str, shift)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def caesar_cipher(string, shift_factor)\n\n\n upc_alphabet_arr = ('A'..'Z').to_a\n downc_alphabet_arr = ('a'..'z').to_a\n\n\n string_chars_arr = string.chars\n\n new_chars_arr = []\n\n string_chars_arr.each do |char|\n if upc_alphabet_arr.include?(char)\n new_index = (upc_alphabet_arr.index(char) + sh... | [
"0.8599134",
"0.8594511",
"0.85886806",
"0.8567948",
"0.856101",
"0.8551369",
"0.85338473",
"0.85260546",
"0.85254586",
"0.85237694",
"0.85232854",
"0.85210884",
"0.8505192",
"0.8492382",
"0.8481106",
"0.84583384",
"0.8453188",
"0.84526193",
"0.84524393",
"0.84277356",
"0.842... | 0.8459711 | 15 |
Write a recursive method that takes in a base 10 number n and converts it to a base b number. Return the new number as a string E.g. base_converter(5, 2) == "101" base_converter(31, 16) == "1f" | def base_converter(num, b)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_converter(num, b)\n\n return num.to_s if [0, 1].include?(num)\n\n digits = %w(0123456789abcdef)\n base_converter(num/b, b) + digits[num % b]\n\nend",
"def base_converter(num, b)\n return \"\" if num == 0\n digits = %w(0 1 2 3 4 5 6 7 8 9 a b c d e f)\n\n base_converter(num/b, b) + digits[num... | [
"0.83575493",
"0.8238559",
"0.8166278",
"0.79266685",
"0.752838",
"0.74049246",
"0.73185587",
"0.72491074",
"0.70962274",
"0.70758754",
"0.70092463",
"0.70092463",
"0.6985597",
"0.6976186",
"0.69758296",
"0.695093",
"0.69158375",
"0.6788643",
"0.6671125",
"0.6626104",
"0.6615... | 0.74677706 | 5 |
Write a recursive method `subsets(array)` that returns all of the subsets of an array example => subsets([1,2,3]) should return => [ [], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3] ] | def subsets(array)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subsets(array)\n if array.length <= 1\n return array\n end\n subset_array = []\n (0..array.length - 1).each do |i|\n subset_array << subsets(array[0...i]) << subsets(array[0...i]).concat([array[-1]])\n end\n return subset_array\nend",
"def subsets(arr)\n return [arr] if arr.em... | [
"0.87269956",
"0.8644677",
"0.864104",
"0.86296016",
"0.8595369",
"0.85549206",
"0.84374523",
"0.8425629",
"0.8392272",
"0.8386299",
"0.836957",
"0.827848",
"0.82594174",
"0.82570493",
"0.82448715",
"0.82265544",
"0.82134014",
"0.8204193",
"0.8200897",
"0.81033313",
"0.810333... | 0.81932193 | 20 |
See question here: Write a recursive method to solve `make_better_change`. HINT: To make_better_change, we only take one coin at a time and never rule out denominations that we've already used. This allows each coin to be available each time we get a new remainder. By iterating over the denominations and continuing to search for the best change, we assure that we test for 'nongreedy' uses of each denomination. `make_better_change(24, [10,7,1])` should return [10,7,7] | def make_better_change(value, coins)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_better_change(amount, coin_denoms)\n return [amount] if coin_denoms.include?(amount)\n return [] if amount <= 0\n\n coin_denoms.sort.reverse!\n all_possible_arr = []\n\n coin_denoms.each do |value|\n change_arr = []\n change_arr << value\n change_arr.concat(make_better_change(amount - value,... | [
"0.8316564",
"0.8313527",
"0.8258674",
"0.82523847",
"0.82502264",
"0.82125086",
"0.817377",
"0.8012915",
"0.79881406",
"0.7953267",
"0.7931597",
"0.7929538",
"0.7929538",
"0.79112273",
"0.7862891",
"0.78613335",
"0.78555894",
"0.7845935",
"0.78330916",
"0.7801413",
"0.774690... | 0.64890194 | 63 |
THIS PROBLEM WILL NOT SHOW UP ON A REAL ASSESSMENT If you are a nonnative English speaker and find it difficult to understand this problem, do not spend too much time on it. Focus on other problems instead. Define a method `pig_latinify(sentence)` that translates a sentence into pig latin. You may want a helper method. Rules In the English language, vowels are the following letters: ['a', 'e', 'i', 'o', 'u'] Consonants are all other letters. Pig latin translation uses the following rules: 1. If the word begins with a vowel, simply append `ay` onto the end. ex. 'apple' => 'appleay' 2. If the word begins with a consonant, move the starting consonants to the end of the word and then append `ay` ex1. 'pearl' => 'earlpay' ex2. `school` => `oolschay` 3. Treat `qu` at the start of a word as a singular consonant. ex1. `queen` => `eenquay` ex2. `square` => `aresquay` | def pig_latinify(sentence)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pig_latin_sentence(sentence)\n y = sentence\n x = sentence.split\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n t = \"t\"\n h = \"h\"\n qu = \"qu\"\n\n x.map do |word|\n first_letter = word[0]\n if vowels.include?(first_letter)\n word << \"way\"\n elsif word.include?(t && h)\n word ... | [
"0.8841267",
"0.87730575",
"0.867668",
"0.8656043",
"0.8618591",
"0.8613246",
"0.8606145",
"0.85803676",
"0.85799867",
"0.8579038",
"0.85786974",
"0.8566909",
"0.856355",
"0.8539216",
"0.8521281",
"0.84993243",
"0.84407496",
"0.8440136",
"0.8426666",
"0.8412286",
"0.8398716",... | 0.84793234 | 16 |
It is sometimes necessary to be able to break down a number into its prime factors. The process is called prime factorization. We can use a factor tree to determine the prime factorization of a number: 12 / \ / \ 4 3 / \ 2 2 Define a method `prime_factorization(n)` that breaks a number down into it's prime factors. example: prime_factorization(12) => [2,2,3] | def prime_factorization(num)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prime_factorization(num)\n if is_prime?(num)\n return [num]\n end\n factors = []\n (2..num).each do |factor|\n if num % factor == 0\n factors << factor\n factors << prime_factorization(num/factor)\n \n break\n end\n end\n factor... | [
"0.8428887",
"0.82478887",
"0.8245271",
"0.8202063",
"0.81589955",
"0.81140804",
"0.81140804",
"0.81003475",
"0.80887234",
"0.80355823",
"0.8033517",
"0.80309725",
"0.80170643",
"0.7986394",
"0.7977813",
"0.7956462",
"0.79532456",
"0.79420835",
"0.79312116",
"0.7917168",
"0.7... | 0.76571995 | 51 |
You are not required to implement this; it's here as a suggestion :) | def bubble_sort!(&prc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def custom; end",
"def custom; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def anchored; end",
"def implementation; end",
"def implementation; end",
"def who_we_are\r\n end",
"def schubert; end",
"def internal... | [
"0.7553544",
"0.6552228",
"0.6468686",
"0.6468686",
"0.6329687",
"0.6329687",
"0.6329687",
"0.6329687",
"0.6240793",
"0.62360597",
"0.62360597",
"0.6225513",
"0.6177131",
"0.6068755",
"0.60113126",
"0.59909743",
"0.59866005",
"0.59866005",
"0.5981032",
"0.5937013",
"0.5912015... | 0.0 | -1 |
Write a method that takes a string and an alphabet. It returns a copy of the string with the letters reordered according to their positions in the alphabet. If no alphabet is passed in, it defaults to normal alphabetical order (az). Do NOT use `Arraysort` or `Arraysort_by`. Example: `jumble_sort("hello")` => "ehllo" `jumble_sort("hello", ['o', 'l', 'h', 'e'])` => 'ollhe' | def jumble_sort(str, alphabet = nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jumble_sort(str, alphabet = nil)\n alphabet ||= (\"a\"..\"z\").to_a\n\n new_string = str.split(\"\").sort do |letter_a, letter_b|\n alphabet.find_index(letter_a) <=> alphabet.find_index(letter_b)\n end\n new_string.join\nend",
"def jumble_sort(str, alphabet = nil)\n return str.split(\"\").sort.join i... | [
"0.82605445",
"0.8129675",
"0.79923725",
"0.79903567",
"0.7891827",
"0.7886857",
"0.7872977",
"0.78611183",
"0.7830589",
"0.77589554",
"0.76950973",
"0.75813735",
"0.7578386",
"0.7437177",
"0.70201355",
"0.6944216",
"0.6866046",
"0.6866045",
"0.68637824",
"0.6863201",
"0.6724... | 0.8202616 | 3 |
Define a method `rec_sum(nums)` that returns the sum of all elements in an array recursively | def rec_sum(nums)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum(nums)\n return 0 if nums.empty?\n nums[0] + sum_rec(nums[1..-1])\nend",
"def sum_rec(nums)\n return 0 if nums.empty?\n nums[0] + sum_rec(nums[1..-1])\nend",
"def sum_rec(nums)\n return 0 if nums.empty?\n nums[0] + sum_rec(nums.drop(1))\nend",
"def sum_rec(nums)\n return 0 if nums.length == 0\n... | [
"0.83367825",
"0.82483006",
"0.8013581",
"0.79152244",
"0.79009026",
"0.78916806",
"0.782543",
"0.78227",
"0.78149915",
"0.77546424",
"0.769735",
"0.7678221",
"0.76095736",
"0.75948626",
"0.7591033",
"0.75586843",
"0.7542731",
"0.7514435",
"0.7514305",
"0.7504766",
"0.7500284... | 0.83437324 | 1 |
Write a method that returns b^n recursively. Your solution should accept negative values for n. | def exponent(b, n)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exponentiation(b, n)\n return 1 if n == 0\n\n return exponentiation(b, n - 1) * b\nend",
"def exponent(b, n)\n return 1 if n == 0\n if n > 0\n b * exponent(b, n - 1)\n else\n 1.0/b * exponent(b, n + 1)\n end\nend",
"def exponent(b, n)\n return 1 if n == 0\n if n > 0\n b * exponent(b, n... | [
"0.7867685",
"0.7718268",
"0.7718268",
"0.7708262",
"0.76860213",
"0.7595162",
"0.75813276",
"0.7523488",
"0.75191253",
"0.7430109",
"0.7412472",
"0.73890454",
"0.73381114",
"0.73173046",
"0.7310674",
"0.7285143",
"0.72811705",
"0.7151168",
"0.7126279",
"0.71241736",
"0.71201... | 0.73164076 | 16 |
Write a recursive method that returns the sum of the first n even numbers recursively. Assume n > 0. | def first_even_numbers_sum(n)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_even_numbers_sum(n)\n return 2 if n == 1\n 2 * n + first_even_numbers_sum(n-1)\n end",
"def first_even_numbers_sum(n)\n return 2 if n == 1\n 2 * n + first_even_numbers_sum(n-1)\nend",
"def recursion(n)\n if n % 2 ==0\n n\n else\n recursion(n + 1)\nend\nend",
"def even_num_rec(n)\n ... | [
"0.88773525",
"0.88209176",
"0.7575595",
"0.7511886",
"0.7442943",
"0.7334038",
"0.73173136",
"0.7249176",
"0.72258985",
"0.72222763",
"0.72195196",
"0.71986216",
"0.7167344",
"0.71563643",
"0.71517795",
"0.71517795",
"0.71517795",
"0.71517795",
"0.7151437",
"0.7128636",
"0.7... | 0.8361318 | 3 |
Write a recursive method `string_include_key?(string, key)` that takes in a string to search and a key string. Return true if the string contains all of the characters in the key in the same order that they appear in the key. example_1: string_include_key?("cadbpc", "abc") => true example_2: string_include_key("cba", "abc") => false | def string_include_key?(string, key)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string_include_key?(string, key)\n return true if key == \"\"\n string.each_char.with_index do |char, idx|\n if char == key[0]\n return string_include_key(string[(idx + 1)..-1], key[1..-1])\n end\n end\n\n false\nend",
"def string_include_key?(string, key)\n return true ... | [
"0.8987253",
"0.89137924",
"0.8889353",
"0.87755823",
"0.8721188",
"0.8523977",
"0.6659698",
"0.665448",
"0.63056636",
"0.627746",
"0.62403536",
"0.6211641",
"0.6196496",
"0.619202",
"0.6184977",
"0.61618227",
"0.61611706",
"0.6121738",
"0.6109552",
"0.6103083",
"0.6071483",
... | 0.8242099 | 8 |
Write a recursive method that returns the first "num" factorial numbers in ascending order. Note that the 1st factorial number is 0!, which equals 1. The 2nd factorial is 1!, the 3rd factorial is 2!, etc. | def factorials_rec(num)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_factorial(num)\n if num < 2\n return 1\n else\n return num * first_factorial(num - 1)\n end\nend",
"def FirstFactorial(num)\n if num > 1\n return num*(FirstFactorial(num-1)) \n end\n return num \nend",
"def factorialrecursion num\n\tif num < 0\n\t\tnil\n\tend\n\t\n\tif nu... | [
"0.8556982",
"0.8358095",
"0.81390655",
"0.8106482",
"0.80206656",
"0.7777546",
"0.776495",
"0.7758426",
"0.7750472",
"0.7726955",
"0.771697",
"0.77163166",
"0.7710064",
"0.77042234",
"0.77035886",
"0.769294",
"0.7690432",
"0.76596737",
"0.7648177",
"0.7648177",
"0.7648177",
... | 0.0 | -1 |
Write a method that finds the sum of the first n fibonacci numbers recursively. Assume n > 0. | def fibs_sum(n)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n - 1) + fibs_sum(n - 2) + 1\nend",
"def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend",
"def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2... | [
"0.8981103",
"0.897471",
"0.897471",
"0.897471",
"0.897471",
"0.87479585",
"0.87065566",
"0.86833096",
"0.86395675",
"0.8585491",
"0.8540424",
"0.85397935",
"0.85042083",
"0.8501192",
"0.8486396",
"0.8470936",
"0.84407544",
"0.84372413",
"0.8435925",
"0.8426029",
"0.8420815",... | 0.82296354 | 75 |
Using recursion and the `is_a?` method, write an `Arraydeep_dup` method that will perform a "deep" duplication of the interior arrays. | def deep_dup(arr)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive_deep_dup(arr)\n # # does arr contain anymore arrays?\n # if !(arr.is_a? Array)\n # arr\n # else\n # arr[recursive_deep_dup(arr)].dup\n # arr_copy = arr.dup\n arr_copy = []\n arr.each do |sub|\n if sub.is_a? Array\n # sub_copy = sub.dup\n # p sub_copy\n # recursive_deep_d... | [
"0.8449243",
"0.8212479",
"0.8200234",
"0.8174518",
"0.814501",
"0.8058728",
"0.80546415",
"0.8049845",
"0.8030621",
"0.80120975",
"0.7983847",
"0.79547346",
"0.7933665",
"0.79264325",
"0.7919462",
"0.7916924",
"0.7916924",
"0.7916924",
"0.7900404",
"0.7895804",
"0.7887487",
... | 0.85044515 | 2 |
Write a method, `digital_root(num)`. It should Sum the digits of a positive integer. If it is greater than 9 (i.e. more than one digit), sum the digits of the resulting number. Keep repeating until there is only one digit in the result, called the "digital root". Do NOT use the built in `Integerto_s` or `Integerdigits` methods in your implementation. You may wish to use a helper function, `digital_root_step(num)` which performs one step of the process. | def digital_root(num)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def digital_root(num)\n digits = []\n until num == 0\n digits << num % 10\n num /= 10\n end\n sum = digits.reduce(0, :+)\n sum < 10 ? sum : digital_root(sum)\nend",
"def digital_root(num)\n while num >= 10\n num = digit_sum(digits(num))\n end\n num\nend",
"def digital_root(num)\n return num... | [
"0.85687935",
"0.8507984",
"0.83947444",
"0.8332727",
"0.8288676",
"0.8264662",
"0.8260138",
"0.8258121",
"0.81567365",
"0.8051066",
"0.7998651",
"0.7973149",
"0.7963087",
"0.7932783",
"0.79193586",
"0.79143745",
"0.7882045",
"0.7866445",
"0.7866445",
"0.7866445",
"0.7777042"... | 0.74865025 | 36 |
Write a method that doubles each element in an array. Assume all elements of the array are integers. | def doubler(array)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_doubles(arr)\n arr.map {|a|a*2}\n\nend",
"def calculate_doubles!(array)\n\t\n\tarray.map! { |num| num * 2}\nend",
"def calculate_doubles(arr)\n doubled_array = []\n arr.each {|int| doubled_array.push(int * 2)}\n doubled_array\nend",
"def calculate_doubles!(arr)\n arr.map! {|int| int * 2}\n... | [
"0.78334135",
"0.7793091",
"0.7789141",
"0.7783288",
"0.7671744",
"0.7598676",
"0.7593664",
"0.7563257",
"0.75166327",
"0.74786144",
"0.7310658",
"0.72904456",
"0.7279631",
"0.7252194",
"0.72190785",
"0.72157377",
"0.71854794",
"0.71812576",
"0.7177584",
"0.7171713",
"0.71614... | 0.0 | -1 |
Define a method `primes(num)` that returns an array of the first "num" primes. You may wish to use an `is_prime?` helper method. | def primes(num)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primes(num)\n\twhole_array = (2..num).to_a\n\tprime_array = [whole_array.shift]\n\n\tuntil whole_array == []\n\t\twhole_array.delete_if { |x| x % prime_array.last == 0 }\n\t\tprime_array << whole_array.shift\n\tend\n\tprime_array\nend",
"def get_primes num\n primes = []\n for i in 0 ... num do\n ... | [
"0.76440054",
"0.75346",
"0.74419427",
"0.74032646",
"0.73564935",
"0.73544806",
"0.7349326",
"0.73464507",
"0.7345914",
"0.73427826",
"0.72873807",
"0.7286154",
"0.7262145",
"0.7199959",
"0.7164529",
"0.71369815",
"0.7088585",
"0.7079181",
"0.70356137",
"0.70328826",
"0.7007... | 0.69505763 | 29 |
Write a method that returns the factors of a number in ascending order. | def factors(num)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factors(num)\n\t((1..num).select {|n| num % n == 0 } ).sort\nend",
"def factors(num)\n factors = []\n for factor in 1..num\n factors << factor if num % factor == 0\n end\n factors.sort\nend",
"def factors(num)\n result = []\n for i in 1..num\n if num % i == 0\n result << i\n end\n end\... | [
"0.8575256",
"0.8532261",
"0.8478011",
"0.8477378",
"0.83777696",
"0.83758056",
"0.83459604",
"0.8343072",
"0.83401227",
"0.83394605",
"0.8335541",
"0.8334777",
"0.83283925",
"0.831717",
"0.8308934",
"0.8308751",
"0.8306715",
"0.8306715",
"0.8306715",
"0.8306715",
"0.8306715"... | 0.84801 | 4 |
Write an `Arraymy_controlled_flatten(n)` method that only flattens n levels of an array. For example, if you have an array with 3 levels of nested arrays, and run `arr.my_flatten(1)`, you should return an array with 1 level of nested arrays flattened. Example: `[1,[2,3], [4,[5]]].my_controlled_flatten(1)` => [1,2,3,4,[5]] | def my_controlled_flatten(n)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_controlled_flatten(n)\n flattened = []\n self.my_each do |el|\n if n > 0 && el.is_a?(Array)\n flattened += el.my_controlled_flatten(n - 1)\n else\n flattened << el\n end\n end\n flattened\n end",
"def my_controlled_flatten(n)\n flattened = []\n\n self.each d... | [
"0.8790983",
"0.8764352",
"0.87516683",
"0.8651184",
"0.8626679",
"0.8626679",
"0.86212575",
"0.7940102",
"0.7869281",
"0.7869235",
"0.70922625",
"0.6985684",
"0.6985684",
"0.69841427",
"0.69667184",
"0.69667184",
"0.69667184",
"0.69667184",
"0.69667184",
"0.69667184",
"0.695... | 0.83443964 | 8 |
GET /certifieds GET /certifieds.json | def index
@certifieds = Certified.where(user: self.current_user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @certifications = Certification.all\n end",
"def certs\n request :get, '/certs'\n end",
"def set_certified\n @certified = Certified.find(params[:id])\n end",
"def index\n @certifications = @certifications.sort_by(&:name)\n\n respond_to do |format|\n format.html # index.html... | [
"0.64023674",
"0.64013535",
"0.62414056",
"0.6160832",
"0.6140631",
"0.59337527",
"0.5896812",
"0.58808196",
"0.57871866",
"0.5755358",
"0.5751683",
"0.57469463",
"0.57280207",
"0.57280207",
"0.57280207",
"0.57280207",
"0.5726518",
"0.5675416",
"0.5665637",
"0.56452423",
"0.5... | 0.6654699 | 0 |
GET /certifieds/1 GET /certifieds/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @certifieds = Certified.where(user: self.current_user)\n end",
"def index\n @certifications = Certification.all\n end",
"def set_certified\n @certified = Certified.find(params[:id])\n end",
"def index\n @certs = Cert.all\n end",
"def show\n @concerts = Concert.find(params[:i... | [
"0.6450775",
"0.64422876",
"0.63641644",
"0.63593847",
"0.63547647",
"0.6341853",
"0.6232498",
"0.6190968",
"0.61797994",
"0.61444694",
"0.6120884",
"0.6018219",
"0.5944131",
"0.5944131",
"0.5944131",
"0.5944131",
"0.58838",
"0.5850074",
"0.5836835",
"0.58322656",
"0.5832056"... | 0.0 | -1 |
POST /certifieds POST /certifieds.json | def create
@certified = Certified.new(certified_params)
@certified.events = events
@certified.attendees = attendees
@certified.slug = generate_token
@certified.user = self.current_user
flash[:notice] = "Certificado criado com sucesso." if @certified.save
respond_with(@certified) do |format|
format.html { redirect_to @certified }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n respond_to do |format|\n if @certification.save\n format.html { redirect_to Certification, :notice => 'Certification was successfully created.' }\n format.json { render :json => @certification, :status => :created, :location => @certification }\n else\n format.html { ... | [
"0.6489707",
"0.6436034",
"0.6311841",
"0.6270349",
"0.6267243",
"0.6254824",
"0.6254824",
"0.6172796",
"0.60597944",
"0.6047397",
"0.6047397",
"0.6040358",
"0.6034543",
"0.5952242",
"0.59151787",
"0.5858251",
"0.58091444",
"0.57874733",
"0.57859355",
"0.5741499",
"0.57053375... | 0.69736564 | 0 |
PATCH/PUT /certifieds/1 PATCH/PUT /certifieds/1.json | def update
respond_to do |format|
@certified.background_url = params[:background_url]
if @certified.update(certified_params)
format.html { redirect_to @certified, notice: 'Certified was successfully updated.' }
format.json { head :no_content }
else
format.html {
render action: 'edit', alert: @certified.errors.to_a
}
format.json { render json: @certified.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @cert.update(cert_params)\n format.html { redirect_to @cert, notice: 'Cert was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cert.errors, stat... | [
"0.67089456",
"0.6598706",
"0.6578622",
"0.6372914",
"0.6175863",
"0.6173402",
"0.61700946",
"0.60551465",
"0.6050975",
"0.6028821",
"0.60144734",
"0.599366",
"0.59705466",
"0.59705466",
"0.591571",
"0.591571",
"0.5899892",
"0.588313",
"0.58670896",
"0.5841749",
"0.5785926",
... | 0.628047 | 4 |
DELETE /certifieds/1 DELETE /certifieds/1.json | def destroy
@certified.destroy
respond_to do |format|
format.html { redirect_to certifieds_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @cert.destroy\n respond_to do |format|\n format.html { redirect_to certs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cert.destroy\n respond_to do |format|\n format.html { redirect_to certs_url, notice: 'Cert was successfully destroyed.' }\n ... | [
"0.7595877",
"0.741068",
"0.73887163",
"0.7270093",
"0.7259015",
"0.7259015",
"0.71330494",
"0.7105309",
"0.7025883",
"0.7000783",
"0.6947421",
"0.6929092",
"0.6903883",
"0.6903883",
"0.6903883",
"0.68865",
"0.6877033",
"0.6791788",
"0.67452013",
"0.6692637",
"0.6690766",
"... | 0.79015255 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_certified
@certified = Certified.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def certified_params
params.require(:certified).permit( :background_url, :event_id, :name_color)
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 |
convert.exe before.jpg region "230x140+60+130" ^ fill black ^ fuzz 25%% ^ opaque rgb("192","00","10") | def apply(image)
image.view(0,0,image.columns,image.rows) do |view|
eyes.each { |eye| do_redeye(eye,view) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main()\n img = ImageList.new($input)\n convert = ImageList.new\n page = Magick::Rectangle.new(0,0,0,0)\n $total_ops = (img.rows * img.columns).to_f\n\n for i in 0..img.rows\n for j in 0..img.columns\n pixel = generate_hex_pixel(rgb_to_hex(img.pixel_color(j,i)))\n convert << pi... | [
"0.6789784",
"0.6426912",
"0.6267639",
"0.6188794",
"0.6138022",
"0.6126526",
"0.60962427",
"0.60889447",
"0.6058799",
"0.6045048",
"0.59996927",
"0.5942661",
"0.5926982",
"0.5922603",
"0.5901185",
"0.58667105",
"0.5866098",
"0.58300483",
"0.5829824",
"0.58087254",
"0.5804506... | 0.0 | -1 |
This algorithm ported directly from shotwell. | def do_redeye(eye,pixbuf)
#
# we remove redeye within a circular region called the "effect
#extent." the effect extent is inscribed within its "bounding
#rectangle." */
# /* for each scanline in the top half-circle of the effect extent,
# compute the number of pixels by which the effect extent is inset
#from the edges of its bounding rectangle. note that we only have
#to do this for the first quadrant because the second quadrant's
#insets can be derived by symmetry */
r = eye.radius
x_insets_first_quadrant = Array.new(eye.radius + 1)
i = 0
r.step(0,-1) do |y|
theta = Math.asin(y.to_f / r)
x = (r.to_f * Math.cos(theta) + 0.5).to_i
x_insets_first_quadrant[i] = eye.radius - x
i = i + 1
end
x_bounds_min = eye.x - eye.radius
x_bounds_max = eye.x + eye.radius
ymin = eye.y - eye.radius
ymin = (ymin < 0) ? 0 : ymin
ymax = eye.y
ymax = (ymax > (pixbuf.height - 1)) ? (pixbuf.height - 1) : ymax
#/* iterate over all the pixels in the top half-circle of the effect
#extent from top to bottom */
inset_index = 0
ymin.upto(ymax) do |y_it|
xmin = x_bounds_min + x_insets_first_quadrant[inset_index]
xmin = (xmin < 0) ? 0 : xmin
xmax = x_bounds_max - x_insets_first_quadrant[inset_index]
xmax = (xmax > (pixbuf.width - 1)) ? (pixbuf.width - 1) : xmax
xmin.upto(xmax) { |x_it| red_reduce_pixel(pixbuf,x_it, y_it) }
inset_index += 1
end
#/* iterate over all the pixels in the bottom half-circle of the effect
#extent from top to bottom */
ymin = eye.y
ymax = eye.y + eye.radius
inset_index = x_insets_first_quadrant.length - 1
ymin.upto(ymax) do |y_it|
xmin = x_bounds_min + x_insets_first_quadrant[inset_index]
xmin = (xmin < 0) ? 0 : xmin
xmax = x_bounds_max - x_insets_first_quadrant[inset_index]
xmax = (xmax > (pixbuf.width - 1)) ? (pixbuf.width - 1) : xmax
xmin.upto(xmax) { |x_it| red_reduce_pixel(pixbuf,x_it, y_it) }
inset_index -= 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alg; end",
"def find_pair\n before = self.entropy\n reduce_pair_line\n reduce_pair_col\n reduce_pair_grid\n reduce_solved if before > self.entropy\n self\n end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"... | [
"0.6287924",
"0.567249",
"0.56470215",
"0.56470215",
"0.56470215",
"0.56470215",
"0.56470215",
"0.5637161",
"0.5600668",
"0.557326",
"0.55539596",
"0.5537526",
"0.55296856",
"0.5529109",
"0.5520327",
"0.551692",
"0.5516786",
"0.5513311",
"0.54849905",
"0.54689443",
"0.5456625... | 0.0 | -1 |
display all current user computers | def list
user = User.find(current_user.id)
@computers = user.computer.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if signed_in?\n @computers = current_user.computers.all.decorate\n @computer = current_user.computers.new\n end\n end",
"def list_current_user\n abort \"You have no current user set!\".yellow unless current_user_exists?\n puts \"\\nCurrent User\"\n config.current_user.... | [
"0.6756206",
"0.6462351",
"0.6424491",
"0.63315994",
"0.62772167",
"0.62321085",
"0.6181889",
"0.6097736",
"0.6088224",
"0.60542756",
"0.60407895",
"0.5988704",
"0.5986329",
"0.5938417",
"0.59100336",
"0.5893264",
"0.5864887",
"0.5836878",
"0.5789722",
"0.5788966",
"0.5776196... | 0.83014435 | 0 |
simulate the P2P network i starting origins n peers tr array of [t, r] | def simulate i, n, tr
unless tr[0].is_a?(Numeric) && tr[1].is_a?(Numeric)
require 'pry'
binding.pry
end
er = tr[0].to_f / (n-2)
ps = i.to_f / n
data = {prior_s: ps, prob_ex: er, total_queries: 0, kdist: []}
# every peer (other than origins) might get to do a direct query and/or get extra responses
know = Array.new(n - i) { false }
data[:responses] = []
k = i
j = 0
while k < n
# pick a peer that doesn't know yet
z = know.each_index.find { |l| !know[l] }
resp = 0
loop do
# record current knowledge dist
data[:kdist][data[:total_queries]] = k
# make a new query
data[:total_queries] += 1
# how many peers responded?
resp = k.times.count { rand < tr[1] }
break if resp > 0
end
data[:responses][j] = {extra: [], queries: data[:total_queries] - 1}
# how many non-origin peers responded?
exres = 0
if resp > i
exres = resp - i
end
nonorg = 0
# record responses
extra = 0
know.each_index do |l|
# if this is the querying peer
if l == z
# they get a direct response
data[:responses][j][:direct] = resp
know[l] = true
next
end
# else see how many extra responses we got
# resp peers are sending extra responses
exre_senders = resp
# subtract 1 if this is one of the k peers
if know[l] && nonorg < exres
exre_senders -= 1
nonorg += 1
end
reses = exre_senders.times.count { rand < er }
# if we got respones
if reses > 0
# record it
data[:responses][j][:extra] << reses
# check if this spread knowledge
if !know[l]
know[l] = true
extra += 1
end
end
end
k += 1 + extra
j += 1
end
data[:kdist][data[:total_queries]] = n
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simulate i, n, t\n er = t.to_f / (n-2)\n ps = i.to_f / n\n data = {prior_s: ps, prob_ex: er, total_queries: 0, kdist: []}\n\n # every peer (other than origins) might get to do a direct query and/or get extra responses\n know = Array.new(n - i) { false }\n data[:responses] = []\n\n k = i\n j = 0\n whil... | [
"0.62776434",
"0.56342787",
"0.55337226",
"0.54760855",
"0.5253529",
"0.5198142",
"0.517477",
"0.5146634",
"0.5137675",
"0.5136337",
"0.5064142",
"0.50373375",
"0.4990826",
"0.49727556",
"0.49395207",
"0.49336106",
"0.48921725",
"0.4889871",
"0.4880847",
"0.48753926",
"0.4868... | 0.67510366 | 0 |
GET /drawings/1 GET /drawings/1.json | def show
@drawing = Drawing.find(params[:id])
render json: @drawing
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @drawings = Drawing.all\n end",
"def index\n @draws = Draw.paginate(:page => params[:page], :per_page => 50)\n @winning_draws = Draw.where(:selection => \"WINNER\")\n @draw = Draw.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dra... | [
"0.71373606",
"0.7108541",
"0.7031232",
"0.6586291",
"0.6414555",
"0.63620937",
"0.62450653",
"0.60835487",
"0.60278845",
"0.6012221",
"0.5936713",
"0.5911544",
"0.58977276",
"0.58437717",
"0.5809068",
"0.5800402",
"0.5795278",
"0.5788694",
"0.5782666",
"0.5779801",
"0.574471... | 0.74483734 | 0 |
GET /drawings/new GET /drawings/new.json | def new
@drawing = Drawing.new
render json: @drawing
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @draw = Draw.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @draw }\n end\n end",
"def new\n @withdrawal = Withdrawal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @withdrawal }\n ... | [
"0.75208336",
"0.6978218",
"0.69780195",
"0.6862454",
"0.68167627",
"0.6771684",
"0.6691346",
"0.6449592",
"0.6449592",
"0.639493",
"0.6382087",
"0.636552",
"0.63246375",
"0.63104844",
"0.63050336",
"0.6297263",
"0.62531143",
"0.62492716",
"0.6231992",
"0.61975193",
"0.618364... | 0.7591941 | 0 |
POST /drawings POST /drawings.json | def create
@drawing = Drawing.new(params[:drawing])
if @drawing.save
render json: @drawing, status: :created, location: @drawing
else
render json: @drawing.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @drawing = Drawing.new(drawing_params)\n\n respond_to do |format|\n if @drawing.save\n format.html { redirect_to @drawing, notice: 'Drawing was successfully created.' }\n format.json { render :show, status: :created, location: @drawing }\n else\n format.html { rend... | [
"0.6910724",
"0.6687737",
"0.6657411",
"0.64601356",
"0.6385349",
"0.62101865",
"0.6162789",
"0.60166717",
"0.5957114",
"0.59391785",
"0.59104735",
"0.58873063",
"0.58715785",
"0.58024114",
"0.5800152",
"0.56954676",
"0.5686099",
"0.56544584",
"0.56416744",
"0.5616906",
"0.55... | 0.7109006 | 0 |
PATCH/PUT /drawings/1 PATCH/PUT /drawings/1.json | def update
@drawing = Drawing.find(params[:id])
if @drawing.update_attributes(params[:drawing])
head :no_content
else
render json: @drawing.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @draw = Draw.find(params[:id])\n\n respond_to do |format|\n if @draw.update_attributes(params[:draw])\n format.html { redirect_to @draw, notice: 'Draw was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n... | [
"0.7125346",
"0.711631",
"0.70599157",
"0.7040108",
"0.6485048",
"0.6449785",
"0.63194305",
"0.611239",
"0.608619",
"0.60325533",
"0.59873444",
"0.5968558",
"0.59627676",
"0.59383816",
"0.5936856",
"0.59348726",
"0.59338003",
"0.5921413",
"0.59095186",
"0.588861",
"0.586535",... | 0.73792917 | 0 |
DELETE /drawings/1 DELETE /drawings/1.json | def destroy
@drawing = Drawing.find(params[:id])
@drawing.destroy
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @draw = Draw.find(params[:id])\n @draw.destroy\n\n respond_to do |format|\n format.html { redirect_to draws_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @draw.destroy\n respond_to do |format|\n format.html { redirect_to draws_url, notice: '... | [
"0.76401263",
"0.7478449",
"0.735697",
"0.70703363",
"0.6947641",
"0.68477297",
"0.67222047",
"0.66976917",
"0.6584963",
"0.654797",
"0.65413046",
"0.65351266",
"0.64933217",
"0.64792794",
"0.6429699",
"0.6410615",
"0.63008165",
"0.62999004",
"0.62818027",
"0.6236122",
"0.623... | 0.7392531 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.