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 |
|---|---|---|---|---|---|---|
Use callbacks to share common setup or constraints between actions. | def set_veiculo_motorista
@veiculo_motorista = VeiculoMotorista.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 veiculo_motorista_params
params.require(:veiculo_motorista).permit(:veiculo_id, :motorista_id, :status)
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 |
Add support for getting comments | def getComments
self.root_comments
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comments; end",
"def comments; end",
"def comments; end",
"def comments; end",
"def comments; end",
"def comments; end",
"def consume_comments; end",
"def comments\n pull_comments\n @comments_list\n end",
"def comments\n\t\t\t@comments ||= read_comments\n\t\tend",
"def comments\n ... | [
"0.81732225",
"0.81732225",
"0.81732225",
"0.81732225",
"0.81732225",
"0.81732225",
"0.77419966",
"0.75509065",
"0.7477337",
"0.73922426",
"0.7225233",
"0.7225233",
"0.7214852",
"0.7174112",
"0.7174112",
"0.7174112",
"0.7174112",
"0.7174112",
"0.7174112",
"0.7174112",
"0.7174... | 0.66210926 | 76 |
Overwriting the sign_out redirect path method | def after_sign_out_path_for(resource_or_scope)
if resource_or_scope == :admin
new_admin_session_path
else
new_user_session_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_sign_out_path_for(resource_or_scope)\n '/signed_out'\n end",
"def after_sign_out_path_for(_resource_or_scope)\n '/'\n end",
"def after_sign_out_path_for(resource_or_scope); end",
"def signout_url\n {:controller => 'auth', :action => 'signout'}\n end",
"def after_sign_out_path_for(reso... | [
"0.8102037",
"0.8007481",
"0.7984188",
"0.79324496",
"0.7897868",
"0.78892565",
"0.7874593",
"0.78685254",
"0.7857867",
"0.78436327",
"0.78436327",
"0.78436327",
"0.78436327",
"0.7842701",
"0.7821579",
"0.77880424",
"0.7748489",
"0.77373666",
"0.7731692",
"0.77291566",
"0.772... | 0.0 | -1 |
need to refactor this, but home_controller cannot do multiple skips?? | def validate_user_authorization
user = User.find_by_id(params[:id])
require_valid_user user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skips; end",
"def skipped; end",
"def skip\n end",
"def skip\n end",
"def skipped!; end",
"def skip_actions; end",
"def index\n redirect_to disabled_path\n # unless logged_in?\n # redirect_to tour_path\n # else\n # @current_item = \"my_hsa\"\n # ... | [
"0.6603064",
"0.6154686",
"0.6127471",
"0.6127471",
"0.612652",
"0.60483104",
"0.59507567",
"0.5941843",
"0.5864651",
"0.5864651",
"0.5864651",
"0.5864651",
"0.58514",
"0.5786248",
"0.57743627",
"0.57743627",
"0.5756998",
"0.5711406",
"0.57079804",
"0.5692506",
"0.56792283",
... | 0.0 | -1 |
shorten. pass: url: the url to be shortened So to use: twurl = Shorty::Truwl.new twurl.shorten(' | def shorten(url)
query = { :'link[url]' => url }
self.class.post("/links", :query => query)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shorten(url)\n bitly_url = \"http://api.bit.ly/shorten?version=2.0.1&login=#{BITLY_LOGIN}&apiKey=#{BITLY_API_KEY}&longUrl=#{CGI::escape(url)}\"\n resp = open(bitly_url).read\n JSON.parse(resp)['results'][url]['shortUrl']\n rescue\n logger.debug(\"Unable to generate Bit.ly url for #{url}\")\n ni... | [
"0.80530053",
"0.80467165",
"0.79164016",
"0.7848189",
"0.7842859",
"0.7826023",
"0.78101313",
"0.7805245",
"0.7697066",
"0.768375",
"0.76509374",
"0.7628345",
"0.7602497",
"0.75701636",
"0.7517032",
"0.7509427",
"0.75025225",
"0.743538",
"0.7422505",
"0.74091196",
"0.7408588... | 0.7600482 | 13 |
Binary Search O(log n) | def search(an_array,item)
first = 0
last = an_array.length - 1
while first <= last
i = (first + last) / 2
if an_array[i] == item
return
# 6 < 5
# first = 6
elsif an_array[i] < item
first = i + 1
elsif an_array[i] > item
last = i - 1
else
# 6 > 5
# last = 5
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binary_search(numbers, element)\n min = 0\n max = numbers.size - 1\n\n index = nil\n\n while index.nil? do\n middle_element_index = (min + max) / 2 # Every iteration (N / 2) = O(log n)\n middle_element = numbers[middle_element_index] \n \n if element < middle_element\n m... | [
"0.76373416",
"0.7475979",
"0.7399161",
"0.73615175",
"0.7347026",
"0.7314209",
"0.73073804",
"0.7297506",
"0.72946084",
"0.72779703",
"0.72716993",
"0.72714156",
"0.7270871",
"0.7267975",
"0.7247053",
"0.7227337",
"0.722029",
"0.7203278",
"0.7189277",
"0.71764624",
"0.717395... | 0.0 | -1 |
Show's the enumeration's configured +Show+ view, as defined in streamlined_ui and Streamlined::Column. | def show_enumeration
self.instance = model.find(params[:id])
rel_type = model_ui.scalars[params[:enumeration].to_sym]
render(:file => rel_type.show_view.partial, :use_full_path => false,
:locals => {:item => instance, :relationship => rel_type})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show(value)\n @ole.Show = value\n nil\n end",
"def show\n default_semantic_show\n end",
"def set_show(val)\n self.show = val\n self\n end",
"def override_show_column_ui(list_ui)\r\n \"active_scaffold_show_#{list_ui}\"\r\n end",
"def show\n self.vis... | [
"0.65104926",
"0.63655216",
"0.6319261",
"0.618467",
"0.612976",
"0.60494447",
"0.60416734",
"0.5959447",
"0.5959447",
"0.5959447",
"0.5959447",
"0.5959447",
"0.5959447",
"0.5959447",
"0.5959447",
"0.5959447",
"0.58757544",
"0.58757544",
"0.5873129",
"0.5873129",
"0.58160776"... | 0.5883871 | 16 |
Select an item in the given enumeration. Used by the enumerable view, as defined in Streamlined::Column. | def update_enumeration
self.instance = model.find(params[:id])
item = (params[:item] == 'nil') ? nil : params[:item]
instance.update_attribute(params[:rel_name], item)
render(:nothing => true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def choice(indx)\n items[to_display.options[:choices][indx]]\n end",
"def select_item\n @selected = @current\n\n items\n end",
"def select_by_index(input)\r\n raise \"Index must be 0 or greater\" if input < 0\r\n begin\r\n expand_combo\r\n list_items[inp... | [
"0.61990607",
"0.60258186",
"0.59706527",
"0.5955629",
"0.5938615",
"0.5779483",
"0.5720658",
"0.56676394",
"0.5653086",
"0.55658346",
"0.554067",
"0.5514392",
"0.54762274",
"0.5466502",
"0.5420213",
"0.5420213",
"0.5420213",
"0.5360081",
"0.53600806",
"0.53522146",
"0.533008... | 0.0 | -1 |
GET /members GET /members.json | def index
@state = params[:status].present? ? params[:status] : "active"
if stale?([@space, @state, flash])
@members = @space.members.by_status(@state).order("name asc")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_members\n @user = User.find_by(user_params)\n @members = @user.members\n \n if not @members.nil?\n render json: @members\n else \n render json: \"\"\n end\n end",
"def members\n raw_response = get_request('users/members')\n ... | [
"0.85555315",
"0.8368444",
"0.80864495",
"0.79692763",
"0.79227495",
"0.7810278",
"0.7673862",
"0.7492891",
"0.74862355",
"0.7484284",
"0.7484284",
"0.7484284",
"0.7377688",
"0.7360226",
"0.7336541",
"0.7336541",
"0.7235276",
"0.7182636",
"0.718245",
"0.71680915",
"0.71680915... | 0.0 | -1 |
GET /members/1 GET /members/1.json | def show
if stale?([@member, flash])
@ledger_items = @member.member_invoices.order("created_at desc")
@history_items = @member.ledger_items
.where(status: ["closed", "cleared", "failed"])
.order("created_at desc")
.limit(6)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_members\n @user = User.find_by(user_params)\n @members = @user.members\n \n if not @members.nil?\n render json: @members\n else \n render json: \"\"\n end\n end",
"def members\n raw_response = get_request('users/members')\n ... | [
"0.8023607",
"0.74336106",
"0.7342003",
"0.7342003",
"0.7342003",
"0.73214304",
"0.7298026",
"0.72192717",
"0.7218691",
"0.7147416",
"0.7146131",
"0.7146131",
"0.7146131",
"0.7146131",
"0.7146131",
"0.7146131",
"0.7146131",
"0.7146131",
"0.7146131",
"0.71341074",
"0.70936525"... | 0.0 | -1 |
POST /members POST /members.json | def create
@member = @space.members.new(member_params)
@member.user = current_user
respond_to do |format|
if @member.save
@space.members << @member
format.html { redirect_to space_member_url(@space, @member), notice: 'Member was successfully created.' }
format.json { render :show, status: :created, location: [@space, @member] }
else
format.html { render :new }
format.json { render json: @member.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_member_to_list(user, list, member_id, options={})\n post(\"/#{user}/#{list}/members.json\", options.merge(:id => member_id))\n end",
"def create_member(data)\n headers = @client.make_request(:post, @client.concat_user_path(\"#{CONFERENCE_PATH}/#{id}/members\"), data)[1]\n id = Client.ge... | [
"0.6734318",
"0.6707801",
"0.66615456",
"0.66511947",
"0.6612481",
"0.6595865",
"0.6571146",
"0.6571146",
"0.6571146",
"0.6569636",
"0.65571123",
"0.65534073",
"0.6552213",
"0.6539384",
"0.6535769",
"0.6534659",
"0.6526704",
"0.6526704",
"0.6526704",
"0.6526704",
"0.6507443",... | 0.6686722 | 2 |
PATCH/PUT /members/1 PATCH/PUT /members/1.json | def update
respond_to do |format|
if @member.update(member_params)
format.html { redirect_to space_member_url(@space, @member), notice: 'Member was successfully updated.' }
format.json { render :show, status: :ok, location: [@space, @member] }
else
format.html { render :edit }
format.json { render json: @member.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n # byebug \n respond_to do |format|\n if self.current_member && self.current_member.id == params[:id].to_i\n if @member.update(member_params)\n format.json { render :show, status: :ok, location: @member }\n else\n return api_error(status: :unprocessable_entity... | [
"0.6825534",
"0.66732514",
"0.66082865",
"0.65920675",
"0.6553189",
"0.65405244",
"0.6517594",
"0.6517594",
"0.6517594",
"0.6517594",
"0.6517594",
"0.65155286",
"0.6492895",
"0.64920187",
"0.64920187",
"0.64920187",
"0.64920187",
"0.64920187",
"0.64920187",
"0.64920187",
"0.6... | 0.61127734 | 38 |
DELETE /members/1 DELETE /members/1.json | def destroy
@member.destroy
respond_to do |format|
format.html { redirect_to space_members_url(@space), notice: 'Member was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n \n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to me... | [
"0.76810235",
"0.7641482",
"0.7641482",
"0.76110274",
"0.76110274",
"0.7567863",
"0.7567863",
"0.7557461",
"0.7545494",
"0.7545494",
"0.7545494",
"0.7545494",
"0.7545494",
"0.7545494",
"0.7545494",
"0.73533356",
"0.7306361",
"0.7306361",
"0.7306361",
"0.7306361",
"0.7306361",... | 0.6972323 | 55 |
Use callbacks to share common setup or constraints between actions. | def set_member
@member = @space.members.friendly.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 member_params
params.require(:member).permit(:name, :email, :location_id, :plan_id, :status)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /loans or /loans.json | def index
@loans = Loan.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loans\n url = \"#{LOANS_PATH}/pre-approved\"\n data = perform_get(url)\n data || {}\n end",
"def index\n @loans = Loan.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @loans }\n end\n end",
"def index\... | [
"0.6826537",
"0.6537598",
"0.64159024",
"0.6415585",
"0.6327823",
"0.62531495",
"0.6161418",
"0.6144067",
"0.6075828",
"0.60086364",
"0.59481794",
"0.5947637",
"0.593769",
"0.58940655",
"0.5810782",
"0.58028126",
"0.579234",
"0.5788496",
"0.5757764",
"0.5750815",
"0.5743334",... | 0.60713345 | 10 |
GET /loans/1 or /loans/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def specific\n @state = State.find(params[:id])\n @loans = @state.loans.where(:purpose_id == params[:purpose_id])\n render json: { state: @state, loans: @loans }\n end",
"def show\n @loan = Loan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { r... | [
"0.6543157",
"0.6495447",
"0.6494963",
"0.6491412",
"0.6355428",
"0.6291733",
"0.61194766",
"0.6079159",
"0.6042374",
"0.6035625",
"0.6019342",
"0.6019342",
"0.59851944",
"0.59557253",
"0.5955025",
"0.5908463",
"0.5897701",
"0.58903205",
"0.5868023",
"0.5864134",
"0.5817883",... | 0.0 | -1 |
POST /loans or /loans.json | def create
@loan = Loan.new(loan_params.merge(user: current_user))
respond_to do |format|
if @loan.save
format.html { redirect_to books_path, notice: "Book added to your library" }
else
format.html { render :new, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n logger.debug \"!! create\"\n loan_params\n @loan = Loan.new(loan_params)\n # logger.debug loan_params\n\n respond_to do |format|\n if @loan.save\n format.html { redirect_to @loan, notice: 'Loan was successfully created.' }\n format.json { render action: 'show', status... | [
"0.5977559",
"0.5920859",
"0.5755291",
"0.57164973",
"0.5672483",
"0.56505686",
"0.5641568",
"0.56366247",
"0.5628906",
"0.55887496",
"0.558587",
"0.5548454",
"0.55474055",
"0.55223143",
"0.5512187",
"0.54946804",
"0.54828334",
"0.5480674",
"0.5478309",
"0.5473621",
"0.546966... | 0.53726566 | 33 |
PATCH/PUT /loans/1 or /loans/1.json | def update
respond_to do |format|
if @loan.update(loan_params)
format.html { redirect_to @loan, notice: "Loan was successfully updated." }
format.json { render :show, status: :ok, location: @loan }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @loan.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @loan.update(loan_params)\n format.html { redirect_to @loan, notice: 'Loan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @loan.errors, stat... | [
"0.62953156",
"0.61731374",
"0.61731374",
"0.61515015",
"0.60271806",
"0.60203665",
"0.59596896",
"0.5940036",
"0.5912754",
"0.5909885",
"0.5908483",
"0.59038484",
"0.59005266",
"0.58863145",
"0.5869889",
"0.5863923",
"0.5856189",
"0.58467406",
"0.5824833",
"0.58219373",
"0.5... | 0.6154034 | 3 |
DELETE /loans/1 or /loans/1.json | def destroy
@loan.destroy
respond_to do |format|
format.html { redirect_to loans_url, notice: "Loan was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @loan.destroy\n respond_to do |format|\n format.html { redirect_to loans_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @loan.destroy\n respond_to do |format|\n format.html { redirect_to loans_url, notice: 'Loan was successfully destroyed.' }\n ... | [
"0.7036163",
"0.67780507",
"0.67780507",
"0.67780507",
"0.6766855",
"0.66537154",
"0.6653622",
"0.6645782",
"0.6631344",
"0.6608415",
"0.65562505",
"0.65418816",
"0.6501577",
"0.64719397",
"0.64577454",
"0.6455477",
"0.6452458",
"0.6449015",
"0.6442445",
"0.6441725",
"0.64397... | 0.6769833 | 4 |
Use callbacks to share common setup or constraints between actions. | def set_loan
@loan = Loan.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def loan_params
params.require(:loan).permit(:book_id, :start_date, :end_date)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
==== Parameters: +options+:: Hash of options ==== Options: +access_key_id+:: access key id +secret_access_key+:: secret access key +use_ssl+:: optional, defaults to false +debug+:: optional, defaults to false +timeout+:: optional, for Net::HTTP | def initialize(options = {})
@access_key_id = options[:access_key_id]
@secret_access_key = options[:secret_access_key]
@use_ssl = options[:use_ssl] || false
@debug = options[:debug]
@timeout = options[:timeout]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(options)\n @access_key_id = options[:access_key_id] or raise ArgumentError, \"No access key id given\"\n @secret_access_key = options[:secret_access_key] or raise ArgumentError, \"No secret access key given\"\n @use_ssl = options[:use_ssl]\n @timeout = options[:timeout]\n @d... | [
"0.72505903",
"0.6038918",
"0.583578",
"0.57985514",
"0.5779334",
"0.5758519",
"0.5720048",
"0.5704394",
"0.5670463",
"0.564725",
"0.56459254",
"0.56380093",
"0.5605419",
"0.5554778",
"0.55327874",
"0.5530953",
"0.552661",
"0.5480762",
"0.54777825",
"0.54507196",
"0.54481685"... | 0.7309609 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_dimension
@dimension = Dimension.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def dimension_params
params.require(:dimension).permit(:name, :questionnaire_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
Returns a unique, deterministically reproducible index into an array We are hashing based on strings, let's use the ascii value of each string as a starting point. | def index(key, size)
key.sum % size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_unique(array)\n unique_id = 0\n\n array.each do |num|\n unique_id ^= num\n end\n\n unique_id\nend",
"def generateKey(string)\r\n key = {}\r\n stringIterator = 0\r\n\r\n (string.length).times do\r\n charactersIterator = string[stringIterator] - 1\r\n divisorsIterator = 0\r\n divisors =... | [
"0.63834584",
"0.62408745",
"0.6144398",
"0.60990644",
"0.60592127",
"0.6046242",
"0.6042425",
"0.60280126",
"0.5992942",
"0.5906817",
"0.5871855",
"0.5838909",
"0.58250093",
"0.5816861",
"0.57664907",
"0.57522625",
"0.5751663",
"0.57400036",
"0.5729892",
"0.57130796",
"0.570... | 0.0 | -1 |
Simple method to return the number of items in the hash | def size
@items.length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size\n return @hash.length\n end",
"def length\n hash.keys.length\n end",
"def size\n @hash.size\n end",
"def size\n @hash.size\n end",
"def size\n @hash.size\n end",
"def size\n @hash_array.length\n end",
"def size\n @hash_array.length\n end",
"def size\n ... | [
"0.82830465",
"0.82106954",
"0.8109915",
"0.8109915",
"0.8109915",
"0.79695594",
"0.79695594",
"0.78124315",
"0.77486163",
"0.76849425",
"0.7678069",
"0.7656559",
"0.7636084",
"0.76298493",
"0.761464",
"0.761464",
"0.7574793",
"0.7569945",
"0.7478816",
"0.7444118",
"0.7398974... | 0.0 | -1 |
Little kludge for getting badlyspecified keys | def delete_with_key(key)
real_key = @original_properties.keys.find { |k| k.to_s == key.to_s }
@original_properties.delete(real_key)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unmatched_keys; end",
"def missing_keys; end",
"def possible_keys(key); end",
"def hkeys(key); end",
"def hkeys(key); end",
"def keys(*) end",
"def stringified_keys; end",
"def key_coercions; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"d... | [
"0.75716215",
"0.7399028",
"0.7315766",
"0.710568",
"0.710568",
"0.70761955",
"0.70651656",
"0.6999975",
"0.69367516",
"0.69367516",
"0.69367516",
"0.69367516",
"0.69367516",
"0.69367516",
"0.69367516",
"0.69367516",
"0.69367516",
"0.686182",
"0.6825731",
"0.6755162",
"0.6734... | 0.0 | -1 |
Get the part of the the uri that can be used as a label | def label_for(uri)
if(uri =~ /xpointer/)
'An Xpointer'
else
uri_fragment(uri)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name()\n if bound?\n return bound_name\n end\n if label && label.match(/[a-zA-Z][a-zA-Z0-9_]*/) != nil\n return label\n end\n return uri.split(/(\\/|#)/).last\n end",
"def parsed_label_uri(value)\n value.split('$').first\n end",
"def local_part_uri\n sel... | [
"0.7736041",
"0.7680642",
"0.68481475",
"0.6714549",
"0.6619614",
"0.6619614",
"0.654376",
"0.63899124",
"0.6317598",
"0.6317598",
"0.62558824",
"0.62350285",
"0.6225079",
"0.61797917",
"0.61721426",
"0.6148535",
"0.61412793",
"0.6140119",
"0.6130022",
"0.6111617",
"0.6059530... | 0.670635 | 4 |
Indicates if the lookup has completed yet or not. | def completed?
return @complete
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def complete?\n @complete\n end",
"def complete?\n @complete\n end",
"def complete?\n completed_at && response\n end",
"def complete?\n true\n end",
"def complete?\n @gapi.job_complete\n end",
"def complete?\r\n @is_complete\r\n end"... | [
"0.7504753",
"0.750444",
"0.73906815",
"0.73713934",
"0.73474526",
"0.7307312",
"0.7298211",
"0.7214583",
"0.71979016",
"0.7174163",
"0.7168761",
"0.7125651",
"0.7124894",
"0.7118348",
"0.7082809",
"0.7053466",
"0.7035593",
"0.7035229",
"0.702824",
"0.702824",
"0.7014408",
... | 0.74687296 | 3 |
This method does the actual permalink escaping. | def escape(string)
result = ((translation_to && translation_from) ? Iconv.iconv(translation_to, translation_from, string) : string).to_s
result.gsub!(/[^\x00-\x7F]+/, '') # Remove anything non-ASCII entirely (e.g. diacritics).
result.gsub!(/[^\w_ \-]+/i, '') # Remove unwanted chars.
result.gsub!(/[ \-]+/i, '-') # No more than one of the separator in a row.
result.gsub!(/^\-|\-$/i, '') # Remove leading/trailing separator.
result.downcase!
result.size.zero? ? random_permalink(string) : result
rescue
random_permalink(string)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_permalink\n self.permalink = CGI.escape(self.name.gsub(' ', '_')) if self.name\n end",
"def escape_and_truncate_for_permalink(value)\n self.escape(value)[0...self.permalink_options[:param_size]]\n end",
"def escape_sitemap_url(url)\n CGI::escape(url)\n end",
"def cr... | [
"0.70940995",
"0.6773647",
"0.6441132",
"0.6398594",
"0.6386641",
"0.6367014",
"0.6326879",
"0.6289178",
"0.62712276",
"0.62712276",
"0.6237689",
"0.6231297",
"0.6218325",
"0.61943936",
"0.618468",
"0.604984",
"0.6023654",
"0.59924155",
"0.5983261",
"0.5961688",
"0.595736",
... | 0.60101897 | 17 |
Create a new Redirect instance if the fields have been changed | def create_redirect_if_permalink_fields_changed
former = send(self.class.permalink_field)
current = PermalinkFu.escape(create_permalink_for(self.class.permalink_attributes))
attributes = {:model => self.class.name, :former_permalink => former, :current_permalink => current}
if !former.nil? && former != current
# If the model attributes are being rolled back to some older value, delete the old redirect
self.class.redirect_model.delete_all :model => self.class.name, :former_permalink => current
self.class.redirect_model.update_all ['current_permalink = ?', current], :current_permalink => former
self.class.redirect_model.create(attributes)
end
return former != current
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_redirect_action\n if params[:redirect_from].strip.size == 0\n flash[:error] = \"Original URL cannot be empty\"\n return redirect_to \"/admin\"\n end\n if params[:redirect_to].strip.size == 0\n flash[:error] = \"New URL cannot be empty\"\n return redirect_to \"/admin\"\n e... | [
"0.6520001",
"0.6351845",
"0.6325829",
"0.6309564",
"0.62364286",
"0.6219673",
"0.6083324",
"0.5975588",
"0.5966061",
"0.59267414",
"0.57616824",
"0.5713381",
"0.5653719",
"0.562784",
"0.5589663",
"0.55734503",
"0.5546721",
"0.54753965",
"0.54564196",
"0.54424274",
"0.5435866... | 0.7034233 | 0 |
Configure Girlfriend to suit your needs Girlfriend.configure do |config| config.name = 'Ruby' end Configurables: [name = String] Girlfriend's name [age = Integer]Girlfriend's age [hometown = String] Girlfriend's hometown [school = String] Girlfriend's school [hobbies = Array]Girlfriend's hobbies [reply = String]Girlfriend's default reply text | def configure
yield self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure\n # Users to block instead of interacting with\n self.blacklist = ['mcamargo1997']\n\n # Range in seconds to randomize delay when bot.delay is called\n self.delay_range = 1..6\n\n @userinfo = {}\n @botinfo = {\n ENV[\"BOT_NAME_1\"] => BotInfo.new(ENV[\"BOT_NAME_1\"]),\n EN... | [
"0.6597587",
"0.62525284",
"0.6174202",
"0.60638344",
"0.5969972",
"0.595579",
"0.5915428",
"0.5845206",
"0.5796624",
"0.5772162",
"0.57536775",
"0.57479936",
"0.5696726",
"0.56653917",
"0.5648837",
"0.5621836",
"0.56044626",
"0.5585927",
"0.5585927",
"0.5585927",
"0.5585927"... | 0.0 | -1 |
Returns an empty or existing array of abilities | def abilities
@abilities ||= {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def abilities_to_register\n []\n end",
"def abilities_to_register\n []\n end",
"def abilities\n (read_attribute(:abilities) || '').split(' ')\n end",
"def abilities\n @abilities ||= Six.new\n end",
"def abilities\n get('/ability/')\n end",
"def activated_abilities\n act... | [
"0.754501",
"0.7383248",
"0.7233026",
"0.71824116",
"0.6516052",
"0.6487794",
"0.6312706",
"0.6312706",
"0.6077586",
"0.59423876",
"0.593129",
"0.59195054",
"0.5914095",
"0.5863681",
"0.58461815",
"0.5838893",
"0.57735115",
"0.57509035",
"0.5732901",
"0.5720581",
"0.5701555",... | 0.7582291 | 0 |
Registers a new Girlfriend ability Girlfriend.register_ability :talk do |girl| Girlfriend::Ability::Talk.new(girl) end | def register_ability(name, &block)
abilities[name] = block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize ability\n @ability = ability\n end",
"def add_ability(func_name, timeout=nil, &block)\n @abilities[func_name] = Ability.new(func_name, block, timeout)\n @connection_pool.with_all_connections do |connection|\n announce_ability(func_name, timeout, connection)\n end\n ... | [
"0.5804026",
"0.573823",
"0.57246786",
"0.5690421",
"0.5690421",
"0.5690421",
"0.5690421",
"0.5690421",
"0.56817305",
"0.56157243",
"0.56028426",
"0.5547905",
"0.5520074",
"0.54803413",
"0.5477103",
"0.5406545",
"0.534792",
"0.530494",
"0.52957565",
"0.52653575",
"0.52394325"... | 0.64486384 | 0 |
Returns TRUE if the given ability exists, otherwise FALSE | def can?(name)
abilities.include? name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ability?\n self.__ability.present?\n end",
"def has_achievement?(name)\n achievements.exists?(name: name)\n end",
"def exist?\n @access.exist?\n end",
"def exist?\n @access.exist?\n end",
"def _has_capability?(capability)\n allow = nil\n deny = nil\n\n roles.each do... | [
"0.79016674",
"0.67917013",
"0.6772654",
"0.6772654",
"0.65737516",
"0.6456097",
"0.6439611",
"0.6417155",
"0.6400718",
"0.6366617",
"0.63634366",
"0.6350886",
"0.6326208",
"0.6317813",
"0.62612975",
"0.62588996",
"0.62570196",
"0.6228",
"0.6219924",
"0.62103456",
"0.61864394... | 0.74174196 | 1 |
Interact with Girlfriend name name of an ability input text input (default: '') if name is :interactive then it enters interactive mode, otherwise executes and returns immediately Returns the result of the interaction. | def interact?(name, input='')
if name == :interactive
interactive(input)
else
if can? name
ability = abilities[name].call(self)
ability.try? name, input
else
reply
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_user_name\n puts \"Please enter your name: \"\n name = gets.chomp\n end",
"def interactive(input)\n\t\t\tputs 'Say hi to ' + name + ' now or type `leave` to stop talking to her!'\n\n\t\t\twhile true\n\t\t\t\tprint 'Dude > '\n\t\t\t\tinput = gets.chomp\n\t\t\n\t\t\t\tif input == 'leave'\n\t\t\t... | [
"0.62065065",
"0.619596",
"0.60996425",
"0.6053882",
"0.6030305",
"0.6001681",
"0.59616333",
"0.5952143",
"0.5950341",
"0.5864927",
"0.58646375",
"0.5850955",
"0.5843785",
"0.58253497",
"0.57997364",
"0.5794855",
"0.5770388",
"0.5741676",
"0.5725465",
"0.5716886",
"0.5714298"... | 0.7485019 | 0 |
Internal helper for interactive mode input text input | def interactive(input)
puts 'Say hi to ' + name + ' now or type `leave` to stop talking to her!'
while true
print 'Dude > '
input = gets.chomp
if input == 'leave'
break
else
puts name + ' > ' + interact?(:talk, input)
end
end
name + ' > Bye dude ...'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text_input; end",
"def set_text_input(input); end",
"def interactive_mode\n\t\tparse_user_input while recv_user_input\n\tend",
"def text(text_input_handle)\n end",
"def new_text_input\n end",
"def set_current_text_input(text_input_handle)\n end",
"def prepare_input(prompt); end",
"def ask_inpu... | [
"0.76246625",
"0.74624574",
"0.7382206",
"0.6982409",
"0.6885963",
"0.6794125",
"0.66711104",
"0.65774745",
"0.65194875",
"0.63821846",
"0.6378466",
"0.636011",
"0.63496083",
"0.63191146",
"0.631329",
"0.6285517",
"0.6285517",
"0.6268257",
"0.626699",
"0.622998",
"0.6228624",... | 0.5919666 | 70 |
def feature_injection(array, &b) list = [:_] yield &b end FEATURE TERMS | def feature_set(*args, &b)
describe(*args, &b)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feature(name, &block); begin; yield; features << name; rescue Exception; end; end",
"def use(*features); end",
"def append_features(mod) end",
"def [](*arg)\n @features[*arg]\n end",
"def list_features *args\r\n puts \"not implemented yet\"\r\n end",
"def each_feature\n self.each do |eleme... | [
"0.6573996",
"0.63501793",
"0.6236588",
"0.58633983",
"0.5725453",
"0.5616294",
"0.55136245",
"0.54750067",
"0.5455767",
"0.5388028",
"0.5383501",
"0.5331738",
"0.5329942",
"0.53293324",
"0.5319823",
"0.52926487",
"0.52900153",
"0.5285923",
"0.5285923",
"0.5276875",
"0.527526... | 0.57449955 | 4 |
AGILE TERMS def epic(args, &b) describe(args, &b) end def story(args, &b) describe(args, &b) end WWW | def feature_www(s, options={}, &b)
s = ["Feature:", s, www(options)]
feature(s, &b)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def help\n\tusage\n\tputs \"This tool is oriented to separate web pages into segments called blocks, based on the structural and visual properties\"\nend",
"def learn_it\n interviews = \"https://www.youtube.com/playlist?list=PLUJNJAesbJGVGDiZJ8WvcEC3e1O5cDb5r\"\n puts \"If you want to learn from the IT pros, c... | [
"0.65469486",
"0.6292197",
"0.62427884",
"0.60935664",
"0.60935664",
"0.60935664",
"0.6010507",
"0.5994045",
"0.596182",
"0.5891901",
"0.589163",
"0.5884729",
"0.5884729",
"0.5859082",
"0.5859082",
"0.58347964",
"0.5829574",
"0.5829574",
"0.5829574",
"0.5829574",
"0.5829574",... | 0.0 | -1 |
Takes in lat and long coord of user and radius defaults to ipaddress location and 0.5 | def index # returns all bikes within a certain radius
## TODO: use coordinates later, when more campuses and bikes.
# # defaults radius to half mile, and coordinate to requesting ip address
# radius = params[:radius] ? params[:radius] : 0.5
# coordinates = params[:coordinates] ? params[:coordinates] : request.location
# puts coordinates
# @bikes = Coordinate.near(coordinates, radius).joins(:bikes)
@bikes = Bike.available
render json: @bikes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_radius\n exact_location ? 100 : 50_000\n end",
"def radius\n end",
"def withinRadius(latitude,longitiude,radius)\n \n rad = 3963.1676\n lat1 = to_rad(latitude.to_f)\n lat2 = to_rad(self.latitude.to_f)\n lon1 = to_rad(longitiude.to_f)\n l... | [
"0.6757389",
"0.6453448",
"0.6337139",
"0.632312",
"0.63168544",
"0.6278281",
"0.6186694",
"0.6147105",
"0.60826516",
"0.60636944",
"0.6050005",
"0.6031478",
"0.60247606",
"0.60247606",
"0.59974486",
"0.5990237",
"0.5941987",
"0.59351134",
"0.58927363",
"0.5878909",
"0.587815... | 0.0 | -1 |
POST /api/bikes/reserve/:id Dont let a user reserve a bike unless they have a payment method added and are in good standing Expected params: XApiKey: api_key | def reserve # Start Ride
return render json: { error: "This bike is not available to reserve" }, status: :forbidden unless @bike.available?
begin
ActiveRecord::Base.transaction do
@bike.current_ride = Ride.build_from_user_bike(@user, @bike)
@bike.reserved!
case params[:payment_type]
when "subscription"
render json: { error: "Subscription has not been implemented yet" }, status: :bad_request
raise ActiveRecord::Rollback
when "prepay"
@user.validates_payment_and_good_standing
@bike.current_ride.trans = Transaction.charge_user_for_ride(@user, @bike.current_ride, "prepay")
else # :per_minute
# put pay_per_minute logic here
end
@bike.save!
print "Reserved Bike #{@bike.id} - scheduling bike-reserved-email"
puts Time.now
minutes = 5
delay = "#{minutes}m"
Rufus::Scheduler.singleton.in delay do
if (Ride.find(@bike.current_ride.id).progress?)
ApplicationMailer.bikes_been_reserved_for(minutes, @user, @bike.id).deliver_now
print "Sent email "
puts Time.now
end
end
end
rescue User::PaymentMethodException, User::BraintreeException => e
render json: { error: e.message },
status: :payment_required,
location: api_new_payment_path
rescue User::NotInGoodStandingException => e
render json: { error: e.message },
status: :forbidden,
location: api_collections_path
rescue ActiveRecord::RecordInvalid => e
render :json => { :error => e.message },
status: :unprocessable_entity
rescue Transaction::Rejected => e
render :json => { :error => e.message },
status: :bad_request
else
render json: {bike: @bike.to_json({methods: :code}), transction: @bike.current_ride.trans}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bike_params\n params.require(:bike).permit(:bike_index_uid, :user_id)\n end",
"def set_bike\n @bike = Bike.find(params[:id])\n authorize @bike\n end",
"def bike_params\n params.require(:bike).permit(:bikeid, :serialnumber, :rating, :condition, :maintenance, :style, :size, :color, ... | [
"0.6272552",
"0.61437535",
"0.61261225",
"0.6092075",
"0.5988227",
"0.5956369",
"0.5892189",
"0.5867415",
"0.5867415",
"0.5867415",
"0.5823128",
"0.58165795",
"0.57885647",
"0.57801604",
"0.5774022",
"0.575455",
"0.57489383",
"0.57458764",
"0.57410276",
"0.57336164",
"0.57207... | 0.62075686 | 1 |
POST /api/bikes/return/:id Expected params: XApiKey: api_key latitude: lat longitude: long payment_method_nonce: braintree token | def return # End Ride
params.require(:latitude)
params.require(:longitude)
@ride = @bike.current_ride
return render json: { error: 'Could not find the current ride associated with this bike' }, status: :not_found if @ride.nil?
return render json: { error: 'Cannot return a bike that is not reserved' }, status: :forbidden unless (@bike.reserved?)
return render json: { error: 'You are not the current owner of this bike' }, status: :forbidden if (@user != @ride.user)
# TODO: get name for this location by nearest Coordinate with name...
@location = Coordinate.find_or_initialize_by(latitude: params[:latitude], longitude: params[:longitude])
render :json => { :error => @location.errors.full_messages } unless @location.save
@ride.stop_location = @location
@ride.stop_time = DateTime.now
@ride.status = Ride.statuses[:complete]
return render :json => { :error => @ride.errors.full_messages } unless @ride.save
# CHARGE FOR RIDE
begin
# TODO: Finish this
# @transaction = Transaction.charge_user_for_ride(@user, @ride)
# @transaction.save!
# put specific rescues here
rescue Exception => e
return render json: { error: e }, status: :internal_server_error
# TODO: What happens if transaction fails
# @user.status === User::STATUS[:outstanding]
ensure
@bike.location = @location
@bike.current_ride = nil
@bike.status = Bike.statuses[:available]
return render json: { error: @bike.errors.full_messages } unless @bike.save
end
# TODO: make this @ride.summary
render :json => @ride.to_json if @ride.save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_doge_token_dropin\r\n if current_user then\r\n tokens = params[:num_tokens]\r\n # CREATE TEST TRANSACTION TODO Make it work\r\n # Handle Taxes for Taxcloud\r\n customer = @current_user\r\n # TODO Change this to retrieved destination\r\n test_destination = TaxCloud::Address... | [
"0.5836549",
"0.57249355",
"0.564266",
"0.5571774",
"0.55488956",
"0.54904217",
"0.5476726",
"0.5394052",
"0.534504",
"0.5344305",
"0.5341261",
"0.5325098",
"0.5282314",
"0.52753234",
"0.52706754",
"0.5238265",
"0.5228178",
"0.52144134",
"0.52126336",
"0.51975065",
"0.518727"... | 0.54679114 | 7 |
return view page create a slide | def create
@mode = 'I'
render 'admin/slides/slide'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @page_slide = Slide.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page_slide }\n end\n end",
"def show\n @slides =@lecture.slides(params[:urlpage])\n \n end",
"def show\n @contents = @slide.contents\n end",
"def show\n se... | [
"0.69299203",
"0.6904884",
"0.6800734",
"0.67499614",
"0.6744819",
"0.667199",
"0.6669424",
"0.66220504",
"0.66192925",
"0.6611391",
"0.6611391",
"0.66070235",
"0.65402",
"0.65184635",
"0.6500471",
"0.6487202",
"0.6487202",
"0.6487202",
"0.64664435",
"0.64406675",
"0.64167476... | 0.75595266 | 0 |
return view page edit a slide | def edit
@data = SlidesHlp.getSlide(params[:id])
if @data['slide_vi'] == nil
@mode = 'I'
else
@slide = @data['slide_vi']
@slide_ja = @data['slide_ja']
@lang = @data['lang']
@mode = 'U'
end
render 'admin/slides/slide'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_slide\n @slide = @presentation.slides.friendly.find(params[:id]) \n end",
"def set_slide\n @slide = Slide.nondraft.find(params[:id])\n end",
"def set_slide\n @slide = Slide.find(params[:id])\n end",
"def create\n @mode = 'I'\n render 'admin/slides/slide'... | [
"0.72954106",
"0.7116887",
"0.71042323",
"0.7039532",
"0.69894713",
"0.6987289",
"0.6987289",
"0.6987289",
"0.6987289",
"0.6987289",
"0.69081426",
"0.68734515",
"0.6873193",
"0.68410283",
"0.6732529",
"0.6664729",
"0.66635966",
"0.65734047",
"0.6557006",
"0.6555633",
"0.65448... | 0.77079725 | 0 |
get data translate of slide | def referSlide
result = Hash.new
result['status'] = true
begin # try
result['data'] = Slide.find_by( id: params[:id], lang: params[:lang], deleted_at: nil)
rescue # catch
result['status'] = false
result['error'] = "#{$!}"
ensure # finally
render json: result
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return_slide_and_data\n target_sentence = nil\n loop do\n target_word = @enrolment_manager.next_word\n return { service: 'EMPTY' } if target_word.nil?\n target_sentence = @next_sentence_retriever.retrieve(target_word)\n break if target_sentence.present?\n @enrolment... | [
"0.56755507",
"0.55818",
"0.55818",
"0.55785453",
"0.5513553",
"0.54947346",
"0.5453491",
"0.53896767",
"0.53681326",
"0.52934486",
"0.5283824",
"0.5269602",
"0.52453387",
"0.5234027",
"0.52149826",
"0.52055985",
"0.5189202",
"0.5189202",
"0.5189202",
"0.5189202",
"0.5189202"... | 0.4973316 | 37 |
add or update a slide | def saveSlide
if params[:mode] == 'I'
update = SlidesHlp.saveSlide(params[:slide])
else
update = SlidesHlp.updateSlide(params[:slide])
end
render json: update
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_slide\n @slide = Slide.find(params[:id])\n end",
"def set_slide\n @slide = Slide.find(params[:id])\n end",
"def set_slide\n @slide = Slide.find(params[:id])\n end",
"def set_slide\n @slide = Slide.find(params[:id])\n end",
"def set_slide\n @slide = Slide.find(params... | [
"0.70799494",
"0.7076021",
"0.7076021",
"0.7076021",
"0.7076021",
"0.7076021",
"0.7000752",
"0.6988983",
"0.69607586",
"0.6899706",
"0.67030966",
"0.6678957",
"0.6637103",
"0.6569969",
"0.6502856",
"0.6471711",
"0.6443339",
"0.64378774",
"0.6412726",
"0.6355204",
"0.63209397"... | 0.6647529 | 12 |
update data translate of slide | def updateSlideTrans
result = Hash.new
result['status'] = true
begin # try
if !SlidesHlp.updateSlideTrans(params[:slide])
result['status'] = false
end
rescue # catch
result['status'] = false
result['error'] = "#{$!}"
ensure # finally
render json: result
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def migrate(data)\n keys = I18n::Translate.hash_to_keys(data, @translate.options[:separator])\n keys.each do |key|\n entry = I18n::Translate.find(key, data, @translate.options[:separator])\n next unless I18n::Translate.is_enhanced?(entry)\n %w(old t).each do |prop|\n ... | [
"0.600775",
"0.6000597",
"0.58729243",
"0.5831652",
"0.5821957",
"0.57016015",
"0.569445",
"0.5568196",
"0.5447744",
"0.5447744",
"0.54306793",
"0.5430647",
"0.5430561",
"0.54159015",
"0.5387675",
"0.53738725",
"0.536614",
"0.53024817",
"0.52914494",
"0.5286722",
"0.5283436",... | 0.60674554 | 0 |
update show status of slide | def updateShowSlide
result = Hash.new
result['status'] = true
begin # try
result['status'] = Slide.where(id: params[:id])
.update_all('slides.show = NOT slides.show, updated_by = ' + $user_id.to_s + ', updated_at = \'' + Time.now.to_formatted_s(:db) + '\'')
rescue # catch
result['status'] = false
result['error'] = "#{$!}"
ensure # finally
render json: result
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show; @showing = false; end",
"def show_slide\n @slide = @slideshow.slides[session[:slide_index]]\n session[:slide_index] += 1\n if @slide.nil?\n session[:slide_index] = 0\n @slide = @slideshow.slides[0]\n end\n render partial: \"show_slides\"\n end",
"def show_slide\n @slidesh... | [
"0.6542944",
"0.64448625",
"0.6404435",
"0.6346779",
"0.62538993",
"0.60797113",
"0.60591894",
"0.60416937",
"0.59968007",
"0.59854925",
"0.5942338",
"0.5942338",
"0.59081703",
"0.5873936",
"0.5863659",
"0.58616453",
"0.5834114",
"0.5834114",
"0.5834114",
"0.5834114",
"0.5834... | 0.7222382 | 0 |
TODO: this method is too long split it up by refactoring | def run(options, argv)
pooled_reads_filename = 'pooled_sampled_reads.fasta' #TODO: remove this constant into a tempfile or something.
if options[:already_patterned_reads] #If skipping read extraction
pooled_reads_filename = options[:already_patterned_reads]
else
# Parse pattern from cmdline
desired_pattern = KmerAbundancePattern.new
desired_pattern.parse_from_human(options[:pattern])
if options[:reads_files].length != desired_pattern.length
raise "Number of entries in the pattern #{desired_pattern.length} and number of reads files #{options[:reads].length} not equivalent!"
end
# Collect the kmers that will be used to find trusted reads i.e.
# Go through each line of the kmer abundance file, looking for kmers that suit the pattern
input_file = File.open options[:kmer_multiple_abundance_file]
csv = CSV.new(input_file, :col_sep => ' ')
whitelist_kmers = []
blacklist_kmers = []
csv.each do |row|
max_i = row.length - 2 if max_i.nil?
kmer = row[0]
counts = row[1...row.length].collect{|s| s.to_i}
this_pattern = []
counts.each_with_index do |count, i|
if count > options[:upper_threshold]
this_pattern[i] = true
elsif count < options[:lower_threshold]
this_pattern[i] = false
else
# coverage was in no man's land between thresholds.
# Ignore this kmer as noise.
this_pattern[i] = '-'
end
end
#log.debug "Found pattern #{this_pattern} from kmer #{kmer}, which has abundances #{counts}" if log.debug?
if desired_pattern.consistent_with? this_pattern
whitelist_kmers.push row[0]
else
# kmer is not present when it should be
blacklist_kmers.push row[0]
end
end
log.info "After parsing the kmer multiple abundance file, found #{whitelist_kmers.length} kmers that matched the pattern, and #{blacklist_kmers.length} that didn't"
unless whitelist_kmers.length > 0
log.error "No kmers found that satisfy the given pattern, exiting.."
exit 1
end
#outdir = options[:output_directory]
#Dir.mkdir outdir unless Dir.exist?(outdir)
# grep the pattern out from the raw reads, subsampling so as to not overwhelm the assembler
#Tempfile.open('whitelist') do |white|
File.open 'whitelist', 'w' do |white| #TODO: remove 'whitelist' file as a constant
white.puts whitelist_kmers.join("\n")
white.close
#Tempfile.open('blacklist') do |black|
File.open('black','w') do |black|
black.puts blacklist_kmers.join("\n")
black.close
threadpool = []
sampled_read_files = []
log.info "Extracting reads that contain suitable kmers"
options[:reads_files].each_with_index do |file, i|
next unless desired_pattern[i] #Don't extract reads from reads where those reads should not have been amplified
sampled = File.basename(file)+'.sampled_reads.fasta'
sampled_read_files.push sampled
grep_path = "#{ ENV['HOME'] }/git/priner/bin/read_selection_by_kmer " #TODO: this won't work on other people's systems.
if options[:min_leftover_length]
grep_path += "--min-leftover-length #{options[:min_leftover_length]} "
end
thr = Thread.new do
grep_cmd = "#{grep_path} --whitelist #{white.path} --blacklist #{black.path} --reads #{file} --kmer-coverage-target #{options[:kmer_coverage_target]} > #{sampled}"
log.debug "Running cmd: #{grep_cmd}"
status, stdout, stderr = systemu grep_cmd
log.debug stderr
raise unless status.exitstatus == 0
log.debug "Finished extracting reads from #{file}"
end
threadpool.push thr
end
threadpool.each do |thread| thread.join; end #wait until everything is finito
log.info "Finished extracting reads for sampling. Now pooling sampled reads"
pool_cmd = "cat #{sampled_read_files.join ' '} >#{pooled_reads_filename}"
log.debug "Running cmd: #{pool_cmd}"
status, stdout, stderr = systemu pool_cmd
raise stderr if stderr != ''
raise unless status.exitstatus == 0
end
end
end
log.info "Extracting dummy reads from the ends of contigs to use as anchors"
start_contig = options[:start_contig]
end_contig = options[:end_contig]
if [start_contig.length, end_contig.length].min < 2*options[:contig_end_length]
log.warn "Choice of initial/terminal nodes to perform graph search with may not be optimal due to the small contig size"
end
if [start_contig.length, end_contig.length].min < options[:contig_end_length]
log.error "At least one contig too small to proceed with current code base, need to fix the code to allow such a small contig"
exit 1
end
probe_sequences = [
start_contig[start_contig.length-options[:contig_end_length]...start_contig.length],
Bio::Sequence::NA.new(end_contig[0...options[:contig_end_length]]).reverse_complement.to_s
]
read_input = Bio::FinishM::ReadInput.new
read_input.fasta_singles = [pooled_reads_filename]
finishm_graph = Bio::FinishM::GraphGenerator.new.generate_graph(probe_sequences, read_input, options)
graph = finishm_graph.graph
start_node = finishm_graph.probe_nodes[0]
start_node_forward = finishm_graph.probe_node_directions[0]
end_node = finishm_graph.probe_nodes[1]
end_node_forward = finishm_graph.probe_node_directions[1]
log.info "Node(s) found that are suitable as initial and terminal nodes in the graph search, respectively: #{start_node.node_id} and #{end_node.node_id}"
log.info "Removing nodes unconnected to either the start or the end from the graph.."
original_num_nodes = graph.nodes.length
original_num_arcs = graph.arcs.length
filter = Bio::AssemblyGraphAlgorithms::ConnectivityBasedGraphFilter.new
filter.remove_unconnected_nodes(graph, [start_node, end_node])
log.info "Removed #{original_num_nodes-graph.nodes.length} nodes and #{original_num_arcs-graph.arcs.length} arcs"
if options[:output_graph_png] or options[:output_graph_svg] or options[:output_graph_dot]
viser = Bio::Assembly::ABVisualiser.new
log.info "Preparing GraphViz object for output"
gv = viser.graphviz(graph, {:start_node_id => start_node.node_id, :end_node_id => end_node.node_id})
if options[:output_graph_png]
log.info "Converting assembly to a graphviz PNG #{options[:output_graph_png] }"
gv.output :png => options[:output_graph_png], :use => :neato
end
if options[:output_graph_svg]
log.info "Converting assembly to a graphviz SVG #{options[:output_graph_svg] }"
gv.output :svg => options[:output_graph_svg], :use => :neato
end
if options[:output_graph_dot]
log.info "Converting assembly to a graphviz DOT #{options[:output_graph_dot] }"
gv.output :dot => options[:output_graph_dot]
end
end
log.info "Searching for trails between the initial and terminal nodes, within the assembly graph"
cartographer = Bio::AssemblyGraphAlgorithms::AcyclicConnectionFinder.new
#raise "Untested connection finder below"
#trails = cartographer.find_all_trails_between_nodes(graph, start_node, end_node, options[:graph_search_leash_length], start_node_forward)
trails = cartographer.find_trails_between_nodes(graph, start_node, end_node, options[:graph_search_leash_length], start_node_forward)
log.info "Found #{trails.length} trail(s) between the initial and terminal nodes"
# log.info "Reading kmer abundances from #{options[:kmer_multiple_abundance_file]}.."
# kmer_hash = Bio::KmerMultipleAbundanceHash.parse_from_file options[:kmer_multiple_abundance_file]
# log.info "Finished reading the kmer abundances"
# if options[:trail_kmer_coverage_file]
# log.info "Writing out kmer coverages to #{options[:trail_kmer_coverage_file]}.."
# writer = Bio::AssemblyGraphAlgorithms::KmerCoverageWriter.new
# io = File.open(options[:trail_kmer_coverage_file],'w')
# writer.write(io, trails, kmer_hash)
# log.info "Finished writing"
# end
# log.info "Filtering trail(s) based on kmer coverage, requiring each kmer in the path to have a minimum of #{options[:kmer_path_filter_min_coverage]} coverage in patterned reads, except for the #{options[:kmer_path_end_exclusion_length]}bp at the ends"
# kmer_path_filter = Bio::AssemblyGraphAlgorithms::KmerCoverageBasedPathFilter.new
# thresholds = desired_pattern.collect{|c| c == true ? 1 : 0}
# log.info "Using thresholds for filtering: #{thresholds}"
# trails = kmer_path_filter.filter(trails, kmer_hash, thresholds, :exclude_ending_length => options[:kmer_path_end_exclusion_length])
# log.info "After filtering remained #{trails.length} trails"
printer = Bio::AssemblyGraphAlgorithms::ContigPrinter.new
trails.each_with_index do |trail, i|
log.debug "Before attachment to the contig, sequence of the trail was #{trail.sequence}" if log.debug?
acon = Bio::AssemblyGraphAlgorithms::ContigPrinter::AnchoredConnection.new
acon.start_probe_read_id = 1
acon.end_probe_read_id = 2
acon.start_probe_node = start_node
acon.end_probe_node = end_node
acon.start_probe_contig_offset = options[:contig_end_length]
acon.end_probe_contig_offset = options[:contig_end_length]
acon.paths = [trail]
log.debug "AnchoredConnection object to print for this trail: #{acon.inspect}" if log.debug?
puts ">trail#{i+1}"
puts printer.one_connection_between_two_contigs(
finishm_graph.graph,
probe_sequences[0],
acon,
probe_sequences[1])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def offences_by; end",
"def formation; end",
"def identify; end",
"def anchored; end",
"def terpene; end",
"def suivre; end",
"def berlioz; end",
"def... | [
"0.67651063",
"0.5921294",
"0.5678794",
"0.56768227",
"0.56768227",
"0.56768227",
"0.56768227",
"0.55266863",
"0.5503148",
"0.5407889",
"0.5389143",
"0.53412527",
"0.5271127",
"0.52139384",
"0.5182962",
"0.51418954",
"0.5125917",
"0.5125917",
"0.5125917",
"0.51191753",
"0.511... | 0.0 | -1 |
+nil+ is blank: nil.blank? => true | def blank?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blank?\n @value == nil\n end",
"def blank?\r\n nil? || (respond_to?(:empty?) && empty?)\r\n end",
"def blank?\n nil? || (respond_to?(:empty?) && empty?)\n end",
"def blank?\n nil? || (respond_to?(:empty?) && empty?)\n end",
"def blank?\n nil? || (respond_to?(:empty?) && empty?)\n... | [
"0.8476583",
"0.8458991",
"0.83773017",
"0.8376911",
"0.8376911",
"0.83311534",
"0.83047694",
"0.8300094",
"0.82690495",
"0.8189922",
"0.81458604",
"0.81458604",
"0.81374216",
"0.80880964",
"0.8047782",
"0.80329067",
"0.8026663",
"0.80087924",
"0.7996571",
"0.7996571",
"0.799... | 0.8129024 | 13 |
Recursively call to_a on all connected Nodes and return an Array with their data. Time Complexity: O(n) Space Complexity: O(n) | def to_a
if next_node
[data].concat(next_node.to_a)
else
[data]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_a\n ret = [self]\n if self.kids\n self.kids.each do |kid|\n kid.to_a.each {|node|\n ret.push node\n }\n end\n end\n ret\n end",
"def to_a\n result = []\n fill_result = proc { |node_data| result << node_data }\n in_order_run_callable(@root, fill_result... | [
"0.7012965",
"0.6966498",
"0.68051904",
"0.6770991",
"0.6724855",
"0.65954775",
"0.6266293",
"0.62211686",
"0.6193075",
"0.6148097",
"0.6112715",
"0.60460734",
"0.602377",
"0.5986071",
"0.5983784",
"0.5983784",
"0.5901126",
"0.5877439",
"0.5841594",
"0.58410764",
"0.5788534",... | 0.66655356 | 5 |
Initialize CWLSLas object passing las file as argument Example: >> my_well = CWLSLas.new('my_well.las') => Arguments: las_file_name: (String) file_options: (Hash) options: encoding | def initialize(filename=nil, file_options={})
load_file(filename, file_options) if not filename.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(file_or_path, options = {})\n data = file_or_path.read if file_or_path.respond_to?(:read)\n data ||= File.read file_or_path\n\n @keystore = options[:keystore]\n\n init(data)\n end",
"def initialize(options)\n options.each { |k, v| self.send :\"#{k}=\", v }\n self.file ... | [
"0.61706287",
"0.6159244",
"0.6005976",
"0.59396875",
"0.588578",
"0.588578",
"0.5879552",
"0.5879552",
"0.5879552",
"0.5865736",
"0.5858681",
"0.58512884",
"0.58512884",
"0.58512884",
"0.5815233",
"0.58008766",
"0.5799979",
"0.576145",
"0.576145",
"0.576145",
"0.57358986",
... | 0.6415842 | 0 |
Return a list of mnemonics representing the curve names Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.curve_names => ["ILD", "ILM", "DT", "NPHI", "RHOB", "SFLA", "SFLU", "DEPT"] | def curve_names
self.curves.keys
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def names\n @mplab_pin.names\n end",
"def standarized_coeffs\n assign_names(@coeffs_stan)\n end",
"def curve(curve_name)\n self.curves[curve_name]\n end",
"def names; end",
"def names; end",
"def names; end",
"def names; end",
"def names; end",
"def names; end",
"def names; end",
... | [
"0.55047166",
"0.5396108",
"0.5383436",
"0.53287905",
"0.53287905",
"0.53287905",
"0.53287905",
"0.53287905",
"0.53287905",
"0.53287905",
"0.5303541",
"0.52750933",
"0.5259933",
"0.52515334",
"0.52482504",
"0.52275157",
"0.5216438",
"0.5197078",
"0.51948726",
"0.51739776",
"0... | 0.7154525 | 0 |
Returns an object representing the curve selected Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.curve('ILD') | def curve(curve_name)
self.curves[curve_name]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def curve\n end",
"def curve\n end",
"def add_curve(*args)\n end",
"def curve(base)\n if base.respond_to?(:to_curve) && base.length == Fever::FRAMES\n return base.to_curve\n end\n\n case base\n when Numeric then curve_from_numeric(base)\n when Enumerable then curve_from_enum(base)\n ... | [
"0.66901845",
"0.66901845",
"0.6249164",
"0.61700153",
"0.6108652",
"0.61054754",
"0.6104347",
"0.59153837",
"0.59153837",
"0.58253616",
"0.5818646",
"0.5791126",
"0.56843776",
"0.5656987",
"0.5641351",
"0.56204563",
"0.55703455",
"0.55378777",
"0.5532485",
"0.5500147",
"0.54... | 0.7155257 | 0 |
Return a list of mnemonics representing the curve names Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.well_name => "ANY ET AL OIL WELL 12" | def well_name
self.well_info.well_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def names\n @mplab_pin.names\n end",
"def name_significance #adding an instance method\n parts = self.split( '-' )\n syllables = @@syllables.dup\n signif = parts.collect do |p|\n syllables.shift[p]\n end\n signif.join( ' ' )\n end",
"def lifter_names_gym\n lifters_gy... | [
"0.57651305",
"0.57417816",
"0.5643479",
"0.55920374",
"0.5547858",
"0.54366666",
"0.5364352",
"0.53182197",
"0.5275155",
"0.526395",
"0.52516013",
"0.52482516",
"0.52316934",
"0.52212983",
"0.5219748",
"0.52005124",
"0.5198502",
"0.5164443",
"0.5157257",
"0.511221",
"0.51060... | 0.5453332 | 5 |
Returns the company name tha owns the well Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.company_name => "ANY OIL COMPANY LTD." | def company_name
self.well_info.company_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def company_name\t\t\t# Getter method - return nil if name is not found\n\t\tcompany.try(:name)\n\tend",
"def company_name\n @company_name\n end",
"def company_name\n object.company.name\n end",
"def company_name\n @company_name\n end",
"def name\n latest_ccla_signature.company\n end"... | [
"0.7688148",
"0.7644459",
"0.7523862",
"0.74599236",
"0.73722374",
"0.733742",
"0.7231664",
"0.71790296",
"0.7172417",
"0.71318823",
"0.7102993",
"0.7085619",
"0.6997876",
"0.6976442",
"0.6913566",
"0.68805295",
"0.68650687",
"0.683369",
"0.683369",
"0.6803127",
"0.6766914",
... | 0.7886307 | 0 |
Returns the field name described in the file Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.field_name => "CAMPOS" | def field_name
self.well_info.field_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def field_name\r\n @field_name ||= begin\r\n %r/(\\w+)Field$/.match(name)[1]\r\n rescue\r\n %r/(\\w+)$/.match(name)[1]\r\n end\r\n end",
"def field_name\n self.class.name.split(\"::\").last.downcase.sub(\"of\", \"_of_\"). \\\n sub(\"fie... | [
"0.66984063",
"0.6500637",
"0.6321359",
"0.6127486",
"0.603498",
"0.6028319",
"0.6027831",
"0.5945752",
"0.59320956",
"0.5923208",
"0.5861244",
"0.5850968",
"0.582545",
"0.58120346",
"0.5811522",
"0.580928",
"0.5802823",
"0.57921726",
"0.5756785",
"0.5756785",
"0.5729316",
... | 0.6367217 | 2 |
Returns the location described in the file Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.location => "43.173871636390686 22.964858960678484" | def location
self.well_info.location
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def location\n fetch('hey_arnold.locations')\n end",
"def location\n fetch('sword_art_online.location')\n end",
"def location\n fetch('simpsons.locations')\n end",
"def location\n @location ||= Station.get(@attrs['LocationCode'])\n end",
"def get_loca... | [
"0.6697898",
"0.65045166",
"0.6493569",
"0.64308834",
"0.6367448",
"0.6348848",
"0.63199323",
"0.63088864",
"0.62945867",
"0.6290822",
"0.62611866",
"0.62571025",
"0.6244376",
"0.6241208",
"0.6241208",
"0.6241208",
"0.6241208",
"0.6225891",
"0.61907434",
"0.61326987",
"0.6113... | 0.63861203 | 4 |
Returns the province described in the file Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.province => "RIO DE JANEIRO" | def province
self.well_info.province
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def province\n ::Province.find_by(contabilium_id: self.IdProvincia)\n end",
"def province\n sale.province\n end",
"def province\n self.municipality.province\n end",
"def find_province_terrain(province_data)\n v = province_data[3]\n v = \"urban\" if urban_province_types.include?(v)\n # v ... | [
"0.6514513",
"0.62548363",
"0.6029765",
"0.5938827",
"0.5837015",
"0.5730205",
"0.5709851",
"0.5691844",
"0.5570934",
"0.551172",
"0.54329526",
"0.54239106",
"0.53504586",
"0.5322867",
"0.5319085",
"0.5305472",
"0.53042424",
"0.52975625",
"0.52730817",
"0.5267117",
"0.5264360... | 0.64560485 | 1 |
Returns the service company that performed the log acquisition Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.service_company => "ANY LOGGING COMPANY LTD." | def service_company
self.well_info.service_company
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def company\n @company ||= research_param(:company) || company_list.first\n end",
"def name\n latest_ccla_signature.company\n end",
"def company_name\n self.dig_for_string(\"agentSummary\", \"office\", \"companyName\")\n end",
"def getcompany\n Company.company_than(need_calc_company)\n ... | [
"0.6822279",
"0.6714972",
"0.67119133",
"0.67011994",
"0.6520701",
"0.643856",
"0.64375067",
"0.639938",
"0.6284502",
"0.6275567",
"0.6275199",
"0.62654847",
"0.62477225",
"0.61418927",
"0.61036944",
"0.6094983",
"0.6093869",
"0.603673",
"0.60061926",
"0.59661937",
"0.5949760... | 0.73509735 | 0 |
Returns a String with the date described in the file. Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.log_date => "25DEC1988" | def log_date
self.well_info.date_logged
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date\n tt = Time.gm(*filename_base.scan(/\\d+/))\n\n def tt.to_s\n to_formatted_s(:short_date_with_year) + \" \" + to_formatted_s(:short_time)\n end\n\n tt\n\tend",
"def date\n file.version.authored_date.strftime(\"%B %d, %Y\")\n end",
"def GetDateOfFile ( fl )\n dt = parse_date(fl... | [
"0.64819264",
"0.62180805",
"0.6192347",
"0.614532",
"0.5927823",
"0.5828196",
"0.58037513",
"0.5778604",
"0.57598037",
"0.57458884",
"0.56466603",
"0.56174666",
"0.5538115",
"0.55343956",
"0.55294913",
"0.5510369",
"0.5505074",
"0.5493487",
"0.54882306",
"0.54448825",
"0.540... | 0.54348123 | 20 |
Returns the API () described in the file Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.api => "1513120205" | def api
self.well_info.api
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api(path)\n OodAppkit.files.api(path: path).to_s\n end",
"def api\n @api\n end",
"def api_base_path\n \"/lol/platform/#{api_version}\"\n end",
"def api_name\n to_s.split('::').last.gsub(/[^\\A]([A-Z])/, '_\\\\1').downcase\n end",
"def get_api_version\n :v201502\n end",
... | [
"0.6092216",
"0.60680616",
"0.6053059",
"0.604105",
"0.59798735",
"0.5959112",
"0.5939222",
"0.58953714",
"0.58548737",
"0.5849631",
"0.57478416",
"0.5705776",
"0.57041574",
"0.5689066",
"0.5661654",
"0.56575954",
"0.5617997",
"0.56079394",
"0.56039745",
"0.55859435",
"0.5556... | 0.6546905 | 0 |
Returns the UWI (UNIQUE WELL ID) described in the file Returns API if UWI not found (for locations outside Canada) Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.uwi => "100091604920W300" | def uwi
self.well_info.uwi || self.well_info.api
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_of_uvhw(well)\n plate, r, c = find_uvhw(well)\n return \"Well #{plate.id}(#{'ABCD'[r]}#{c+1})\"\n end",
"def wpi\n data[:wpi]\n end",
"def get_WOEID()\n \t return @outputs[\"WOEID\"]\n \tend",
"def get_WOEID()\n \t return @outputs[\"WOEID\"]\n \tend",
"def wiki... | [
"0.58519405",
"0.55437887",
"0.5113649",
"0.5113649",
"0.5034688",
"0.50089514",
"0.49868485",
"0.49679846",
"0.4937397",
"0.4928996",
"0.48776057",
"0.48640478",
"0.48640436",
"0.4858467",
"0.48494008",
"0.48494008",
"0.48388565",
"0.47967997",
"0.4796675",
"0.47878236",
"0.... | 0.7319451 | 0 |
Returns the state described in the file Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.state => "KANSAS" | def state
self.well_info.state
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_file\n return File.join(File.dirname(__FILE__), 'state.json')\n end",
"def load_state\n begin\n if File.file?(\"#{$statefile}\") && File.readable?(\"#{$statefile}\") \n @current_state = File.read(\"#{$statefile}\").strip.split(':')\n end\n rescue\n erro... | [
"0.6223619",
"0.59959173",
"0.5980139",
"0.59111553",
"0.5908104",
"0.5802069",
"0.57481354",
"0.5739185",
"0.5670909",
"0.55981153",
"0.5576716",
"0.55691576",
"0.55563766",
"0.5542589",
"0.548392",
"0.5470379",
"0.5461593",
"0.5456341",
"0.54466414",
"0.54140544",
"0.540312... | 0.59478986 | 3 |
Returns the county described in the file Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.county => "KENAI" | def county
self.well_info.county
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def business_county\n business_location.county if business_location.present?\n end",
"def decode_county\n\t#\tcase county_code.to_s.slice(-2,2)\n\t#\twhat if '01' or '1' or 1 or '12341234123401'\n\t\tcase sprintf('%02d',self.to_i).to_s.slice(-2,2).to_i\n\t#\t\twhen 0 then the given state code was all text\n\... | [
"0.6126817",
"0.5840096",
"0.5806407",
"0.57190007",
"0.5713216",
"0.56970817",
"0.56970817",
"0.56970817",
"0.5654555",
"0.5235436",
"0.51854503",
"0.5128856",
"0.50996417",
"0.50856274",
"0.5079576",
"0.49857908",
"0.49810976",
"0.49487928",
"0.49149308",
"0.49089268",
"0.4... | 0.6615666 | 0 |
Returns the country described in the file Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.country => "US" | def country
self.well_info.country
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def country\n @country ||= IsoCountryCodes.find(alpha2)\n end",
"def get_country\n @single_city_data[\"sys\"][\"country\"]\n end",
"def country\n self[:C]\n end",
"def country\n 'United Kingdom'\n end",
"def get_country_name_lib country_code\n country = Carmen::Country.coded(coun... | [
"0.66511816",
"0.640445",
"0.63179964",
"0.62392914",
"0.61957055",
"0.6162235",
"0.6160568",
"0.6121128",
"0.61086684",
"0.6094934",
"0.6092756",
"0.6082983",
"0.606678",
"0.60591793",
"0.6046856",
"0.6032826",
"0.60316855",
"0.6017057",
"0.60140425",
"0.6007601",
"0.5961274... | 0.5985217 | 20 |
Backup of websites is often not considered until | def generate_rdf_abstract(b)
k = setup_abst_info(to_marc)
b.dcterms(:abstract,k.join(' ')) unless k.blank?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_backup\n end",
"def system_backup\n\n\n end",
"def backups_to_keep\n @backups_to_keep ||= 2\n end",
"def perform_backup\n \n add_memories_to_dropbox! if has_dropbox?\n\n # Clone the repo incase something is writing to it while we are backing up\n run \"cd #{@home} && ... | [
"0.6760374",
"0.65854764",
"0.6568706",
"0.65109974",
"0.63714516",
"0.63710374",
"0.6369073",
"0.63092065",
"0.6279789",
"0.62043643",
"0.61842984",
"0.6123452",
"0.6004151",
"0.59951764",
"0.59724164",
"0.5958574",
"0.5903095",
"0.5886609",
"0.58676755",
"0.58336115",
"0.58... | 0.0 | -1 |
if eresource put catalog link in coverage else put in url field. | def generate_rdf_catlink(b,ty)
ul = "http://catalog.library.cornell.edu/catalog/#{id}"
# if no elect access data, 'description' field.
b.dc(:description,ul)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def catalog_generator(bib)\n QuickSearch::Engine::WORLD_CAT_DISCOVERY_API_ARTICLE_CONFIG['url_link'] +\n bib.oclc_number.to_s\n end",
"def ajax_catalog_link_and_source\n instance_id = params['instanceId']\n url = ENV['OKAPI_URL']\n tenant = ENV['OKAPI_TENANT']\n # Get instance ... | [
"0.55972606",
"0.55344504",
"0.55250597",
"0.5484369",
"0.54650277",
"0.54366934",
"0.53981376",
"0.53907686",
"0.5372756",
"0.53431016",
"0.5312575",
"0.5293552",
"0.5248956",
"0.52340806",
"0.5197136",
"0.5188058",
"0.5169922",
"0.51620907",
"0.5158144",
"0.51543087",
"0.51... | 0.55700177 | 1 |
add info specific to an item type. | def generate_rdf_specific(b,ty)
case ty
when 'thesis'
th = setup_thesis_info(to_marc)
typ = th[:type].to_s
Rails.logger.debug "********es287_dev #{__FILE__} #{__LINE__} #{__method__} #{th.inspect}"
b.z(:type,typ)
else
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_type\n @item.type = bibtex_type\n end",
"def add(type, description, options={})\n type = type.downcase\n if type == 'todo' then @items.push TodoItem.new(description, options) #uses ToDoItem class in todo.rb\n elsif type == 'event' then @items.push EventItem.new(description, options) ... | [
"0.7269015",
"0.67680913",
"0.6578306",
"0.64838266",
"0.63886726",
"0.6326152",
"0.63034403",
"0.63034403",
"0.6257325",
"0.6180453",
"0.60943633",
"0.607539",
"0.60279316",
"0.60252964",
"0.60067475",
"0.6005773",
"0.60036635",
"0.58729863",
"0.58678126",
"0.58525",
"0.5826... | 0.0 | -1 |
GET /cms/pages GET /cms/pages.json | def index
@cms_pages = Cms::Page.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pages = current_site.pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def get_pages(options = nil)\n @client.raw('get', '/content/pages', options)\n end",
"def index\n @pages = Page.page params[:page]\n\... | [
"0.80024236",
"0.7591794",
"0.7548563",
"0.7502745",
"0.7413682",
"0.72976756",
"0.7275709",
"0.727428",
"0.7253506",
"0.7253506",
"0.7253506",
"0.7253506",
"0.7253506",
"0.7253506",
"0.7253506",
"0.7227317",
"0.70825803",
"0.70712346",
"0.7023665",
"0.7011868",
"0.7003465",
... | 0.74624985 | 4 |
GET /cms/pages/1 GET /cms/pages/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pages = current_site.pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render ... | [
"0.7818136",
"0.7398596",
"0.72995096",
"0.7295045",
"0.7292579",
"0.71695435",
"0.7168041",
"0.7146733",
"0.7132539",
"0.7132539",
"0.7132539",
"0.7132539",
"0.7132539",
"0.7132539",
"0.7132539",
"0.7121467",
"0.70936114",
"0.7087248",
"0.70760006",
"0.69468063",
"0.6940699"... | 0.0 | -1 |
POST /cms/pages POST /cms/pages.json | def create
@cms_page = Cms::Page.new(cms_page_params)
respond_to do |format|
if @cms_page.save
if @cms_page.page_type == "Template"
format.html { redirect_to :action => "add_content", :id => @cms_page.id, notice: 'Page was successfully created.' }
else
format.html { redirect_to @cms_page, notice: 'Page was successfully updated.' }
end
format.json { render :show, status: :created, location: @cms_page }
else
format.html { render :new }
format.json { render json: @cms_page.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @cms_page = current_portal.pages.build(cms_page_params)\n\n respond_to do |format|\n if @cms_page.save\n format.html { redirect_to @cms_page, notice: 'Page was successfully created.' }\n format.json { render :show, status: :created, location: @cms_page }\n else\n f... | [
"0.7243622",
"0.71870834",
"0.71328",
"0.7092713",
"0.70550215",
"0.6958681",
"0.68977296",
"0.6827462",
"0.68213457",
"0.6796138",
"0.67860544",
"0.6785146",
"0.6784767",
"0.67567915",
"0.6750377",
"0.67454386",
"0.6743167",
"0.6719996",
"0.67171437",
"0.6685417",
"0.6658822... | 0.67217517 | 17 |
PATCH/PUT /cms/pages/1 PATCH/PUT /cms/pages/1.json | def update
respond_to do |format|
if @cms_page.update(cms_page_params)
if @cms_page.page_type == "Template"
format.html { redirect_to :action => "add_content", :id => @cms_page.id, notice: 'Page was successfully updated.' }
else
format.html { redirect_to @cms_page, notice: 'Page was successfully updated.' }
end
format.json { render :show, status: :ok, location: @cms_page }
else
format.html { render :edit }
format.json { render json: @cms_page.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @page = current_cms.pages.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:big_cms_page])\n format.html { render :action => \"edit\" }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xm... | [
"0.71848303",
"0.69642866",
"0.69482815",
"0.68609107",
"0.67964363",
"0.679205",
"0.6771985",
"0.6746097",
"0.67242384",
"0.67217857",
"0.6716855",
"0.6683872",
"0.66713697",
"0.6643328",
"0.6638371",
"0.6638371",
"0.66383207",
"0.66339535",
"0.6623543",
"0.66084224",
"0.660... | 0.6748274 | 7 |
DELETE /cms/pages/1 DELETE /cms/pages/1.json | def destroy
@cms_page.destroy
respond_to do |format|
format.html { redirect_to cms_pages_url, notice: 'Page was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @cms_page.destroy\n respond_to do |format|\n format.html { redirect_to cms_pages_url, notice: \"#{@cms_page.title} has been deleted.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cms_page.destroy\n respond_to do |format|\n format.html { redirect... | [
"0.78697467",
"0.7766718",
"0.7704622",
"0.76399887",
"0.7600261",
"0.7593965",
"0.75675017",
"0.74696565",
"0.7417237",
"0.7417237",
"0.7417237",
"0.7417237",
"0.73983175",
"0.738937",
"0.73876965",
"0.73876965",
"0.73876965",
"0.73876965",
"0.73876965",
"0.73876965",
"0.738... | 0.77656174 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_cms_page
@cms_page = Cms::Page.friendly.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 cms_page_params
params.require(:cms_page).permit(:title, :category, :page_type, :external_url, :internal_url, :document, :page_template_id, :cols, page_sections_attributes: [ :id, :photo, :body, :page_id ])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Change this eventually for better security supportsetup_fileserver | def setup_autosigning
<<-EOS
echo "*" > /etc/puppet/autosign.conf
EOS
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_file_server; end",
"def public_file_server; end",
"def public_file_server=(_arg0); end",
"def public_file_server=(_arg0); end",
"def file_handler_opts; end",
"def file_options; end",
"def file_utils; end",
"def runFileServer\n @@servlet = FileServlet.new(@@self_port)\n \n Thread.start {... | [
"0.7538976",
"0.7538976",
"0.74575835",
"0.74575835",
"0.6470444",
"0.6065189",
"0.60561615",
"0.59861195",
"0.59857917",
"0.5959054",
"0.5942652",
"0.5895407",
"0.58773345",
"0.58416224",
"0.5839264",
"0.5838764",
"0.5838069",
"0.5807039",
"0.5790493",
"0.5785617",
"0.577893... | 0.0 | -1 |
Takes a number and options hash and outputs a string in any currency format. CREDIT: | def currencify(number, options={})
return "$0.00" if number.nil?
# default format: $12,345,678.90
options = {
:currency_symbol => "$",
:delimiter => ",",
:decimal_symbol => ".",
:currency_before => true
}.merge(options)
# split integer and fractional parts
int, frac = ("%.2f" % number).split('.')
# insert the delimiters
int.gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{options[:delimiter]}")
if options[:currency_before]
options[:currency_symbol] + int + options[:decimal_symbol] + frac
else
int + options[:decimal_symbol] + frac + options[:currency_symbol]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_price(options = {})\n price_unpacked.to_s + '€ per piece, ' + price_packed.to_s + '€ per box'\n end",
"def to_s(options = {})\n return amount.to_f.to_s if options[:exact]\n self.format(:symbol => false)\n end",
"def pretty_currency_formatted(options={})\n if self == 0.00\n \"free\"\... | [
"0.71907204",
"0.7063055",
"0.70190763",
"0.6985442",
"0.69077504",
"0.67169166",
"0.6700911",
"0.6589675",
"0.64248496",
"0.6295236",
"0.6284713",
"0.6274329",
"0.62716234",
"0.6267303",
"0.62597984",
"0.62457037",
"0.62457037",
"0.62248987",
"0.62122995",
"0.62122995",
"0.6... | 0.65858483 | 8 |
this will be useful if we want to `puts params` in the server log | def to_s
@params.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output_debug(params)\n Rails.logger.debug(\"\\n\\n\\n\\n------------------------------------------------\\n\")\n Rails.logger.debug(params.inspect)\n Rails.logger.debug(\"\\n------------------------------------------------\\n\\n\\n\\n\")\n end",
"def log_request\n logger.info \"HTTP request rece... | [
"0.7539688",
"0.7500098",
"0.7247633",
"0.701044",
"0.70040363",
"0.67842156",
"0.676317",
"0.666582",
"0.66440433",
"0.6626347",
"0.65786785",
"0.6577528",
"0.65625983",
"0.65605503",
"0.65155727",
"0.64918655",
"0.6450838",
"0.6412487",
"0.64084923",
"0.63752234",
"0.637508... | 0.0 | -1 |
this should return an array user[address][street] should return ['user', 'address', 'street'] | def parse_key(key)
key.split(/\]\[|\[|\]/)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_data(users, username)\n user_array = []\n users.each do |user|\n if user['username'] == username\n user_array << user['name']\n user_array << user['username']\n user_array << user['password']\n user_array << user['admin']\n end\n end\n... | [
"0.6054917",
"0.57644564",
"0.5720622",
"0.56273395",
"0.55881655",
"0.54471415",
"0.5436326",
"0.5410643",
"0.53270715",
"0.5200718",
"0.5155467",
"0.51475835",
"0.5094791",
"0.50841933",
"0.50824666",
"0.50767744",
"0.5075248",
"0.5067996",
"0.5064469",
"0.5058632",
"0.5058... | 0.0 | -1 |
Returns all repos as pythonlike generators | def all_repos_as_generator
Enumerator.new do |enum|
each do |repo|
enum.yield repo
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repos\n pry(Git::Multi.repositories)\nend",
"def all\n return @raw_repos unless @raw_repos.empty?\n return [Template.root.basename.to_s] if Template.project?\n Template.root.join(Meta.new({}).repos_dir).children.map do |path|\n path.basename.to_s\n end\n\n rescue Er... | [
"0.6886352",
"0.6706091",
"0.6547711",
"0.6488232",
"0.64740634",
"0.64513975",
"0.6448159",
"0.64425504",
"0.6407408",
"0.6400587",
"0.6387641",
"0.6384363",
"0.63795084",
"0.63451135",
"0.63272053",
"0.63034374",
"0.6265424",
"0.6264255",
"0.62005675",
"0.61952955",
"0.6194... | 0.81309724 | 1 |
GET /feed_entries/1 GET /feed_entries/1.json | def show
@feed_entry = FeedEntry.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @feed_entry }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @feed = Feed.find(params[:id])\n @entries = EntryFeed.where(:feed_id => @feed.id)\n\n if @entries.blank?\n EntryFeed.create_from_feed(@feed)\n @entries = EntryFeed.where(:feed_id => @feed.id)\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json ... | [
"0.77304965",
"0.7627515",
"0.73237264",
"0.73084277",
"0.7175086",
"0.7175017",
"0.71232295",
"0.7010187",
"0.7007073",
"0.69571435",
"0.69366586",
"0.6868748",
"0.6859293",
"0.6788085",
"0.6766332",
"0.66928005",
"0.6673857",
"0.6669177",
"0.6668894",
"0.6667361",
"0.665704... | 0.72590834 | 4 |
GET /feed_entries/new GET /feed_entries/new.json | def new
@feed_entry = FeedEntry.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @feed_entry }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @feed = Feed.find(params[:feed_id])\n @entry = @feed.entries.new\n respond_to do |format|\n format.html { render :layout => 'feed'}\n format.json { render json: @entry }\n end\n end",
"def new\n @feedentry = Feedentry.new\n\n respond_to do |format|\n format.html # new.... | [
"0.81818604",
"0.79339516",
"0.7641211",
"0.7641211",
"0.7641211",
"0.7641211",
"0.7585719",
"0.7567555",
"0.75592077",
"0.75592077",
"0.75592077",
"0.75592077",
"0.75592077",
"0.75592077",
"0.75592077",
"0.75592077",
"0.7367382",
"0.72282284",
"0.7134517",
"0.7098455",
"0.70... | 0.791516 | 2 |
POST /feed_entries POST /feed_entries.json | def create
@feed_entry = FeedEntry.new(params[:feed_entry])
respond_to do |format|
if @feed_entry.save
format.html { redirect_to @feed_entry, notice: 'Feed entry was successfully created.' }
format.json { render json: @feed_entry, status: :created, location: @feed_entry }
else
format.html { render action: "new" }
format.json { render json: @feed_entry.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @feed = Feed.find(params[:feed_id])\n @entry = @feed.entries.new(params[:entry])\n\n respond_to do |format|\n if @entry.save\n @entry.author.save\n format.html { redirect_to feed_entry_path(@feed,@entry), notice: 'Entry was successfully created.' }\n format.json { re... | [
"0.71177864",
"0.6742121",
"0.6672325",
"0.6662345",
"0.66572225",
"0.6586359",
"0.6571794",
"0.6541356",
"0.6541065",
"0.64221865",
"0.63847136",
"0.63748074",
"0.6251975",
"0.61803406",
"0.6178804",
"0.61771166",
"0.6169259",
"0.6151998",
"0.6145556",
"0.6129383",
"0.612374... | 0.6662979 | 3 |
PUT /feed_entries/1 PUT /feed_entries/1.json | def update
@feed_entry = FeedEntry.find(params[:id])
respond_to do |format|
if @feed_entry.update_attributes(params[:feed_entry])
format.html { redirect_to @feed_entry, notice: 'Feed entry was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @feed_entry.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @entry = Entry.find(params[:id])\n @feed = @entry.feed\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to feed_entry_path(@feed, @entry), notice: 'Entry was successfully updated.' }\n format.json { head :no_content }\n ... | [
"0.7246307",
"0.7246307",
"0.70268375",
"0.6814572",
"0.6733385",
"0.6701174",
"0.6678864",
"0.66784394",
"0.666431",
"0.6620534",
"0.6612091",
"0.6603729",
"0.6603729",
"0.6593721",
"0.65492576",
"0.6521436",
"0.64245814",
"0.64245814",
"0.64245814",
"0.64245814",
"0.6424581... | 0.6841135 | 3 |
DELETE /feed_entries/1 DELETE /feed_entries/1.json | def destroy
@feed_entry = FeedEntry.find(params[:id])
@feed_entry.destroy
respond_to do |format|
format.html { redirect_to feed_entries_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @entry = Entry.find(params[:id])\n @feed = @entry.feed\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to feed_path(@feed) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feedentry = Feedentry.find(params[:id])\n @feedentry.des... | [
"0.7675228",
"0.7567747",
"0.7458496",
"0.7410145",
"0.7379684",
"0.7348866",
"0.7295838",
"0.7239369",
"0.7239369",
"0.72324055",
"0.7209484",
"0.72024554",
"0.72024554",
"0.72024554",
"0.71721816",
"0.7163158",
"0.7163158",
"0.7163158",
"0.7163036",
"0.7148303",
"0.714283",... | 0.76343584 | 1 |
Details: Your car is old, it breaks easily. The shock absorbers are gone and you think it can handle about 15 more bumps before it dies totally. Unfortunately for you, your drive is very bumpy! Given a string showing either flat road ("_") or bumps ("n"), work out if you make it home safely. 15 bumps or under, return "Woohoo!", over 15 bumps return "Car Dead". | def bump(x)
x.count('n') <= 15 ? "Woohoo!" : "Car Dead"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hamstrings_stretch\n \"Remaining seated, extend one leg outward. Reach toward your toes. Hold for 10 to 30 seconds. Repeat on the other side. Be sure to do this one leg at a time, as doing this exercise with both legs out can cause back issues.\"\nend",
"def catch_phrase\n [\n [\"ninja\",\... | [
"0.6288638",
"0.6200622",
"0.60731244",
"0.60665154",
"0.60089314",
"0.59571177",
"0.59512025",
"0.59426916",
"0.5941199",
"0.592064",
"0.5899853",
"0.58943903",
"0.5884555",
"0.586874",
"0.58502626",
"0.58115613",
"0.5811494",
"0.5808975",
"0.57971054",
"0.5795099",
"0.57858... | 0.0 | -1 |
makes a request and raises in case of Riot API error | def make_request(url)
res = Typhoeus::Request.new(
url,
method: :get,
headers: {
"Accept-Charset": "application/x-www-form-urlencoded; charset=UTF-8",
"Accept-Language" => "en-US,en;q=0.9,pt;q=0.8",
"X-Riot-Token" => @api_key.to_s,
"User-Agent": "https://github.com/drish/rioter"
}
).run
parse!(res)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_request(method, url, params = {})\n path = \"#{EbanqApi.base_url}/#{url}\"\n response = case method\n when :get then get(path, headers, params)\n when :post then post(path, headers, params)\n when :put then put(path, headers, params)\n ... | [
"0.69253516",
"0.65905386",
"0.6541506",
"0.6455014",
"0.6446199",
"0.6446199",
"0.64422065",
"0.64416486",
"0.6423835",
"0.63428026",
"0.63072413",
"0.63021266",
"0.62828106",
"0.62677324",
"0.6234778",
"0.6162966",
"0.61435753",
"0.61298525",
"0.612292",
"0.61221504",
"0.61... | 0.6396709 | 9 |
handling behaviour based on response code | def parse!(response)
case response.code
when 404
raise Rioter::Errors::SummonerNotFound.new
when 403
# TODO: custom errors
raise StandardError.new("Riot error: Forbidden.")
when 429
retry_after = response.headers["Retry-After"]
raise Rioter::Errors::RateLimited.new(msg: "Rate limit reached, retry after: #{retry_after}", retry_after: retry_after)
else
JSON.parse(response.body)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_status_code(req)\n case req.code\n when 200..204; return\n when 400; raise ResponseError.new req\n when 401; raise ResponseError.new req\n else raise StandardError\n end\n end",
"def response_code; end",
"def response_code; end",
"def response_code; end",
"def re... | [
"0.78711",
"0.77024347",
"0.77024347",
"0.77024347",
"0.77024347",
"0.7574864",
"0.7558899",
"0.7441638",
"0.74407214",
"0.74375355",
"0.74352586",
"0.74352586",
"0.7407546",
"0.7358558",
"0.7344115",
"0.73034644",
"0.73034644",
"0.7217653",
"0.7124387",
"0.7091345",
"0.70735... | 0.0 | -1 |
add screener to playlist | def add_screener
@screener_playlist = ScreenerPlaylist.find(params[:id])
@screener_playlist_item_position = ScreenerPlaylistItem.where("screener_playlist_id=?", params[:id])
.order("position ASC")
.find(:last)
@screener_playlist_item_position = @screener_playlist_item_position.nil? ? 1 : @screener_playlist_item_position.position + 1
@screener_playlist_item = ScreenerPlaylistItem.new(screener_playlist_id: params[:id],
screener_id: params[:screener_id],
position: @screener_playlist_item_position)
@notice=""
@screener_to_add = Screener.find(params[:screener_id])
if @screener_playlist_item.save
flash[:notice] = 'Screener was successfully added.'
session[:screeners_search] = collection_to_id_array(@screener_playlist.screeners)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_queue(playlist)\n @queue << playlist\n if @current_playlist.nil? \n @current_playlist = @queue.shift\n play @current_playlist\n end\n end",
"def add_to_playlist(media)\n connection.write(\"enqueue #{media(media)}\")\n end",
"def add_to_playlist(media)\n connect... | [
"0.6616027",
"0.64913815",
"0.64092594",
"0.638075",
"0.6302139",
"0.6292513",
"0.62877065",
"0.6255536",
"0.62553316",
"0.62321717",
"0.6228287",
"0.6226817",
"0.6194212",
"0.6181943",
"0.61334336",
"0.6117756",
"0.6101854",
"0.6098525",
"0.6084723",
"0.60626733",
"0.6057634... | 0.67087215 | 0 |
add selected videos to playlist | def add_multiple_screeners
@notice = ""
@screener_playlist = ScreenerPlaylist.find(params[:playlist_id])
screener_ids = params[:screener_ids]
screener_ids.each do |screener_id|
@screener_playlist_item_position = ScreenerPlaylistItem.where("screener_playlist_id=?", params[:playlist_id])
.order("position ASC")
.find(:last)
@screener_playlist_item_position = @screener_playlist_item_position.nil? ? 1 : @screener_playlist_item_position.position + 1
@screener_playlist_item = ScreenerPlaylistItem.new(screener_playlist_id: params[:playlist_id],
screener_id: screener_id,
position: @screener_playlist_item_position)
@screener_to_add = Screener.find(screener_id)
if @screener_playlist_item.save
flash[:notice] = 'Screeners were successfully added.'
session[:screeners_search] = collection_to_id_array(@screener_playlist.screeners)
end
end # loop through video ids
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_multiple_videos\n\n @notice = \"\"\n @video_playlist = VideoPlaylist.find(params[:playlist_id])\n video_ids = params[:video_ids]\n\n video_ids.each do |video_id|\n @video_playlist_item_position = VideoPlaylistItem.where(\"video_playlist_id=?\", params[:playlist_id])\n ... | [
"0.7316284",
"0.72339803",
"0.68312114",
"0.6595592",
"0.6514733",
"0.6476899",
"0.6388595",
"0.63495183",
"0.6311904",
"0.6173108",
"0.614058",
"0.6132977",
"0.6110577",
"0.61001635",
"0.60890406",
"0.6058278",
"0.60539895",
"0.6022344",
"0.6021603",
"0.5972253",
"0.59683645... | 0.5472455 | 78 |
PATCH/PUT /extractions_extraction_forms_projects_sections_type1/1 PATCH/PUT /extractions_extraction_forms_projects_sections_type1/1.json | def update
# A bit of security here to ensure we get values we expected:
# - 'false'
# - 'citations'
# - 'project'
propagation_scope = { 'false' => false, 'citations' => :citations,
'project' => :project }[extractions_extraction_forms_projects_sections_type1_params.dig(
:should, :propagate
)]
# If we want to propagate then do it now.
if propagation_scope
@extractions_extraction_forms_projects_sections_type1.propagate_type1_change(propagation_scope,
extractions_extraction_forms_projects_sections_type1_params)
end
respond_to do |format|
if @extractions_extraction_forms_projects_sections_type1.update(extractions_extraction_forms_projects_sections_type1_params)
format.html do
redirect_to work_extraction_path(@extractions_extraction_forms_projects_sections_type1.extraction,
'panel-tab': @extractions_extraction_forms_projects_sections_type1
.extractions_extraction_forms_projects_section
.extraction_forms_projects_section.id),
notice: t('success')
end
format.json { render json: {} }
format.js {}
else
format.html do
flash[:alert] = @extractions_extraction_forms_projects_sections_type1.errors.messages.values.dig(0, 0)
render :edit
end
format.json do
render json: @extractions_extraction_forms_projects_sections_type1.errors, status: :unprocessable_entity
end
format.js {}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_extractions_extraction_forms_projects_sections_type1\n @extractions_extraction_forms_projects_sections_type1 = ExtractionsExtractionFormsProjectsSectionsType1.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @extractions_extraction_forms_projects_sections_type1.update(e... | [
"0.71862346",
"0.71666884",
"0.6797903",
"0.67297965",
"0.64738977",
"0.6439036",
"0.6389619",
"0.6322907",
"0.6301197",
"0.6295501",
"0.62587935",
"0.5670713",
"0.56633794",
"0.56380713",
"0.55923945",
"0.55866194",
"0.5577865",
"0.555775",
"0.55483025",
"0.55263823",
"0.547... | 0.69906765 | 2 |
DELETE /extractions_extraction_forms_projects_sections_type1/1 DELETE /extractions_extraction_forms_projects_sections_type1/1.json | def destroy
@extractions_extraction_forms_projects_sections_type1.destroy
respond_to do |format|
format.html do
redirect_to work_extraction_path(@extractions_extraction_forms_projects_sections_type1
.extractions_extraction_forms_projects_section
.extraction,
'panel-tab': @extractions_extraction_forms_projects_sections_type1
.extractions_extraction_forms_projects_section
.extraction_forms_projects_section
.id),
notice: t('removed')
end
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @extractions_extraction_forms_projects_sections_type1.destroy\n respond_to do |format|\n format.html { redirect_to work_extraction_path(@extractions_extraction_forms_projects_sections_type1\n .extractions_extraction_forms_projects_secti... | [
"0.7626632",
"0.6354295",
"0.63228387",
"0.63028866",
"0.62969583",
"0.6292912",
"0.62236863",
"0.62202066",
"0.62114114",
"0.61981344",
"0.6196551",
"0.61782646",
"0.6177106",
"0.6175349",
"0.6148747",
"0.6143146",
"0.61424005",
"0.6111107",
"0.61093783",
"0.6106999",
"0.610... | 0.76073885 | 1 |
POST /extractions_extraction_forms_projects_sections_type1s/1/add_population POST /extractions_extraction_forms_projects_sections_type1s/1/add_population.json | def add_population
authorize(@extractions_extraction_forms_projects_sections_type1)
@extractions_extraction_forms_projects_sections_type1.extractions_extraction_forms_projects_sections_type1_rows.each do |eefpst1r|
eefpst1r.extractions_extraction_forms_projects_sections_type1_row_columns.create
end
redirect_to(
edit_populations_extractions_extraction_forms_projects_sections_type1(@extractions_extraction_forms_projects_sections_type1),
notice: t('success'),
status: 303
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_population\n @extractions_extraction_forms_projects_sections_type1.extractions_extraction_forms_projects_sections_type1_rows.each do |eefpst1r|\n eefpst1r.extractions_extraction_forms_projects_sections_type1_row_columns.create\n end\n\n redirect_to edit_populations_extractions_extraction_form... | [
"0.7874224",
"0.6710033",
"0.6270805",
"0.6023102",
"0.55719763",
"0.55287224",
"0.55287224",
"0.5522431",
"0.54312444",
"0.53367424",
"0.5334908",
"0.52677965",
"0.51416105",
"0.5138206",
"0.50998086",
"0.5098964",
"0.5084003",
"0.5073172",
"0.50245917",
"0.50188595",
"0.501... | 0.8248006 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_extractions_extraction_forms_projects_sections_type1
@extractions_extraction_forms_projects_sections_type1 = ExtractionsExtractionFormsProjectsSectionsType1.find(params[:id])
authorize(@extractions_extraction_forms_projects_sections_type1)
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 extractions_extraction_forms_projects_sections_type1_params
params.require(:extractions_extraction_forms_projects_sections_type1)
.permit(:type1_type_id, :extractions_extraction_forms_projects_section_id, :type1_id, :units,
should: :propagate,
type1_attributes: %i[id name description],
extractions_extraction_forms_projects_sections_type1_rows_attributes: [
:id, :_destroy,
{ population_name_attributes: %i[id name description],
extractions_extraction_forms_projects_sections_type1_row_columns_attributes: [
:id, :_destroy,
{ timepoint_name_attributes: %i[id name unit] }
] }
])
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 |
def index user = User.find_by(id: params['user_id']) expenses = user.expenses.all render json: debts end | def create
user = User.find_by(id: expense_params['user_id'])
debt = Debt.find_by(id: expense_params['debt_id'])
expense = user.expenses.build(expense_params)
if expense.save
if debt
debt.expenses << expense
end
render json: user
else
render json: expense.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if current_user\n \t@debts = Debt.paginate(:page => params[:page], :per_page => 10)\n \trespond_to do |format|\n \tformat.html # index.html.erb\n \tformat.json { render json: @debts }\n \tend\n end\n end",
"def index\n @expenses = find_expenses.all\n render json: @expe... | [
"0.8071129",
"0.7704536",
"0.75661975",
"0.74813133",
"0.74079037",
"0.73860496",
"0.7382088",
"0.7296139",
"0.7250527",
"0.7234994",
"0.72144365",
"0.71990156",
"0.7157554",
"0.7133846",
"0.712324",
"0.7096128",
"0.7084539",
"0.7084539",
"0.7071406",
"0.707128",
"0.70526135"... | 0.6620122 | 72 |
options: key: namespace name redis_prefix: redis prefix name similarity_func: see readme.md file weight: see readme.md file | def initialize(options)
@input_matrix = Recommendify::InputMatrix.create(options)
@similarity_matrix = Recommendify::SimilarityMatrix.new(options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redis_key(str)\n \"score:#{self.id}:#{str}\"\n end",
"def add_item_to_redis_key args, key\n if args.has_key?(key) && !args[key].nil?\n key = \":#{args[key]}\"\n key = key.mb_chars.downcase if redis_key_normalize_conf.include?(:downcase)\n key = ActiveSupport::Inflector::translit... | [
"0.59889215",
"0.56199765",
"0.5440855",
"0.54006696",
"0.53479666",
"0.5303104",
"0.5281439",
"0.5274622",
"0.5254971",
"0.5232295",
"0.5222194",
"0.51854455",
"0.51823235",
"0.5162396",
"0.51604503",
"0.5156732",
"0.5151567",
"0.5121496",
"0.5117017",
"0.51167166",
"0.51023... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.