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 |
|---|---|---|---|---|---|---|
Open current file or directory with the editor. | def edit
execute_external_command do
editor = ENV['EDITOR'] || 'vim'
unless in_zip?
system %Q[#{editor} "#{current_item.path}"]
else
begin
tmpdir, tmpfile_name = nil
Zip::File.open(current_zip) do |zip|
tmpdir = Dir.mktmpdir
FileUtils.mkdir_p File.join(tmpdir, File.dirname(current_item.name))
tmpfile_name = File.join(tmpdir, current_item.name)
File.open(tmpfile_name, 'w') {|f| f.puts zip.file.read(current_item.name)}
system %Q[#{editor} "#{tmpfile_name}"]
zip.add(current_item.name, tmpfile_name) { true }
end
ls
ensure
FileUtils.remove_entry_secure tmpdir if tmpdir
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_in_editor(file)\n if (ENV['EDITOR'])\n system (\"#{ENV['EDITOR']} #{file}\")\n end\nend",
"def open_in_editor(file)\n if (ENV['EDITOR'])\n system (\"#{ENV['EDITOR']} #{file}\")\n end\nend",
"def open\n ensure!\n open_in_editor\n end",
"def open(file = nil, editor: nil, command... | [
"0.7969313",
"0.7969313",
"0.7921218",
"0.77874136",
"0.7464126",
"0.73881567",
"0.7286962",
"0.7279407",
"0.7226133",
"0.704737",
"0.6853889",
"0.6805099",
"0.68046224",
"0.6772369",
"0.6739086",
"0.6689621",
"0.65286225",
"0.6495167",
"0.6491517",
"0.6440104",
"0.63972884",... | 0.585707 | 42 |
Open current file or directory with the viewer. | def view
pager = ENV['PAGER'] || 'less'
execute_external_command do
unless in_zip?
system %Q[#{pager} "#{current_item.path}"]
else
begin
tmpdir, tmpfile_name = nil
Zip::File.open(current_zip) do |zip|
tmpdir = Dir.mktmpdir
FileUtils.mkdir_p File.join(tmpdir, File.dirname(current_item.name))
tmpfile_name = File.join(tmpdir, current_item.name)
File.open(tmpfile_name, 'w') {|f| f.puts zip.file.read(current_item.name)}
end
system %Q[#{pager} "#{tmpfile_name}"]
ensure
FileUtils.remove_entry_secure tmpdir if tmpdir
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_in_viewer\n fork { exec \"#{Seee::Config.application_paths[:pdf_viewer]} \\\"#{current_path}\\\"\" }\n end",
"def view\n\t `ruby #{File.dirname(__FILE__) + \"/viewer/viewer.rb\"}`\n end",
"def open(sender)\n open = NSOpenPanel.openPanel\n open.setAllowsMultipleSelection(true)\n open... | [
"0.781872",
"0.6997111",
"0.67266864",
"0.67022246",
"0.6667257",
"0.6482035",
"0.6454375",
"0.64361364",
"0.6367363",
"0.6297417",
"0.6258015",
"0.6227832",
"0.6223393",
"0.6219053",
"0.6166791",
"0.61420774",
"0.6094677",
"0.606768",
"0.6066725",
"0.60534966",
"0.60240424",... | 0.5240972 | 82 |
GET /events GET /events.json | def index
@events = Event.all
respond_to do |format|
format.html
format.json do
render :json => {events: @events}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end",
"def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end",
"def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}... | [
"0.8337294",
"0.82393",
"0.7943906",
"0.7928331",
"0.77682066",
"0.77408546",
"0.76701826",
"0.7665501",
"0.76581633",
"0.7642472",
"0.76212007",
"0.7615658",
"0.7615658",
"0.7612881",
"0.75687",
"0.7488667",
"0.74813455",
"0.74698067",
"0.7441679",
"0.74408287",
"0.7439104",... | 0.7522498 | 15 |
GET /events/1 GET /events/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @event = Event.find(params[:id])\n render json: @event\n end",
"def get(event_id)\n @client.request \"events/#{event_id}\"\n end",
"def show\n event_id = params[:id]\n if event_id.present?\n @event = Com::Nbos::Events::Event.active_events.where(id: event_id, tenant_id: @use... | [
"0.75029767",
"0.74019474",
"0.7361382",
"0.7348975",
"0.73475033",
"0.7338018",
"0.7317425",
"0.72875094",
"0.72813755",
"0.7246173",
"0.72317284",
"0.7219172",
"0.7219172",
"0.7218839",
"0.7218839",
"0.721464",
"0.7204848",
"0.71989256",
"0.7196662",
"0.71925515",
"0.719221... | 0.0 | -1 |
POST /events POST /events.json | def create
@event = Event.new(event_params)
respond_to do |format|
if @event.save
format.html { redirect_to @event, notice: 'Event was successfully created.' }
format.json { render :show, status: :created, location: @event }
else
format.html { render :new }
format.json { render json: @event.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_event event, data={}\n data[:event] = event\n post '/event', data\n end",
"def create\n event = Event.new(event_params)\n event.save!\n render json: event\n end",
"def create\n Rails.logger.debug(\"Received event #{params[:event]}\")\n head :ok\n end",
"def crea... | [
"0.7714071",
"0.7611226",
"0.76028967",
"0.7541319",
"0.7444731",
"0.73206913",
"0.73138195",
"0.728203",
"0.7251226",
"0.7235907",
"0.7235907",
"0.7215051",
"0.71682763",
"0.7150409",
"0.7126664",
"0.7118896",
"0.7117831",
"0.71162695",
"0.70964044",
"0.70907074",
"0.7083036... | 0.6948119 | 71 |
PATCH/PUT /events/1 PATCH/PUT /events/1.json | def update
respond_to do |format|
if @event.update(event_params)
format.html { redirect_to @event, notice: 'Event was successfully updated.' }
format.json { render :show, status: :ok, location: @event }
else
format.html { render :edit }
format.json { render json: @event.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch_event\n user_id = params[\"user_id\"]\n group_id = params[\"group_id\"]\n event_id = params[\"event_id\"]\n\n #TODO Handle 404 if event not found\n event = Event.find(event_id)\n\n json_body = JSON.parse(request.body.read)\n\n @@event_service.patch_event(j... | [
"0.752944",
"0.73721",
"0.71765804",
"0.7171193",
"0.71704644",
"0.7142285",
"0.7095896",
"0.70823616",
"0.70823616",
"0.705728",
"0.70204586",
"0.6989217",
"0.6982309",
"0.69782525",
"0.69601846",
"0.69542354",
"0.69542354",
"0.6952027",
"0.6920712",
"0.6920712",
"0.6920712"... | 0.0 | -1 |
DELETE /events/1 DELETE /events/1.json | def destroy
@event.destroy
respond_to do |format|
format.html { redirect_to events_url, notice: 'Event was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @event = Event.using(:shard_one).find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_... | [
"0.76929694",
"0.7688217",
"0.7688217",
"0.7688217",
"0.7681325",
"0.7585923",
"0.75685203",
"0.7560765",
"0.7541314",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.75410026",
"0.... | 0.0 | -1 |
convert angle into radian | def to_rad(angle)
angle * Math::PI / 180
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def radian_angle\n @angle * Math::PI / 180.0\n end",
"def deg2rad(angle)\n angle * (Math::PI / 180.0)\n end",
"def rad2rad(rad)\r\n remt(rad, PI2)\r\n end",
"def to_rad\n self * Math::PI / 180\n end",
"def grados2radianes(alfa)\n\t\treturn ((alfa*Math::PI)/180)\n\tend",
"def d... | [
"0.8188487",
"0.81217587",
"0.80756223",
"0.79066086",
"0.7888177",
"0.7733667",
"0.7690215",
"0.7642279",
"0.7455517",
"0.7417873",
"0.7374782",
"0.73061264",
"0.72938514",
"0.72599244",
"0.70856446",
"0.70856446",
"0.70626193",
"0.7046213",
"0.7024125",
"0.70218194",
"0.700... | 0.842279 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_event
@event = Event.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 event_params
params.require(:event).permit(:name, :description, :event_image, :venue, :location_lati, :location_long, :category, :subcategories, :cost, :date, :time, :address)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981537",
"0.67835593",
"0.6748275",
"0.67436063",
"0.6736311",
"0.65937173",
"0.6503359",
"0.6498499",
"0.6482832",
"0.6478776",
"0.645703",
"0.6439998",
"0.63802195",
"0.6377008",
"0.6366287",
"0.632018",
"0.63016284",
"0.63011277",
"0.62932974",
"0.62919617",
"0.6290564... | 0.0 | -1 |
Unshift this log_hash to the top of the session_info array | def to_hash
log_hash = {
'date' => @date,
'duration' => @duration,
'contents' => @contents,
'notes' => {
'q1' => @q1,
'q2' => @q2,
'q3' => @q3
}
}
return log_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append_info_to_payload(payload)\n super\n payload.merge!(Logstasher.payload_from_request( request ))\n payload.merge!( { session: session } )\n if logged_in?\n payload.merge!(Logstasher.payload_from_user( current_user ))\n end\n end",
"def prepend(hash_stack)\n @stack.unshift *has... | [
"0.5581232",
"0.52753687",
"0.52623487",
"0.51862454",
"0.51808614",
"0.5158661",
"0.50765455",
"0.5012979",
"0.5009293",
"0.4991338",
"0.49580652",
"0.49547216",
"0.49088234",
"0.48754597",
"0.4873559",
"0.4868562",
"0.4861445",
"0.4838951",
"0.4821234",
"0.4819764",
"0.4796... | 0.0 | -1 |
It is meant to answer exercise 2 question of Week 10, Prof. Kakimura's Information class. In the interest of not plagarizing, I would like to say that in my confusion I looked up this topic on StackOverflow and came across this page ( with rather inspiring code. | def min_index(a,i)
minimum = 0
for i in 1..(a.length())
if array[i]<array[0]
minimum = i
end
end
return minimum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exercise_119 (number)\n end",
"def input_students\n # Exercise 7 - Ask for both name and cohort and check conditions\n def enter_info(instruction)\n # Do a loop until user inputs correct value\n while true do\n puts instruction\n # Exercise 10 - Use another method to get rid of last ch... | [
"0.6504072",
"0.6044925",
"0.6025884",
"0.60155064",
"0.5992971",
"0.5958038",
"0.58771497",
"0.58520645",
"0.58125186",
"0.5731678",
"0.57071084",
"0.5668288",
"0.5662267",
"0.56603974",
"0.5651699",
"0.56427264",
"0.561013",
"0.5548985",
"0.55343604",
"0.55166817",
"0.54705... | 0.0 | -1 |
recomputes the sources and stores them | def sources
@sources = Dir.glob(File.join(@test_cases_path,"**","*.txt")).sort
@sources
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_sources\n SOURCES.each_pair do |suite, url|\n prepare_source_for(url, @freshen)\n end\n end",
"def reload!\n @sources.each {|k,s,v| do_load_source(k,s,v)}\n end",
"def run\n Laze.debug 'Starting source processing'\n target.reset\n store.each do |item|\n ... | [
"0.7342347",
"0.6772982",
"0.6438325",
"0.64239895",
"0.62638587",
"0.62148726",
"0.6212401",
"0.61977756",
"0.6143289",
"0.61194044",
"0.6117721",
"0.6111869",
"0.609418",
"0.6094128",
"0.60406435",
"0.6035261",
"0.601409",
"0.6009558",
"0.59570915",
"0.5945168",
"0.59015334... | 0.0 | -1 |
takes a block argument which is called back by each result | def run_tests(&block)
@sources.each do |source|
result = test_source(File.absolute_path(source))
block.call({ :source => source, :result => result })
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end"... | [
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186",
"0.80518186"... | 0.0 | -1 |
GET /rows GET /rows.xml | def index
session[:search_filter_info] = {}
@screen = Screen.find(params[:id])
@action_source = params[:action_source] || 'index'
@quick_operation = params[:quick_operation] || 'index'
@filtered_reference = params[:filtered_reference] || {}
@row_ids = []
@row_pattern = Row.find(params[:row_pattern_id].to_i) unless params[:row_pattern_id].nil?
rpp = ApplicationController.current_user.rows_per_page
@pageno = (!@action_source.include?('page_')) ? 1 : params[:pageno].gsub('/','')
case @action_source
when 'index'
options = @quick_operation == 'index' ? Row.filter_by_custom_fields(params[:id].to_i, {}, 'index', false) : {}
@row_ids = options[:filtered_row_ids] || []
@row_ids_wo_limit = options[:filtered_row_ids_wo_limit] || []
@row_pattern = Row.find(options[:row_pattern_id]) unless options[:row_pattern_id].nil?
session[:sort_field_id_order] = options[:sort_field_id_order] || []
RowsController.store_session_row_ids(session.session_id, @screen.id, @row_ids, @row_ids_wo_limit)
when 'search', 'page_search', 'page_index'
session[:search_filter_info] = {}
@filtered_reference.each do |key, other|
cf = CustomField.find(key)
case cf
when CustomFields::TextField
fieldValue = other
session[:search_filter_info][cf.name] = fieldValue
when CustomFields::Reference
fieldValue = Cell.find(:first, :conditions => {:row_id => other.values}).value
session[:search_filter_info][cf.name] = fieldValue
when CustomFields::DateTimeField
count = other.length
i=0
for i in 0..(count-1)
fieldDate = other.keys[i]
fieldValue = other.values[i]
session[:search_filter_info][fieldDate] = fieldValue
end
else
fieldValue = other
a=10
end
end
screen_id = params[:request_id] || @screen.id
purge = !params[:request_id].nil?
@row_ids = RowsController.get_session_row_ids(session.session_id, screen_id.to_i, purge)
if params.has_key?(:sort_field_id)
session[:sort_field_id_order] = Row.reorder_field_sorting(session[:sort_field_id_order], params[:sort_field_id])
@row_ids = Row.sort(@row_ids, session[:sort_field_id_order])
RowsController.store_session_row_ids(session.session_id, @screen.id, @row_ids)
end
end
@sort_field_id_order = session[:sort_field_id_order]
@row_ids ||= []
@row_count = @row_ids.size
#Page generator
pageno_from = (rpp*(@pageno.to_i-1))
pageno_to = ((rpp*@pageno.to_i)-1)
@maxpage = (@row_ids.size.to_f / rpp).ceil
@row_ids = @row_ids[pageno_from..pageno_to] || []
@rows = @screen.rows.find(:all,
:conditions => {
:rows => { :id => @row_ids }
}
)
@rows.sort!{|a, b| @row_ids.index(a.id) <=> @row_ids.index(b.id)}
GC.start
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @rows }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rows\n render 'rows.html'\n end",
"def row(row_id); get(\"#{link('rows')}/#{row_id}\"); end",
"def rows\r\n @all_rows\r\n end",
"def rows\n @rows\n end",
"def rows\n @rows\n end",
"def rows\n @rows\n end",
"def rows\n @rows\n end",
"def rows\n return @row... | [
"0.6413202",
"0.6403182",
"0.63217473",
"0.62903666",
"0.6270877",
"0.6270877",
"0.6270877",
"0.61829215",
"0.6097462",
"0.6054289",
"0.59701735",
"0.59487486",
"0.5944638",
"0.59300935",
"0.58696544",
"0.58170253",
"0.57566464",
"0.5756029",
"0.5750333",
"0.5750333",
"0.5736... | 0.0 | -1 |
GET /rows/1 GET /rows/1.xml | def show
@row = Row.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @row }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def row(row_id); get(\"#{link('rows')}/#{row_id}\"); end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def show\n @datashows = Datashow.find(params[:id])\n\n respond_to do ... | [
"0.6468013",
"0.58220077",
"0.5796088",
"0.57727957",
"0.5766898",
"0.5766898",
"0.5700217",
"0.5696157",
"0.5677216",
"0.5623952",
"0.56088895",
"0.5596446",
"0.5593269",
"0.5592369",
"0.55885434",
"0.55766624",
"0.5574343",
"0.5570168",
"0.5565081",
"0.5565081",
"0.556031",... | 0.62354 | 1 |
GET /rows/new GET /rows/new.xml | def new
@screen = Screen.find(params[:id])
@row = HeaderRow.new(:screen_id => @screen.id)
@filtered_reference = params[:filtered_reference] || {}
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @row }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @task_row = TaskRow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task_row }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def get... | [
"0.6665572",
"0.66210467",
"0.6539119",
"0.64179224",
"0.6272423",
"0.62522334",
"0.6196304",
"0.61499584",
"0.6144718",
"0.6140753",
"0.6130457",
"0.61265266",
"0.612116",
"0.6119578",
"0.61002594",
"0.60907435",
"0.6075035",
"0.60455763",
"0.6034289",
"0.60233486",
"0.60071... | 0.0 | -1 |
POST /rows POST /rows.xml | def create
@row = HeaderRow.save(params)
respond_to do |format|
format.html # create.html.erb
format.xml { render :xml => @row }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batch_modify_rows(action, rows, per_page=100)\n if not per_page.is_a? Fixnum or not per_page > 0\n raise VeritableError.new(\"Batch upload or delete must have integer page size greater than 0.\")\n end\n batch = []\n rows.each do |row|\n Util.check_row(row)\n batch.push... | [
"0.59664047",
"0.5861051",
"0.5593458",
"0.54831976",
"0.5367803",
"0.53363127",
"0.52645123",
"0.5258665",
"0.51800036",
"0.51765615",
"0.51674116",
"0.5113631",
"0.5076991",
"0.50438255",
"0.5033215",
"0.50232726",
"0.50009197",
"0.49986017",
"0.4996895",
"0.4938371",
"0.49... | 0.5322555 | 6 |
PUT /rows/1 PUT /rows/1.xml | def update
@row = Row.find(params[:id])
respond_to do |format|
if @row.update_attributes(:remark => params[:remark])
@cells = params[:cells]
@cells.each do |field_id,value|
@cell = Cell.find(:first, :conditions => ['row_id = ? and field_id = ?', @row.id , field_id])
if @cell == nil
Cell.new(:row_id => @row.id, :field_id => field_id, :value => value).save
else
@cell.update_attributes(:row_id => @row.id, :field_id => field_id, :value => value)
end
end
forward_to_front_desk :format => format, :object => @row, :screen_id =>@row.screen_id
else
back_to_operation_form :format => format, :action => 'edit', :object_errors => @row.errors
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def batch_upload_rows(rows, per_page=100); batch_modify_rows('put', rows, per_page); end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n r... | [
"0.62992954",
"0.61409783",
"0.5824773",
"0.5819761",
"0.57864124",
"0.5729437",
"0.56530464",
"0.5637884",
"0.55770445",
"0.554965",
"0.5521953",
"0.551672",
"0.54710233",
"0.54595786",
"0.5441335",
"0.53758335",
"0.53758335",
"0.52860487",
"0.5282932",
"0.5271425",
"0.52632... | 0.5445404 | 14 |
Example from another LS member | def swapcase(string)
string.chars.map {|c| c == c.upcase ? c.downcase : c.upcase}.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def example_passed(example)\n end",
"def example\n @example ||= example_override\n end",
"def usage; end",
"def usage; end",
"def lab\n # STUB\n end",
"def example(example) #:doc:\n return unless Apipie.active_dsl?\n Apipie.add_example(example)\n end",
"def eg(name =... | [
"0.64237046",
"0.6148968",
"0.6121934",
"0.6121934",
"0.5989123",
"0.59646344",
"0.5806157",
"0.576811",
"0.576811",
"0.576811",
"0.576811",
"0.576811",
"0.5762931",
"0.5698781",
"0.5689984",
"0.56871474",
"0.5624785",
"0.5585145",
"0.5529111",
"0.5524651",
"0.55181485",
"0... | 0.0 | -1 |
this method notifies the user a new analisy event | def user_event_analisys(user, event)
@user = user
@event = event
@meeting = user.meetings.find_by(event: event)
mail(to: @user.email, subject: t('user_event_analisys', scope: 'message.email.subjects')) if @user.email.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def acknowledged_event(user,event)\n @greeting = \"Hi\"\n @event = event\n mail to: user.email\n end",
"def event; end",
"def event; end",
"def event; end",
"def notify\n end",
"def create\n @event = Event.find(params[:attended_event_id])\n if current_user.attend(@event)\n fla... | [
"0.68957365",
"0.6646867",
"0.6646867",
"0.6646867",
"0.6635636",
"0.65104336",
"0.64653444",
"0.64395034",
"0.6338823",
"0.63362455",
"0.63362455",
"0.6304962",
"0.6301756",
"0.62648666",
"0.62400764",
"0.62400764",
"0.62400764",
"0.62400764",
"0.62400764",
"0.62400764",
"0.... | 0.6041477 | 32 |
this method notifies the user a new visit event | def user_event_visit(user, event)
@user = user
@event = event
@meeting = user.meetings.find_by(event: event)
mail(to: @user.email, subject: t('user_event_visit', scope: 'message.email.subjects')) if @user.email.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visit\n self.update(last_visit: DateTime.now);\n self.update(visit_count: (self.visit_count + 1));\n end",
"def new_visit\n visit = Visit.find_by(vis_type: 'TV')\n UserMailer.new_visit(visit)\n end",
"def add_visit\n self.visits += 1\n self.date_last_visit = DateTime.now\n end",
... | [
"0.71183974",
"0.67220324",
"0.6346431",
"0.6289727",
"0.6224122",
"0.613647",
"0.6110393",
"0.6035355",
"0.5973513",
"0.5943135",
"0.58394134",
"0.5809386",
"0.5805647",
"0.5773279",
"0.57558066",
"0.57520026",
"0.574163",
"0.574163",
"0.574163",
"0.574163",
"0.5731923",
"... | 0.63359 | 3 |
this method notifies the user a new event | def user_event_confirmed(user, event)
@user = user
@event = event
meeting = user.meetings.find_by(event: event)
attachments.inline['prenotazione.ics'] = meeting.ical.to_ical if meeting.confirmed?
mail(to: @user.email, subject: t('user_event_modified', scope: 'message.email.subjects') + ' ' + (l event.date_on)) if user.email.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def acknowledged_event(user,event)\n @greeting = \"Hi\"\n @event = event\n mail to: user.email\n end",
"def new_event(user,event)\n @greeting = \"Hi\"\n @event = event\n\n mail to: user.email\n end",
"def event; end",
"def event; end",
"def event; end",
"def new_event(event)\n # @g... | [
"0.7072374",
"0.70721227",
"0.6928551",
"0.6928551",
"0.6928551",
"0.68989295",
"0.66684985",
"0.66242516",
"0.66161937",
"0.6615172",
"0.65598845",
"0.6533328",
"0.65123487",
"0.639797",
"0.639797",
"0.639797",
"0.639797",
"0.639797",
"0.639797",
"0.639797",
"0.639797",
"0... | 0.0 | -1 |
Serves predictions for the buyers | def predictions
raise "Err"
buyer_suggestions = PropertyBuyer.suggest_buyers(params[:str]).select([:id, :name, :image_url]).limit(20)
render json: buyer_suggestions, status: 200
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict\n\t\t@bio = Bio.where(:user_id => current_user.id).last \n\n\t\t# Game_date and @players transformed to JSON and send to API in order to fetch player predictions\n\t\t@game_date = params[:game_date]\n\t\t@players = params[:players] \n\n\t\t# API Returns player predictions\n\t\t\t#first look in databas... | [
"0.66308594",
"0.65091336",
"0.6460537",
"0.6067307",
"0.6058793",
"0.6032062",
"0.5990188",
"0.5979455",
"0.5977669",
"0.59733355",
"0.5946819",
"0.59376407",
"0.58779806",
"0.57795596",
"0.5755886",
"0.5754334",
"0.5754334",
"0.57266814",
"0.57213825",
"0.5720535",
"0.57189... | 0.6594821 | 1 |
buyer tracking history curl XGET H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo4OCwiZXhwIjoxNTAzNTEwNzUyfQ.7zo4a8g4MTSTURpU5kfzGbMLVyYN_9dDTKIBvKLSvPo" ' | def tracking_history
buyer = user_valid_for_viewing?('Buyer')
if !buyer.nil?
events = Events::Track.where(buyer_id: buyer.id).order("created_at desc")
results = events.map do |event|
{
udprn: event.udprn,
hash_str: event.hash_str,
type_of_tracking: Events::Track::REVERSE_TRACKING_TYPE_MAP[event.type_of_tracking],
created_at: event.created_at,
tracking_id: event.id
}
end
render json: results, status: 200
else
render json: { message: 'Authorization failed' }, status: 401
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_wechat_access_token\n res = RestClient.get \"https://foodtrust.cn/wx/get-access-token?badge=#{ENV['RDS_AGENT']}\"\n #ap res.code; res.cookies; ap res.headers; ap res.body\n return JSON.parse(res.body)['access_token']\nend",
"def get_json_bitbucket_action header\n header['x-event-key'][0]\n end... | [
"0.5797186",
"0.5700164",
"0.56709397",
"0.5640822",
"0.5569054",
"0.54849124",
"0.5482643",
"0.54783344",
"0.5473061",
"0.5461563",
"0.5458975",
"0.54404914",
"0.5436548",
"0.54051435",
"0.5400448",
"0.5377582",
"0.5368418",
"0.53604376",
"0.5323719",
"0.5309286",
"0.5294859... | 0.6094292 | 0 |
Get tracking stats for a buyer curl XGET H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0MywiZXhwIjoxNDg1NTMzMDQ5fQ.KPpngSimK5_EcdCeVj7rtIiMOtADL0o5NadFJi2Xs4c" " | def tracking_stats
buyer = @current_user
property_tracking_count = Events::Track.where(buyer_id: buyer.id).where(type_of_tracking: Events::Track::TRACKING_TYPE_MAP[:property_tracking]).count
street_tracking_count = Events::Track.where(buyer_id: buyer.id).where(type_of_tracking: Events::Track::TRACKING_TYPE_MAP[:street_tracking]).count
locality_tracking_count = Events::Track.where(buyer_id: buyer.id).where(type_of_tracking: Events::Track::TRACKING_TYPE_MAP[:locality_tracking]).count
stats = {
type: (buyer.is_premium? ? 'Premium' : 'Standard'),
locality_tracking_count_limit: Events::Track::BUYER_LOCALITY_PREMIUM_LIMIT[buyer.is_premium.to_s],
street_tracking_count_limit: Events::Track::BUYER_STREET_PREMIUM_LIMIT[buyer.is_premium.to_s],
property_tracking_count_limit: Events::Track::BUYER_PROPERTY_PREMIUM_LIMIT[buyer.is_premium.to_s],
locality_tracking_count: locality_tracking_count,
property_tracking_count: property_tracking_count,
street_tracking_count: street_tracking_count
}
render json: stats, status: 200
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def usage\n @headers['x-ratelimit-usage']\n end",
"def get_member_brief_stats(custid)\n res = $client.get(\"/membersite/member/CareerStats.do?custid=#{custid}\", $headers)\n start = res.body.index('buf = \\'{\"memberSince\"') + 7\n length = res.body.index(\"MemberProfile.driver = extractJSON\") - ... | [
"0.629435",
"0.62524647",
"0.6112888",
"0.6063808",
"0.5868",
"0.58195317",
"0.57700455",
"0.5760547",
"0.5760547",
"0.5737094",
"0.5737094",
"0.5677557",
"0.5658288",
"0.564761",
"0.56249946",
"0.5598312",
"0.55890745",
"0.55623746",
"0.5556137",
"0.5533361",
"0.5524257",
... | 0.64779234 | 0 |
Get tracking filters and find details of properties in type of tracking TODO: Net HTTP calls made with hardcoded hostnames to be removed TODO: tracking id should be returned or not? | def tracking_details
buyer = @current_user
type_of_tracking = (params[:type_of_tracking] || "property_tracking").to_sym
if type_of_tracking == :property_tracking
udprns = Events::Track.where(buyer_id: buyer.id).where(type_of_tracking: Events::Track::TRACKING_TYPE_MAP[:property_tracking]).pluck(:udprn)
api = PropertySearchApi.new(filtered_params: {})
body = api.fetch_details_from_udprns(udprns)
render json: {property_details: body}, status: 200
else
if params["hash_str"].present?
body = Oj.load(Net::HTTP.get(URI.parse(URI.encode("http://52.66.124.42/api/v0/properties/search?hash_str=#{params['hash_str']}"))))
render json: {property_details: body}, status: 200
else
body = []
search_hashes = Events::Track.where(buyer_id: buyer.id).where(type_of_tracking: Events::Track::TRACKING_TYPE_MAP[type_of_tracking]).pluck(:hash_str).compact
search_hashes.each do |search_hash|
### TODO: Fix this. Use internal methods rather than calling the api
body = Oj.load(Net::HTTP.get(URI.parse(URI.encode("http://api.prophety.co.uk/api/v0/properties/search?hash_str=#{search_hash}")))) + body
end
render json: {search_hashes: search_hashes, property_details: body}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trackers(query, type=nil)\n if type.nil?\n is_valid_with_error(__method__, [:ipv4, :domain], query)\n if domain?(query)\n query = normalize_domain(query)\n end\n get('host-attributes/trackers', {'query' => query})\n else\n is_valid_with_error(__method__, [:... | [
"0.597705",
"0.59144413",
"0.5735036",
"0.5617689",
"0.54666567",
"0.5431689",
"0.54226965",
"0.5419066",
"0.53725445",
"0.5345034",
"0.5329371",
"0.5322544",
"0.5312536",
"0.52893865",
"0.5265697",
"0.5249971",
"0.5234865",
"0.5217012",
"0.52111447",
"0.5188541",
"0.51814127... | 0.65677255 | 0 |
Edit tracking details curl XPOST H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0MywiZXhwIjoxNDg1NTMzMDQ5fQ.KPpngSimK5_EcdCeVj7rtIiMOtADL0o5NadFJi2Xs4c" " | def edit_tracking
buyer = @current_user
destroyed = Events::Track.where(id: params[:tracking_id].to_i).last.destroy
render json: { message: 'Destroyed tracking request' }, status: 200
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tracking_params\n params.permit(:location, :trip_request_id)\n end",
"def post_curl\n `curl -X \"POST\" -H \"Authorization: Basic #{_encode}\" -d grant_type=client_credentials https://accounts.spotify.com/api/token`\n end",
"def tracking_params\n params.require(:tracking).permit(:content, ... | [
"0.540576",
"0.53994876",
"0.5268931",
"0.52506155",
"0.52359056",
"0.52315164",
"0.5205049",
"0.5192182",
"0.51643455",
"0.51627517",
"0.5141517",
"0.5140408",
"0.5091574",
"0.5076165",
"0.5075412",
"0.5070239",
"0.50637466",
"0.5051737",
"0.50487304",
"0.5031082",
"0.498484... | 0.5718332 | 0 |
Stripe agents subscription recurring payment curl XPOST H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo4OCwiZXhwIjoxNTAzNTEwNzUyfQ.7zo4a8g4MTSTURpU5kfzGbMLVyYN_9dDTKIBvKLSvPo" ' | def remove_subscription
buyer = @current_user
customer_id = buyer.stripe_customer_id
customer = Stripe::Customer.retrieve(customer_id)
subscription.delete
render json: { message: 'Unsubscribed succesfully' }, status: 200
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_subscription\n session[:merchant_subscription_id] = 'User' + sprintf('%03d', rand(1000)) + 'Subscription' + sprintf('%04d', rand(10000))\n\n # prepare payload\n data = {\n :Amount => params[:product] == '1' ? 1.99 : 3.99,\n :Category => 1,\n :Channel => 'MOBILE_WEB',\n :Description => 'Wo... | [
"0.672462",
"0.65684134",
"0.6528255",
"0.64397657",
"0.6291405",
"0.6224515",
"0.6172476",
"0.6158918",
"0.6122615",
"0.61010516",
"0.60559887",
"0.6049334",
"0.60405326",
"0.6034719",
"0.60239387",
"0.6019898",
"0.60170716",
"0.60159814",
"0.60136545",
"0.5983511",
"0.59758... | 0.0 | -1 |
Info about the premium charges monthly curl XGET ' | def info_premium
render json: { value: (PropertyBuyer::PREMIUM_COST*100) }, status: 200
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def credits\n return nil unless have_key?\n url = \"/v1/credits\"\n #Hashie::Mash.new(\n self.class.post(url, :headers => headers_for(url)).parsed_response\n end",
"def show(charge_token)\n api_response(api_get(\"#{PATH}/#{charge_token}\"))\n end",
"def billing\n request('billin... | [
"0.56957513",
"0.56536996",
"0.5617652",
"0.55346733",
"0.54489124",
"0.54278827",
"0.54152215",
"0.5404938",
"0.5353512",
"0.53332824",
"0.53332824",
"0.5309007",
"0.5282927",
"0.52481157",
"0.5220851",
"0.5192615",
"0.5178005",
"0.51483846",
"0.5146838",
"0.51355654",
"0.51... | 0.56641144 | 1 |
Buyer's calendar events curl XGET H "ContentType: application/json" H "Authorization: zbdxhsaba" ' | def buyer_calendar_events
buyer = @current_user
calendar_events = AgentCalendarUnavailability.where(buyer_id: buyer.id)
render json: { calendar_events: calendar_events }, status: 200
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}/#{id}/events\"))[0]\n end",
"def fetch_events\n params = {'calendarId' => CONFIG[:cal_id], \n 'orderBy' => 'startTime',\n #'timeMax' => Time.utc(CONFIG[:year].to_i + 1, 4, 1).iso8601, \n ... | [
"0.6930128",
"0.6919274",
"0.6847805",
"0.68208474",
"0.6750647",
"0.6661014",
"0.66247123",
"0.65484726",
"0.6530007",
"0.65281224",
"0.6480053",
"0.64560646",
"0.64541453",
"0.638245",
"0.63778245",
"0.63722247",
"0.63270223",
"0.6212991",
"0.61797464",
"0.6168183",
"0.6156... | 0.61791736 | 19 |
Create a new Response object for the given Net::SFTP::Request instance, and with the given data. If there is no :code key in the data, the code is assumed to be FX_OK. | def initialize(request, data={}) #:nodoc:
@request, @data = request, data
@code, @message = data[:code] || FX_OK, data[:message]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response_with_code(code, subcode)\n OpenStruct.new(name: code_name(code), code: code, subcode: subcode)\n end",
"def initialize(data, status_code)\n @data = data\n @statusCode = status_code\n end",
"def _success(data,code)\n status code\n response.headers['Conte... | [
"0.6052174",
"0.55225223",
"0.5418228",
"0.5374258",
"0.5374032",
"0.5334785",
"0.53197",
"0.530625",
"0.5239993",
"0.5202389",
"0.51979333",
"0.5196144",
"0.5151053",
"0.5093738",
"0.5084425",
"0.5067291",
"0.50454336",
"0.4987059",
"0.49779797",
"0.4945318",
"0.49262756",
... | 0.57564694 | 1 |
Retrieve the data item with the given +key+. The key is converted to a symbol before being used to lookup the value. | def [](key)
data[key.to_sym]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(key)\n return @data[key.to_s]\n end",
"def get_item(key)\n self[key]\n end",
"def [](key)\n return nil unless key\n @data[key.to_s] || @data[key.to_sym]\n end",
"def [](key)\n @data[key.to_sym]\n end",
"def [](key)\n @data[key.to_sym]\n end",... | [
"0.7909084",
"0.76764816",
"0.7557976",
"0.74991965",
"0.74991965",
"0.73280144",
"0.7325387",
"0.7305599",
"0.71363986",
"0.71012944",
"0.70948505",
"0.70274526",
"0.70274526",
"0.70274526",
"0.70274526",
"0.70274526",
"0.70274526",
"0.6990239",
"0.6977794",
"0.6977794",
"0.... | 0.7449856 | 5 |
Returns a textual description of this response, including the status code and name. | def to_s
if message && !message.empty? && message.downcase != MAP[code]
"#{message} (#{MAP[code]}, #{code})"
else
"#{MAP[code]} (#{code})"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inspect\n \"<Response(#{status})>\"\n end",
"def to_s\n response = \"#{@status_line}\\n#{@header_fields}\\n#{@body}\"\n end",
"def response_status\n @response[:status]\n end",
"def response_message(response)\n @last_response = response\n 'HTTP Response status... | [
"0.7910374",
"0.7110447",
"0.6915804",
"0.68945146",
"0.68945146",
"0.68792117",
"0.6873165",
"0.682058",
"0.682058",
"0.67896783",
"0.6770691",
"0.67387325",
"0.67046636",
"0.67014253",
"0.6668569",
"0.66589165",
"0.66547424",
"0.66528654",
"0.66178256",
"0.6589557",
"0.6586... | 0.0 | -1 |
Returns +true+ if the status code is FX_OK; +false+ otherwise. | def ok?
code == FX_OK
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ok?\n @status == OK\n end",
"def is_ok?\n code == OK_CODE\n end",
"def success?\n (status_code.to_s =~ /2../) ? true : false\n end",
"def ok?\n @status == 200\n end",
"def is_successful?\n status_code == '0'\n end",
"def success?\n\t\t!!( @status and @status.ex... | [
"0.74520737",
"0.7108859",
"0.7098609",
"0.7043127",
"0.7035813",
"0.6967889",
"0.6966165",
"0.6905255",
"0.6896311",
"0.6857539",
"0.6839474",
"0.6802789",
"0.6788055",
"0.6776196",
"0.6763993",
"0.6753299",
"0.6742513",
"0.6727451",
"0.6726015",
"0.6707289",
"0.6688147",
... | 0.83634627 | 0 |
Returns +true+ if the status code is FX_EOF; +false+ otherwise. | def eof?
code == FX_EOF
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eof?\n @io.eof?\n end",
"def eof?\n @io.eof?\n end",
"def eof?\n @io.eof?\n end",
"def eof?\n return @stream.eof?\n end",
"def eof?\n io.eof?\n end",
"def eof?\n @eof\n end",
"def eof?\n @eof\n end",
"def eof?\n @eof\n end",
... | [
"0.7336073",
"0.7336073",
"0.7336073",
"0.72984815",
"0.72851884",
"0.7255248",
"0.7255248",
"0.7255248",
"0.72539973",
"0.7221933",
"0.7221933",
"0.7221933",
"0.7211516",
"0.71952873",
"0.71592677",
"0.7016629",
"0.6980623",
"0.6976482",
"0.69627213",
"0.69623184",
"0.692446... | 0.8081804 | 0 |
accessors (with input checking) | def temperature=(temperature)
raise ArgumentError unless temperature.is_a?(Data::Temperature)
@temperature = temperature
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input; end",
"def input; end",
"def input; end",
"def input?; @input; end",
"def get_input;\t@input \t\tend",
"def input; @input; end",
"def input; @input; end",
"def read_input; end",
"def input=(_arg0); end",
"def read_input\n end",
"def get_input\n #Get input from the user\ne... | [
"0.749392",
"0.749392",
"0.749392",
"0.7253445",
"0.714534",
"0.7074125",
"0.7074125",
"0.6940484",
"0.68478554",
"0.6809061",
"0.6761475",
"0.65394133",
"0.65347874",
"0.6514947",
"0.6431825",
"0.638621",
"0.63433737",
"0.6277592",
"0.6253407",
"0.62345976",
"0.62123156",
... | 0.0 | -1 |
creates "?" helpers for all attributes (which maps to nil?) | def method_missing(method,*args)
# if the method ends in ?, then strip it off and see if we
# respond to the method without the ?
if (call_method = method.to_s.chomp!("?")) && respond_to?(call_method)
return send(call_method).nil? ? false : true
else
super(method,*args)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nil_if_blank\n NULL_ATTRS.each { |attr| self[attr] = nil if self[attr].blank? }\n end",
"def defaulted_attrs\n given_attrs.reject {|attr| send(\"given_#{attr}?\")}\n end",
"def normalize_blank_values\n attributes.each do |column, value|\n self[column].present? || self[colu... | [
"0.6737692",
"0.6613082",
"0.6535803",
"0.6324057",
"0.6153298",
"0.60936314",
"0.6088683",
"0.6067056",
"0.60546",
"0.6001157",
"0.5961988",
"0.5954428",
"0.59314656",
"0.590819",
"0.58942467",
"0.5890935",
"0.5877964",
"0.586465",
"0.584416",
"0.58357567",
"0.58221275",
"... | 0.0 | -1 |
Faire une copie de sauvegarde sans destruction du fichier | def make_rescue path
FileUtils::cp path, path_rescue(path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy\n \n end",
"def copy(io, context)\n super\n if io.respond_to?(:path) && io.path && delete_raw? && context[:delete] != false\n begin\n File.delete(io.path)\n rescue Errno::ENOENT\n # file might already be deleted by the moving plugin\n... | [
"0.6650017",
"0.6411355",
"0.6312308",
"0.6312308",
"0.6194134",
"0.6085993",
"0.60720146",
"0.60692465",
"0.6059849",
"0.60560054",
"0.60504955",
"0.5918213",
"0.5918213",
"0.5918213",
"0.5918213",
"0.5902717",
"0.58884114",
"0.5834196",
"0.58204716",
"0.5771379",
"0.5771379... | 0.0 | -1 |
GET /polling_sessions/1 GET /polling_sessions/1.json | def show
@polling_session = PollingSession.find(params[:id])
@polls = @polling_session.polls
authorize! :read, PollingSession
respond_to do |format|
format.html # show.html.erb
format.json { render json: @polling_session }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_poll_sessions_for_poll(poll_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n # set default values and merge with input\n options = underscored_me... | [
"0.6730336",
"0.6657565",
"0.65170884",
"0.64331716",
"0.6379616",
"0.633456",
"0.63025635",
"0.62377775",
"0.6209552",
"0.6168578",
"0.6120831",
"0.60957116",
"0.6078542",
"0.60583705",
"0.60091716",
"0.598851",
"0.59638804",
"0.59597915",
"0.5951662",
"0.5948003",
"0.593618... | 0.6612596 | 2 |
GET /polling_sessions/new GET /polling_sessions/new.json | def new
@polling_session = PollingSession.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @polling_session }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @polling_session = PollingSession.new(params[:polling_session])\n\n respond_to do |format|\n if @polling_session.save\n format.html { redirect_to @polling_session, notice: 'Polling session was successfully created.' }\n format.json { render json: @polling_session, status: :cre... | [
"0.7200673",
"0.6922426",
"0.68400216",
"0.679016",
"0.66888666",
"0.6647991",
"0.63777757",
"0.63396496",
"0.6328666",
"0.6305696",
"0.6293725",
"0.62511176",
"0.6195757",
"0.61729836",
"0.6103391",
"0.60841775",
"0.6060703",
"0.6017639",
"0.59978026",
"0.5979473",
"0.597579... | 0.80017734 | 0 |
POST /polling_sessions POST /polling_sessions.json | def create
@polling_session = PollingSession.new(params[:polling_session])
respond_to do |format|
if @polling_session.save
format.html { redirect_to @polling_session, notice: 'Polling session was successfully created.' }
format.json { render json: @polling_session, status: :created, location: @polling_session }
else
format.html { render action: "new" }
format.json { render json: @polling_session.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @polling_session = PollingSession.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @polling_session }\n end\n end",
"def create_single_poll_session(poll_id,poll_sessions__course_id__,opts={})\n query_param_keys = [\n \n ]\n\n ... | [
"0.6141677",
"0.6007205",
"0.59136736",
"0.59000343",
"0.58953667",
"0.58930206",
"0.58599037",
"0.58243406",
"0.5788784",
"0.57812786",
"0.5772482",
"0.5752685",
"0.5741058",
"0.57021147",
"0.57020754",
"0.56545407",
"0.56434214",
"0.5627708",
"0.5618583",
"0.55769926",
"0.5... | 0.6964131 | 0 |
PUT /polling_sessions/1 PUT /polling_sessions/1.json | def update
@polling_session = PollingSession.find(params[:id])
respond_to do |format|
if @polling_session.update_attributes(params[:polling_session])
format.html { redirect_to @polling_session, notice: 'Polling session was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @polling_session.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_single_poll_session(poll_id,id,poll_sessions__course_id__,poll_sessions__course_section_id__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :poll_sessions__course_id__,\n :poll_sessions__course_section_id__,\n :poll_sessions__has_public_result... | [
"0.62015176",
"0.6142145",
"0.6055531",
"0.6052481",
"0.5942413",
"0.59289163",
"0.58133686",
"0.5766334",
"0.5756454",
"0.57487214",
"0.57074255",
"0.5697528",
"0.56855774",
"0.5656672",
"0.5631655",
"0.56300336",
"0.5626987",
"0.56072384",
"0.56072384",
"0.5606675",
"0.5598... | 0.68678343 | 0 |
DELETE /polling_sessions/1 DELETE /polling_sessions/1.json | def destroy
@polling_session = PollingSession.find(params[:id])
@polling_session.destroy
respond_to do |format|
format.html { redirect_to polling_sessions_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_session\n request.method = :get\n request.uri = '_session'\n Couchdbtools.execute(request)\n end",
"def destroy\n @yoga_session = YogaSession.find(params[:id])\n @yoga_session.destroy\n\n respond_to do |format|\n format.html { redirect_to yoga_sessions_url }\n form... | [
"0.6872393",
"0.6747178",
"0.66962314",
"0.6695935",
"0.66853786",
"0.66851443",
"0.66586506",
"0.6655968",
"0.66477543",
"0.6643424",
"0.66171086",
"0.6616865",
"0.6606987",
"0.6604662",
"0.6598259",
"0.65948504",
"0.65540737",
"0.65282935",
"0.652107",
"0.65035516",
"0.6440... | 0.7535422 | 0 |
Extract url from json and get files | def download
URI.extract(json, ['http', 'https']).each do |url|
get_asset(url)
end
json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_at(url)\n JSON.parse(open(url).read, symbolize_names: true)[:objects]\nend",
"def get_urls( search_url )\n urls = []\n result_json = parse_json( search_url )\n result_json['items'].each do |item|\n urls << item['url']\n end\n\n return urls\nend",
"def get_file(url); end",
"def get_json(url)... | [
"0.67730147",
"0.67432445",
"0.6627193",
"0.66143686",
"0.64659387",
"0.64624846",
"0.6248586",
"0.6248171",
"0.62244123",
"0.6207111",
"0.620166",
"0.609987",
"0.6023666",
"0.6012393",
"0.6009479",
"0.6003042",
"0.5988958",
"0.5979974",
"0.59771436",
"0.59398866",
"0.5939069... | 0.69814074 | 0 |
download a file and writes it | def get_asset(url)
uri = URI.parse(url)
unless File.exists?(File.join(['public', uri.path]))
FileManager.new(['public', uri.path], Downloader.get(url, URI.decode_www_form(uri.query)), true).write!
end
replace_url(url, uri.path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_file_from_url(file, url)\n Net::HTTP.start(@download.base_url) do |http|\n begin\n http.request_get(url) do |resp|\n resp.read_body do |segment|\n file.write(segment)\n end\n end\n ensure\n file.close\n end\n end... | [
"0.80339223",
"0.78283",
"0.78141093",
"0.76428866",
"0.7613416",
"0.75650495",
"0.7543139",
"0.75342065",
"0.7490002",
"0.7486346",
"0.7480046",
"0.74708503",
"0.74389774",
"0.73595786",
"0.73448706",
"0.7265237",
"0.7254644",
"0.72170925",
"0.711131",
"0.7100639",
"0.709112... | 0.0 | -1 |
get ip address of server | def local_ip
Synchronizer.config['local_url']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ip\n if ifconfig =~ /inet addr:([0-9.]+)/\n $1\n else\n \"0.0.0.0\"\n end\n end",
"def get_ip_address\n request.remote_ip\n end",
"def get_ip_address \t\t\t\n\t\trequest.remote_ip \n\tend",
"def server_ip_address\n $tracer.trace(__method__)\n begin\n ... | [
"0.7852457",
"0.77663803",
"0.77464926",
"0.77085835",
"0.7697207",
"0.7690139",
"0.7667996",
"0.7603963",
"0.7591252",
"0.75591755",
"0.7552053",
"0.7506804",
"0.7501567",
"0.7440655",
"0.741831",
"0.74054486",
"0.7387019",
"0.7387019",
"0.7387019",
"0.7387019",
"0.7387019",... | 0.0 | -1 |
GET /solicitacao_tipos GET /solicitacao_tipos.json | def index
@solicitacao_tipos = SolicitacaoTipo.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n tips = Tip.all\n json_response(tips)\n end",
"def show\n @tip_so = TipSo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tip_so }\n end\n end",
"def show\n json_response(@tip)\n end",
"def tecnicos_p... | [
"0.65108067",
"0.64022475",
"0.61986303",
"0.61943024",
"0.61738473",
"0.60719556",
"0.60466915",
"0.6017275",
"0.5969186",
"0.5969186",
"0.5964207",
"0.59610367",
"0.59297687",
"0.59143305",
"0.591277",
"0.590865",
"0.59049314",
"0.58742553",
"0.58641595",
"0.5852805",
"0.57... | 0.7046238 | 0 |
GET /solicitacao_tipos/1 GET /solicitacao_tipos/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @solicitacao_tipos = SolicitacaoTipo.all\n end",
"def show\n @tip_so = TipSo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tip_so }\n end\n end",
"def show\n @tipocliente = Tipocliente.find(params[:id])\n\n res... | [
"0.6817256",
"0.6669637",
"0.64503783",
"0.6372201",
"0.6367699",
"0.6265731",
"0.62596667",
"0.6170344",
"0.61276793",
"0.597531",
"0.5974145",
"0.59422886",
"0.5879393",
"0.58658284",
"0.58658284",
"0.58501226",
"0.5815338",
"0.5805142",
"0.579987",
"0.57922894",
"0.5792289... | 0.0 | -1 |
POST /solicitacao_tipos POST /solicitacao_tipos.json | def create
@solicitacao_tipo = SolicitacaoTipo.new(solicitacao_tipo_params)
respond_to do |format|
if @solicitacao_tipo.save
format.html { redirect_to @solicitacao_tipo, notice: 'Solicitacao tipo was successfully created.' }
format.json { render action: 'show', status: :created, location: @solicitacao_tipo }
else
format.html { render action: 'new' }
format.json { render json: @solicitacao_tipo.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @tip_so = TipSo.new(params[:tip_so])\n\n respond_to do |format|\n if @tip_so.save\n format.html { redirect_to @tip_so, notice: 'Tip so was successfully created.' }\n format.json { render json: @tip_so, status: :created, location: @tip_so }\n else\n format.html { re... | [
"0.67034465",
"0.66678816",
"0.65577585",
"0.6449446",
"0.641211",
"0.64117646",
"0.6356537",
"0.6324983",
"0.6288912",
"0.6286157",
"0.6282469",
"0.6250847",
"0.6242328",
"0.6225682",
"0.6209179",
"0.6201209",
"0.61829597",
"0.6163679",
"0.6162684",
"0.61430997",
"0.61374307... | 0.6199879 | 16 |
PATCH/PUT /solicitacao_tipos/1 PATCH/PUT /solicitacao_tipos/1.json | def update
respond_to do |format|
if @solicitacao_tipo.update(solicitacao_tipo_params)
format.html { redirect_to @solicitacao_tipo, notice: 'Solicitacao tipo was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @solicitacao_tipo.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @tip_so = TipSo.find(params[:id])\n\n respond_to do |format|\n if @tip_so.update_attributes(params[:tip_so])\n format.html { redirect_to @tip_so, notice: 'Tip so was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \... | [
"0.68049604",
"0.66864556",
"0.66023237",
"0.6564181",
"0.655705",
"0.65283144",
"0.6523591",
"0.6453579",
"0.6410637",
"0.64080346",
"0.63508874",
"0.6267339",
"0.6209148",
"0.6205629",
"0.62011945",
"0.6186779",
"0.61786264",
"0.6166486",
"0.61635375",
"0.6155421",
"0.61513... | 0.6580395 | 3 |
DELETE /solicitacao_tipos/1 DELETE /solicitacao_tipos/1.json | def destroy
@solicitacao_tipo.destroy
respond_to do |format|
format.html { redirect_to solicitacao_tipos_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @tip_so = TipSo.find(params[:id])\n @tip_so.destroy\n\n respond_to do |format|\n format.html { redirect_to tip_sos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solicitud.destroy\n respond_to do |format|\n format.html { redirect_to solicitu... | [
"0.7579861",
"0.7466454",
"0.74196404",
"0.7383597",
"0.7359379",
"0.7359123",
"0.73443264",
"0.73396087",
"0.73336804",
"0.73320884",
"0.7324677",
"0.7316358",
"0.73079914",
"0.7290945",
"0.72845405",
"0.71892256",
"0.7168368",
"0.71579796",
"0.7135689",
"0.7111101",
"0.7103... | 0.784042 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_solicitacao_tipo
@solicitacao_tipo = SolicitacaoTipo.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 solicitacao_tipo_params
params.require(:solicitacao_tipo).permit(:tipo)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981537",
"0.67835593",
"0.6748275",
"0.67436063",
"0.6736311",
"0.65937173",
"0.6503359",
"0.6498499",
"0.6482832",
"0.6478776",
"0.645703",
"0.6439998",
"0.63802195",
"0.6377008",
"0.6366287",
"0.632018",
"0.63016284",
"0.63011277",
"0.62932974",
"0.62919617",
"0.6290564... | 0.0 | -1 |
GET /u_sers/1 GET /u_sers/1.json | def show
@u_ser = USer.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @u_ser }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @u_sers = USer.all\n end",
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @use... | [
"0.72598606",
"0.64190686",
"0.61925536",
"0.6137131",
"0.6118909",
"0.58885694",
"0.58674437",
"0.584617",
"0.57275486",
"0.57150984",
"0.5712456",
"0.57095677",
"0.57087487",
"0.56723416",
"0.56693363",
"0.5663225",
"0.5655754",
"0.5607923",
"0.5603253",
"0.55927724",
"0.55... | 0.669042 | 1 |
GET /u_sers/new GET /u_sers/new.json | def new
@u_ser = USer.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @u_ser }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @u = U.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @u }\n end\n end",
"def new\n @usr = Usr.new\n \n respond_to do |format|\n format.html # new.html.haml\n format.js # new.js.rjs\n format.xml { render :xml => @usr... | [
"0.7417012",
"0.71170324",
"0.7092639",
"0.70402247",
"0.7038747",
"0.69986254",
"0.6989611",
"0.6915032",
"0.69037205",
"0.68724126",
"0.68586445",
"0.685825",
"0.68405515",
"0.68140286",
"0.680881",
"0.6794129",
"0.67895055",
"0.67843366",
"0.67783564",
"0.67762804",
"0.675... | 0.7504908 | 0 |
POST /u_sers POST /u_sers.json | def create
@u_ser = USer.new(params[:u_ser])
respond_to do |format|
if @u_ser.save
format.html { redirect_to @u_ser, notice: 'U ser was successfully created.' }
format.json { render json: @u_ser, status: :created, location: @u_ser }
else
format.html { render action: "new" }
format.json { render json: @u_ser.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @u_ser = USer.new(u_ser_params)\n\n respond_to do |format|\n if @u_ser.save\n format.html { redirect_to @u_ser, notice: 'U ser was successfully created.' }\n format.json { render :show, status: :created, location: @u_ser }\n else\n format.html { render :new }\n ... | [
"0.634905",
"0.6186928",
"0.57403594",
"0.5651373",
"0.56368405",
"0.5628509",
"0.55825585",
"0.5521971",
"0.5495161",
"0.5338382",
"0.5268426",
"0.5267577",
"0.5261323",
"0.52466214",
"0.52267075",
"0.520776",
"0.5193178",
"0.5183848",
"0.51413196",
"0.51302457",
"0.51100314... | 0.6416255 | 0 |
PUT /u_sers/1 PUT /u_sers/1.json | def update
@u_ser = USer.find(params[:id])
respond_to do |format|
if @u_ser.update_attributes(params[:u_ser])
format.html { redirect_to @u_ser, notice: 'U ser was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @u_ser.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @u_ser.update(u_ser_params)\n format.html { redirect_to @u_ser, notice: 'U ser was successfully updated.' }\n format.json { render :show, status: :ok, location: @u_ser }\n else\n format.html { render :edit }\n format.json { render js... | [
"0.63182807",
"0.6270266",
"0.598554",
"0.58476627",
"0.5657172",
"0.5600045",
"0.55445385",
"0.5544309",
"0.55440676",
"0.5539058",
"0.5495385",
"0.5483849",
"0.54661477",
"0.54532695",
"0.54205054",
"0.5383168",
"0.5339815",
"0.5328165",
"0.532579",
"0.53112024",
"0.5309192... | 0.65416086 | 0 |
DELETE /u_sers/1 DELETE /u_sers/1.json | def destroy
@u_ser = USer.find(params[:id])
@u_ser.destroy
respond_to do |format|
format.html { redirect_to u_sers_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @u_ser.destroy\n respond_to do |format|\n format.html { redirect_to u_sers_url, notice: 'U ser was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @uder.destroy\n respond_t... | [
"0.6946302",
"0.69276553",
"0.667342",
"0.6612868",
"0.65867144",
"0.6580875",
"0.6554371",
"0.65526795",
"0.6550917",
"0.6549767",
"0.654431",
"0.65373445",
"0.6532813",
"0.6529876",
"0.65264964",
"0.65020865",
"0.6501794",
"0.64871585",
"0.64734113",
"0.64729655",
"0.645458... | 0.7272203 | 0 |
devise check to ensure only logged in users can access GET /posts GET /posts.json | def index
@posts = Post.all
# authorize @posts
puts "current project is: #{@current_project.name}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_post_owner\n json_response({ error: 'Not authorized' }, :unauthorized) unless @post.user_id == current_user.id\n end",
"def show\n if user_signed_in?\n\n @post = current_user.posts.find(params[:id])\n \n if @post.user_id == current_user.id\n respond_to do |format|\n ... | [
"0.75213313",
"0.7219987",
"0.7109975",
"0.707588",
"0.7053311",
"0.69760376",
"0.69620776",
"0.6915803",
"0.6891779",
"0.68828577",
"0.6861492",
"0.68146676",
"0.6785645",
"0.6763384",
"0.67630196",
"0.6755915",
"0.6710937",
"0.67034155",
"0.66480917",
"0.66394776",
"0.66246... | 0.0 | -1 |
GET /posts/1 GET /posts/1.json | def show
if request.path != project_post_path(@current_project, @post)
return redirect_to project_post_path(@current_project, @post), :status => :moved_permanently
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def show\n render json: Post.find(params[\"id\"])\n end",
"def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end",
"def show\n @post = Post.find(params[:id])\n\n render json: @post\n end",
... | [
"0.77110183",
"0.73537844",
"0.73433185",
"0.73379177",
"0.73228735",
"0.7293139",
"0.7275997",
"0.7256934",
"0.7161576",
"0.7158913",
"0.71552676",
"0.71552676",
"0.7119547",
"0.7094749",
"0.7094749",
"0.7094749",
"0.70943594",
"0.7071599",
"0.70607626",
"0.70452625",
"0.703... | 0.0 | -1 |
POST /posts POST /posts.json | def create
@post = Post.new(post_params)
# authorize @post
respond_to do |format|
if @post.save
format.html { redirect_to project_posts_path, notice: 'Post was successfully created.' }
format.json { render :show, status: :created, location: @post }
else
format.html { render :new }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n render json: Post.create(params[\"post\"])\n end",
"def create\n respond_with Post.create(params[:posts])\n end",
"def create\n @post = Post.create(post_params)\n render json: @post, serializer: PostSerializer\n end",
"def create\n @post = Post.new(post_params)\n @po... | [
"0.74453115",
"0.73224664",
"0.73065",
"0.7123661",
"0.7014955",
"0.7012768",
"0.69840264",
"0.6938563",
"0.69309723",
"0.6905106",
"0.68197066",
"0.68119097",
"0.67928475",
"0.6792773",
"0.67785394",
"0.67785394",
"0.6762736",
"0.6759516",
"0.67510056",
"0.67350024",
"0.6698... | 0.0 | -1 |
PATCH/PUT /posts/1 PATCH/PUT /posts/1.json | def update
respond_to do |format|
if @post.update(post_params)
format.html { redirect_to project_posts_path, notice: 'Post was successfully updated.' }
format.json { render :show, status: :ok, location: @post }
else
format.html { render :edit }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end",
"def update\n respond_with Post.update(params[:id], params[:posts])\n end",
"def update\n @post = Post.find(params[:id])\n respond_to do |format|\n if @post.update_attributes(params[:post])\n forma... | [
"0.71867543",
"0.7042899",
"0.6774105",
"0.67672604",
"0.6669961",
"0.6649129",
"0.657972",
"0.6556958",
"0.6551495",
"0.6549005",
"0.6535034",
"0.6531995",
"0.6497553",
"0.64958835",
"0.6468818",
"0.64319825",
"0.6428907",
"0.64275557",
"0.64273673",
"0.64193714",
"0.6419366... | 0.0 | -1 |
DELETE /posts/1 DELETE /posts/1.json | def destroy
@post.destroy
respond_to do |format|
format.html { redirect_to project_posts_url, notice: 'Post was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n post = Post.find(params[:id])\n if post.destroy\n render json: {status: \"success\", data: {id: param... | [
"0.8046884",
"0.76902676",
"0.7583626",
"0.75803024",
"0.7568048",
"0.75047046",
"0.75031126",
"0.74750155",
"0.74671036",
"0.74650854",
"0.746482",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_post
@post = Post.friendly.find(params[:id])
# authorize @post
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 post_params
params.require(:post).permit(:name, :description, :project_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.6981537",
"0.67835593",
"0.6748275",
"0.67436063",
"0.6736311",
"0.65937173",
"0.6503359",
"0.6498499",
"0.6482832",
"0.6478776",
"0.645703",
"0.6439998",
"0.63802195",
"0.6377008",
"0.6366287",
"0.632018",
"0.63016284",
"0.63011277",
"0.62932974",
"0.62919617",
"0.6290564... | 0.0 | -1 |
, 64 Dado un arreglo no vacio, duplique los items | def maps(x)
duplicados = x.map { |n| n * 2}
print duplicados
puts
return duplicados
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duplicate_items_from(items)\n transaction do\n items.each do |item|\n transfer_items << item.dup\n end\n end\n end",
"def items; @items.clone end",
"def resize\n old_items = @items\n @items = Array.new(@items.size*2)\n old_items.each do |i|\n if i != nil\n puts ... | [
"0.65675336",
"0.6152339",
"0.58827555",
"0.5850411",
"0.58345705",
"0.5788555",
"0.5754244",
"0.57430786",
"0.57233846",
"0.56722075",
"0.5657133",
"0.5643768",
"0.5532891",
"0.5495206",
"0.54490507",
"0.5437809",
"0.54334766",
"0.5425746",
"0.5425102",
"0.5417686",
"0.54074... | 0.0 | -1 |
triggered while creating a record for first time | def convert_price_to_dollar
self.price = self.price.to_f/100
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_create_save(record); end",
"def enter_created; end",
"def before_create_save(record); end",
"def create\n run_callbacks :create do\n true\n end\n end",
"def after_create; end",
"def before_create()\n end",
"def after_created; end",
"def _create\n true\n ... | [
"0.76792896",
"0.76379",
"0.75934875",
"0.7258986",
"0.7223479",
"0.7212328",
"0.7084132",
"0.70021677",
"0.6964432",
"0.69378865",
"0.6934749",
"0.6932605",
"0.6932605",
"0.69299996",
"0.6881073",
"0.6877005",
"0.68763435",
"0.6803837",
"0.6803837",
"0.6803837",
"0.6803837",... | 0.0 | -1 |
validates_presence_of :name, :title, :message | def update_images(image_ids)
Image.where(id: image_ids).update_all(blog_id: self.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate\n validates_presence([:title, :body])\n end",
"def validate\n validates_presence([:name, :phone])\n end",
"def validate_presence(attribute_name, message = nil)\n value = send(attribute_name)\n if !value || value.to_s.empty?\n append_error(attribute_name, message || :cant_b... | [
"0.7961016",
"0.72607696",
"0.68245965",
"0.6821016",
"0.6810354",
"0.6764489",
"0.67547685",
"0.6706585",
"0.66238576",
"0.66005015",
"0.66005015",
"0.65942824",
"0.6519605",
"0.6492172",
"0.64604485",
"0.63819003",
"0.6364475",
"0.6363069",
"0.63594365",
"0.6353447",
"0.634... | 0.0 | -1 |
Don't bother creating a connection until we need one | def connection
@connection ||= if authenticated?
RestClient::Resource.new(api_uri.to_s, @username, @password)
else
RestClient::Resource.new(api_uri.to_s)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_connection; end",
"def connect_if_connection_initialized\n connection.connect if connection.initialized?\n end",
"def ensure_connection!\n fail \"Must have active connection\" unless connection\n end",
"def ensure_connection!\n fail \"Must have active connection\" unles... | [
"0.7541748",
"0.7487058",
"0.735854",
"0.735854",
"0.735854",
"0.735854",
"0.735854",
"0.735854",
"0.7137877",
"0.7043957",
"0.6962577",
"0.6953826",
"0.68738353",
"0.6847752",
"0.6842711",
"0.6796541",
"0.67583257",
"0.672204",
"0.67161494",
"0.6693824",
"0.6693824",
"0.66... | 0.0 | -1 |
Keep track of the players in play order | def append_player(player)
@players ||= []
@players << player unless @players.include?(player)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def players\n @players ||= []\n end",
"def players\n @players ||= []\n end",
"def assign_order\n num = 1\n self.game_players.each do |player|\n player.username = player.user.username\n player.turn_order = num\n if num == 1\n self.up_next = player.user.usernam... | [
"0.7203553",
"0.7203553",
"0.69835204",
"0.6976748",
"0.6917932",
"0.6899957",
"0.6876158",
"0.67553353",
"0.6734399",
"0.67293537",
"0.67174685",
"0.67142373",
"0.6668544",
"0.6646417",
"0.6596821",
"0.653175",
"0.65066534",
"0.64616036",
"0.64600724",
"0.645983",
"0.6452759... | 0.5941571 | 95 |
from a move (set) check the col & row for a winning move | def check_winner(col,row)
return true if win?
ranges = get_ranges_for(col, row)
return true if ranges.any?{|range| is_winner_on_range?(range) }
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def winning_move?\n winning_moves = [[1,2,3], [4,5,6], [7,8,9], [1,4,7], [2,5,8], [3,6,9], [1,5,9], [3,5,7]]\n winning_moves.each do |set|\n #check game board to see if XXX or OOO combination exists\n if (@board[set[0]] == \"X\") && (@board[set[1]] == \"X\") && (@board[set[2]] == \"X\")\n @w... | [
"0.771016",
"0.74987394",
"0.73713684",
"0.7296509",
"0.72825724",
"0.7278986",
"0.7272849",
"0.71941257",
"0.71807796",
"0.7166739",
"0.71369344",
"0.7125951",
"0.71029353",
"0.7100392",
"0.7067427",
"0.7027524",
"0.702122",
"0.7017957",
"0.7014674",
"0.70119536",
"0.7008903... | 0.0 | -1 |
the winner is defined by having no other values on the range (rows, cols or diagonals) | def is_winner_on_range?(range)
return false unless range.uniq.size == 1 && !range.first.nil?
@winner = range.first
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def out_of_board(row,column)\n (!(0...@rows).include? row) ||\n (!(0...@columns).include? column)\n end",
"def winner\n result = nil\n @field.each do | row | result ||= winner_test(row) end # Horizontal\n @field.transpose.each do | row | result ||= winner_test(row) end # Vertical\n r... | [
"0.7145024",
"0.7131199",
"0.700994",
"0.6911217",
"0.69062406",
"0.6860557",
"0.68375206",
"0.6821963",
"0.680867",
"0.67607576",
"0.67604506",
"0.6669689",
"0.665233",
"0.662261",
"0.660868",
"0.65973854",
"0.65973854",
"0.65973854",
"0.65950155",
"0.6594573",
"0.6570412",
... | 0.6465493 | 29 |
need to figure out how to find tree items that are the same... | def delete_secGrp(groupName,vpc=nil)
start = @serverBranch if vpc == nil or vpc == ""
start = @vpc_serverBranch[vpc] if vpc != nil and vpc != ""
t = @tree.findItem(groupName,start)
if t != nil
p = t.parent
if p != nil
if (p.text() == "Servers" and (vpc == nil or vpc == "")) or
((vpc != nil and vpc != "") and p.text() == vpc)
@tree.removeItem(t)
end
else
puts "Security Group not found in tree"
end
else
puts "Security Group not found in tree"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leaf_similar(root1, root2)\n leaves1 = []\n leaves2 = []\n\n dfs(root1, leaves1)\n dfs(root2, leaves2)\n\n leaves1 == leaves2\nend",
"def findSet(originalname,checkitem) \n if @store[checkitem].is_a?(Integer) then\n #Updating refrence to speed up further query\n if originalname!=checkitem t... | [
"0.66177845",
"0.61900204",
"0.6100806",
"0.60627586",
"0.6042924",
"0.60416543",
"0.60361564",
"0.5958678",
"0.59428614",
"0.58916795",
"0.57454145",
"0.5659736",
"0.5654334",
"0.5620236",
"0.56017274",
"0.5601023",
"0.5600481",
"0.55781376",
"0.5577995",
"0.5545188",
"0.554... | 0.0 | -1 |
GET /u/dashboard/1 GET /u/dashboard/1.json | def dashboard
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @dashboards = current_user.dashboards\n if !params[:detail]\n render json: @dashboards, each_serializer: DashboardSummarySerializer \n else\n render json: @dashboards\n end\n end",
"def dashboard\n __log_activity\n __debug_route\n opt = url_parameters\n fast = opt... | [
"0.73191476",
"0.7042014",
"0.6952365",
"0.68764853",
"0.6840577",
"0.6840577",
"0.683669",
"0.683669",
"0.683669",
"0.683669",
"0.6810283",
"0.67448145",
"0.67432964",
"0.67069924",
"0.66859394",
"0.66765153",
"0.6666256",
"0.6657843",
"0.66410047",
"0.6610535",
"0.6588395",... | 0.679921 | 15 |
GET /u/profile/1 GET /u/profile/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile\n check_auth :profile\n \n response = connection.post do |req|\n req.url '/user/profile'\n req.body = { :format => @format }\n end\n response.body[0]\n end",
"def profile(user_id: '-')\n return get(\"#{API_URI}/#{PROFILE_API_VERSION}/user/#{user_id}/profil... | [
"0.7831829",
"0.76969075",
"0.7562164",
"0.75329024",
"0.7519524",
"0.7519524",
"0.750621",
"0.7501591",
"0.74229556",
"0.7416458",
"0.7401251",
"0.7389491",
"0.7374967",
"0.73513246",
"0.7324969",
"0.7273774",
"0.72464174",
"0.7244626",
"0.7206244",
"0.71958977",
"0.71824324... | 0.0 | -1 |
PATCH/PUT /u/profile/1 PATCH/PUT /u/profile/1.json | def update
if @user.update_with_password(params[:user])
# Sign in the user by passing validation in case his password changed
sign_in @user, :bypass => true if @user.id == current_user.id
flash[:notice] = "User was successfully updated."
end
respond_with @user, location: user_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_profile! (data = {})\n check_auth :update\n \n response = connection.put do |req|\n req.url '/user/update'\n req.body = { :format => @format }.merge(data)\n end\n response\n end",
"def update_profile(body={})\n perform_post(\"/account/update_profile.json\", :bo... | [
"0.74081624",
"0.73876625",
"0.7341647",
"0.72933096",
"0.7292685",
"0.7240915",
"0.7236433",
"0.7210315",
"0.71867067",
"0.71742845",
"0.71742845",
"0.71606743",
"0.71383184",
"0.7136014",
"0.71239114",
"0.7117873",
"0.7117873",
"0.7117873",
"0.7117873",
"0.71102315",
"0.709... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.533008... | 0.0 | -1 |
Old school Roman numerals My attempt. I actually did not get what the Roman Numerals were all about until I checked at the end of the book for some answers. I am sending a note to the author on giving us some sample examples of what the old numerals are like. | def oldrconv number
set = [1,5,10,50,100,500,1000]
x = 0
len = set.length
while x < len
result = number/set[x]
break if result < 1
sres = result
x = x + 1
end
base = set[x -1]
if (base !=1)
fresult = number%base
else
fresult = number%5
end
if (base == 1)
form = 'I'* sres
elsif (base == 5)
form = 'V' * sres
elsif (base == 10)
form = 'X'* sres
elsif (base ==50)
form = 'L'* sres
elsif (base ==100)
form = 'C'* sres
elsif (base == 500)
form = 'D'* sres
elsif (base == 1000)
form = 'M'* result
end
if (fresult == 0)
puts form
elsif (fresult != 0 && base != 1)
puts form + 'I'*fresult
else
puts 'I' * fresult
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def old_roman_numeral num\n\t\n\tif num >= 1000\n\t\tthousands = 'M' * (num / 1000)\n\tend\n\n\tif num >= 100\n\t\ttemp_hundreds = (num % 1000) / 100\n\t\tif temp_hundreds > 5\n\t\t\thundreds = 'D' + 'C' * (temp_hundreds - 5)\n\t\telsif temp_hundreds == 5\n\t\t\thundreds = 'D'\n\t\telse\n\t\t\thundreds = 'C' * tem... | [
"0.8268601",
"0.8162354",
"0.81545943",
"0.8100603",
"0.80930024",
"0.80885345",
"0.8082562",
"0.7971593",
"0.7951563",
"0.79267955",
"0.7888079",
"0.78568465",
"0.78292936",
"0.7825537",
"0.7813372",
"0.7812969",
"0.7801929",
"0.7792692",
"0.7779612",
"0.77774316",
"0.776395... | 0.0 | -1 |
Solution by author reimplementation | def old_r_conv nums
roman = ''
roman = roman + 'M' * (nums/1000)
roman = roman + 'D' * ((nums%1000)/500)
roman = roman + 'C' * ((nums%500)/100)
roman = roman + 'L' * ((nums%100)/50)
roman = roman + 'X' * ((nums%50)/10)
roman = roman + 'V' * ((nums%10)/5)
roman = roman + 'I' * ((nums%5)/1)
puts roman
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def schubert; end",
"def implementation; end",
"def implementation; end",
"def probers; end",
"def suivre; end",
"def anchored; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def formation; end",
"def verdi; end",
"def internal; end"... | [
"0.7484431",
"0.66558784",
"0.6488447",
"0.6488447",
"0.6484637",
"0.64493936",
"0.64450246",
"0.6346427",
"0.6346427",
"0.6346427",
"0.6346427",
"0.63020873",
"0.6098203",
"0.6056682",
"0.6056549",
"0.60565233",
"0.6036468",
"0.6012553",
"0.60120404",
"0.59948075",
"0.597266... | 0.0 | -1 |
checks if conv is a replied to message | def replied_conv? usr
if @conv.posts.count > 1 && @conv.posts.last.user_id != usr.id
@conv.posts.each do |post|
return true if post.user_id == usr.id
end
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replied_conv? usr\n ConversationProcessor.new(self).replied_conv? usr\n end",
"def msg_sent?\n true\n end",
"def reply?\n self.operation == OP_REPLY\n end",
"def replied_to?\n !replied_at.nil?\n end",
"def reply?\n !!in_reply_to_status_id\n end",
"def receive_r... | [
"0.7671172",
"0.6758361",
"0.6430282",
"0.6423208",
"0.63591963",
"0.62989885",
"0.62989885",
"0.62989885",
"0.62628335",
"0.62210596",
"0.62210596",
"0.61984015",
"0.6186934",
"0.61807084",
"0.614865",
"0.6137858",
"0.6130745",
"0.6126751",
"0.6051924",
"0.6044637",
"0.60351... | 0.6440597 | 2 |
returns whether conversation has any associated unread posts | def any_unread? usr
@conv.posts.each do |post|
if post.unread?(usr) && post.recipient_id == usr.id
return true
end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_unread?\n Message.any_in(conversation_id: conversations.map(&:id)).ne(read_by: id).present?\n end",
"def has_unread_messages?\n received_messages.count > 0\n end",
"def any_unread? usr\n ConversationProcessor.new(self).any_unread? usr\n end",
"def unread? user_id\n !unread_messages(use... | [
"0.79774034",
"0.7608553",
"0.73700744",
"0.730161",
"0.7006697",
"0.6941816",
"0.6934406",
"0.6927607",
"0.69178337",
"0.6910893",
"0.68594486",
"0.68594486",
"0.68594486",
"0.6850814",
"0.68155205",
"0.6780257",
"0.6730168",
"0.6643015",
"0.66117275",
"0.66050315",
"0.66005... | 0.80610716 | 0 |
check if user has a message in the conversation | def usr_msg? convo, usr
(usr.id == convo.user_id && convo.status == 'active') || (usr.id == convo.recipient_id && convo.recipient_status == 'active')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_in_conversation?(_user_id)\n conversation_members.where(user_id: _user_id).any?\n end",
"def has_message?\n has_message\n # && messages.count > 0\n end",
"def has_conversation?(conversation)\n conversation.is_participant?(messageable)\n end",
"def has_conversation?(conversation)\n co... | [
"0.7807762",
"0.76709825",
"0.76076967",
"0.76076967",
"0.75791794",
"0.7477209",
"0.7438737",
"0.7148298",
"0.7003683",
"0.6972134",
"0.6939719",
"0.6931666",
"0.69269556",
"0.6914397",
"0.69119173",
"0.6868971",
"0.6854507",
"0.68348354",
"0.6808971",
"0.6783754",
"0.672966... | 0.7094983 | 8 |
get conversations where user has sent/received at least one message in conversation and conversation is active | def get_specific_conversations usr, c_type
conv_ids = Array.new
convos = Conversation.get_conversations(usr)
convos.find_each do |convo|
convo.posts.find_each do |post|
if (c_type == "received" && post.recipient_id == usr.id && post.recipient_status == 'active') ||
(c_type == "sent" && post.user_id == usr.id && post.status == 'active')
conv_ids << convo.id if usr_msg?(convo, usr); break
end
end
end
return convos.where(["id in (?)", conv_ids]).sort_by {|x| x.posts.last.created_at }.reverse
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conversations\n Conversation.where(\"sender_id = ? or recipient_id = ?\",self.id,self.id)\n end",
"def conversations\n Conversation.where(\"sender_id = ? OR recipient_id = ?\", id,id)\n end",
"def get_conversations\n n = Notification.where(user_id:current_user)\n conversation_ids = Array.new\... | [
"0.7559071",
"0.75354826",
"0.708918",
"0.70735186",
"0.67406595",
"0.640352",
"0.6388556",
"0.6370114",
"0.6329861",
"0.62790936",
"0.62372273",
"0.62033486",
"0.6154459",
"0.6141713",
"0.61287546",
"0.61178565",
"0.60924554",
"0.6002418",
"0.6001807",
"0.5943966",
"0.592510... | 0.6255811 | 10 |
sets convo status to 'removed' | def remove_conv conv, user
if user.id == conv.user_id
return update_status(conv, user, 'status')
elsif user.id == conv.recipient_id
return update_status(conv, user, 'recipient_status')
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove!\n self.update_attribute(:status, REMOVED)\n end",
"def remove!\n self.update_attribute(:status, REMOVED)\n end",
"def removed; status[:removed]; end",
"def destroye\n self.update_attribute(:status,7)\n end",
"def remove\n if status == \"pending\"\n reject\n else\n ... | [
"0.69407505",
"0.69407505",
"0.6678533",
"0.6245886",
"0.62038225",
"0.6047187",
"0.6032951",
"0.6011759",
"0.5924574",
"0.5850906",
"0.5850906",
"0.5850906",
"0.58394384",
"0.58113974",
"0.5778667",
"0.575794",
"0.57445323",
"0.57445323",
"0.57445323",
"0.57445323",
"0.56943... | 0.6261511 | 3 |
update appropriate status fld | def update_status conv, user, fld
if conv.update_attribute(fld.to_sym, 'removed')
conv.remove_posts(user)
true
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_status(status)\n self.status = status\n self.save! validate: false\n end",
"def update_status(status)\n @status = status\n @last_status_change = Time.now\n update_statusfile\n end",
"def set_flds\n self.status = 'active' if status.blank?\n self.status = 'scheduled' if has_appt... | [
"0.70309967",
"0.697569",
"0.6943432",
"0.68446016",
"0.6799303",
"0.67307174",
"0.67230606",
"0.6718294",
"0.6712188",
"0.6712188",
"0.6705528",
"0.669559",
"0.66875",
"0.6641387",
"0.66072446",
"0.660232",
"0.65956587",
"0.6559024",
"0.65514934",
"0.6538516",
"0.6531496",
... | 0.0 | -1 |
sets all posts in a convo to 'removed' | def remove_posts usr
@conv.posts.each do |post|
if usr.id == post.user_id
post.status = 'removed'
elsif usr.id == post.recipient_id
post.recipient_status = 'removed'
end
post.save
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_posts usr\n ConversationProcessor.new(self).remove_posts usr\n end",
"def clear!\n @posts = nil\n end",
"def after_destroy(post)\n post = post.to_post\n Notification.where(:scope => 'mention',\n :source_ids => {'Post' => post.id}).each do |notification|\n notification.rem... | [
"0.6978334",
"0.6913233",
"0.6187236",
"0.61253244",
"0.6107475",
"0.60547864",
"0.604865",
"0.6046654",
"0.60339445",
"0.6005888",
"0.6005888",
"0.6005888",
"0.6005485",
"0.5974702",
"0.5935466",
"0.59247625",
"0.59185445",
"0.59035033",
"0.58933",
"0.5884303",
"0.58808655",... | 0.73982596 | 0 |
mark all posts in a conversation | def mark_all_posts usr
return false if usr.blank?
@conv.posts.each do |post|
post.mark_as_read! for: usr if post
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_all_posts usr\n ConversationProcessor.new(self).mark_all_posts usr\n end",
"def mark_all_readed\n doctor.notifications.update_all unreaded: false\n send_json doctor.notifications, true\n end",
"def mark_read_messages(conversation)\n time = Time.current\n conversation = Conversation.fi... | [
"0.8151513",
"0.6205402",
"0.6189774",
"0.58371794",
"0.56703055",
"0.56609356",
"0.55997",
"0.55727977",
"0.5549892",
"0.54906887",
"0.54813874",
"0.5453417",
"0.54390085",
"0.54188335",
"0.5398069",
"0.5370722",
"0.5357503",
"0.53451574",
"0.53398174",
"0.53383404",
"0.5307... | 0.69614565 | 1 |
This method sets up the user's abilities to view admin pages look at for more info | def initialize(user)
user ||= User.new # guest user will not be allowed in the admin section
alias_actions
if user.super_admin?
can :manage, :all
elsif user.admin? || user.contractor?
#can :manage, :all
#can :read, :all
#can :view_users, User do
# user.admin?
#end
#authorize! :view_users, @user
#can :create_users, User do
# user.super_admin?
#end
#authorize! :create_users, @user
#can :create_orders, User
if user.trial || user.unsubscribed
unless user.unsubscribed
can [:make], Product if user.products.count < 1
end
can [:read, :change], Product, contractor_id: user.id
else
can :manage, Product, contractor_id: user.id
end
can :manage, Order, contractor_id: user.id
can :manage, Shipment, order: {contractor_id: user.id}
can :manage, ImageGroup, product: {contractor_id: user.id}
can :manage, Property
can :manage, Invoice
if user.has_balance?
can :manage, Requests::Balance, user_id: user.id
can [:read, :make, :cancel], Requests::Transaction, balance_id: user.balance.id
can :read, Requests::Credit
can [:read, :make, :cancel], Requests::Withdraw
can [:read], Requests::Refund, transaksi: {balance_id: user.balance.id}
end
can :manage, :overview
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin_actions(user)\n can_act_as_logged_in_user(user)\n can_view_any_profile\n can_view_any_gallery\n can_edit_saved_queries\n can_curate\n can_update_metadata\n can_administer\n end",
"def info_for_edit_page\n @is_super_adm = is_super?\n\n if @is_super_adm\n # Loading Choosi... | [
"0.7362424",
"0.71003675",
"0.7093616",
"0.70592356",
"0.7056795",
"0.7026277",
"0.700151",
"0.69992375",
"0.69992375",
"0.6967919",
"0.69633496",
"0.69437665",
"0.6916778",
"0.6903402",
"0.6896182",
"0.6881814",
"0.6854698",
"0.683619",
"0.68319356",
"0.6800599",
"0.6788348"... | 0.0 | -1 |
Initializes an instance url:: URL to a BigBlueButton server (e.g. salt:: Secret salt for this server version:: API version: 0.7 (valid for 0.7, 0.71 and 0.71a) | def initialize(url, salt, version='0.7', debug=false)
@supported_versions = ['0.7','0.8']
@url = url
@salt = salt
@debug = debug
if version.nil?
@version = get_api_version
else
@version = version
end
unless @supported_versions.include?(@version)
raise BigBlueButtonException.new("BigBlueButton error: Invalid API version #{version}. Supported versions: #{@supported_versions.join(', ')}")
end
puts "BigBlueButtonAPI: Using version #{@version}" if @debug
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(url, salt, version='0.7', debug=false)\n @supported_versions = ['0.7', '0.8']\n @url = url\n @salt = salt\n @debug = debug\n @timeout = 10 # default timeout for api requests\n @request_headers = {} # http headers sent in all requests\n\n @version = version ... | [
"0.7773854",
"0.75203896",
"0.7190561",
"0.6984908",
"0.6750601",
"0.67253166",
"0.67134416",
"0.67134416",
"0.67134416",
"0.66722953",
"0.6669814",
"0.66446024",
"0.66299945",
"0.6591506",
"0.6515754",
"0.649704",
"0.64923084",
"0.6490326",
"0.6474378",
"0.6450362",
"0.64403... | 0.7768183 | 1 |
Returns the url used to join the meeting meeting_id:: Unique identifier for the meeting user_name:: Name of the user password:: Password for this meeting used to set the user as moderator or attendee user_id:: Unique identifier for this user web_voice_conf:: Custom voiceextension for users using VoIP | def join_meeting_url(meeting_id, user_name, password,
user_id = nil, web_voice_conf = nil)
params = { :meetingID => meeting_id, :password => password, :fullName => user_name,
:userID => user_id, :webVoiceConf => web_voice_conf }
get_url(:join, params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_meeting_url(meeting_id, user_name, password, options={})\n valid_options = [:userID, :webVoiceConf]\n valid_options += [:createTime] if @version >= \"0.8\"\n options.reject!{ |k,v| !valid_options.include?(k) }\n\n params = { :meetingID => meeting_id, :password => password, :fullName =>... | [
"0.8092655",
"0.7162452",
"0.713902",
"0.7123276",
"0.700276",
"0.6416468",
"0.5919399",
"0.5888902",
"0.5880316",
"0.5797665",
"0.57330704",
"0.5627439",
"0.54624236",
"0.5445873",
"0.5445873",
"0.5440448",
"0.5386621",
"0.53849703",
"0.5333603",
"0.5322903",
"0.531965",
"... | 0.80475104 | 1 |
Returns true or false as to whether meeting is open. A meeting is only open after at least one participant has joined. meeting_id:: Unique identifier for the meeting | def is_meeting_running?(meeting_id)
hash = send_api_request(:isMeetingRunning, { :meetingID => meeting_id } )
hash[:running].downcase == "true"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def meeting_running?(id)\n prepare\n @api.is_meeting_running?(id)\n end",
"def is_meeting_running?(meeting_id)\n hash = send_api_request(:isMeetingRunning, { :meetingID => meeting_id } )\n BigBlueButtonFormatter.new(hash).to_boolean(:running)\n end",
"def open?\n\t\t@time = Time.now.to_form... | [
"0.6380261",
"0.62248003",
"0.6221971",
"0.6039648",
"0.6039648",
"0.59506863",
"0.590294",
"0.57762027",
"0.57440346",
"0.572106",
"0.5709472",
"0.5704064",
"0.5704059",
"0.57009107",
"0.5669436",
"0.5643488",
"0.5627048",
"0.5624854",
"0.55969566",
"0.5593739",
"0.55860245"... | 0.6326372 | 1 |
Warning: As of this version of the gem, this call does not work (instead of returning XML response, it should join the meeting). Joins a user into the meeting using an API call, instead of directing the user's browser to moderator_url or attendee_url (note: this will still be required however to actually use bbb). Returns the URL a user can use to enter this meeting. meeting_id:: Unique identifier for the meeting user_name:: Name of the user password:: Moderator or attendee password for this meeting user_id:: Unique identifier for this user web_voice_conf:: Custom voiceextension for users using VoIP | def join_meeting(meeting_id, user_name, password, user_id = nil, web_voice_conf = nil)
params = { :meetingID => meeting_id, :password => password, :fullName => user_name,
:userID => user_id, :webVoiceConf => web_voice_conf }
send_api_request(:join, params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_meeting_url(meeting_id, user_name, password, options={})\n valid_options = [:userID, :webVoiceConf]\n valid_options += [:createTime] if @version >= \"0.8\"\n options.reject!{ |k,v| !valid_options.include?(k) }\n\n params = { :meetingID => meeting_id, :password => password, :fullName =>... | [
"0.71058464",
"0.70569307",
"0.7056182",
"0.6351036",
"0.6325934",
"0.61878186",
"0.61102873",
"0.58758646",
"0.5833925",
"0.581703",
"0.5768154",
"0.57501143",
"0.57223004",
"0.56345004",
"0.55315965",
"0.55248547",
"0.5518703",
"0.5513635",
"0.5485416",
"0.54838276",
"0.545... | 0.7053277 | 3 |
Returns the API version (as string) of the associated server. This actually returns the version returned by the BBB server, and not the version set by the user in the initialization of this object. | def get_api_version
response = send_api_request(:index)
if response[:returncode]
response[:version].to_s
else
""
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_version\n @api_version ||= begin\n pool = self.pool.get_all[0]\n host = self.pool.get_master(pool)\n major = self.host.get_API_version_major(host)\n minor = self.host.get_API_version_minor(host)\n \"#{major}.#{minor}\"\n end\n end",
"def get_server_version\... | [
"0.8020638",
"0.7922533",
"0.7849166",
"0.78220415",
"0.7770864",
"0.77261287",
"0.76650965",
"0.7625699",
"0.7594201",
"0.755313",
"0.75075597",
"0.7504527",
"0.74810535",
"0.74678487",
"0.7390593",
"0.7367479",
"0.7310886",
"0.7304962",
"0.7296324",
"0.72943884",
"0.7284807... | 0.7735128 | 5 |
Make a simple request to the server to test the connection | def test_connection
response = send_api_request(:index)
response[:returncode]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_connection\n args = get_connection_args(\"#{endpoint}/auth\")\n args[:raw_response] = true\n RestClient::Request.execute(args)\n end",
"def make_http_request\n Net::HTTP.get_response('localhost', '/ping', 3000).body\nend",
"def talk_to_server(host, port, request)\n socket = TCPSocket.open(... | [
"0.7246728",
"0.6996201",
"0.6960943",
"0.69358444",
"0.6804451",
"0.67962855",
"0.6730802",
"0.6646011",
"0.6623835",
"0.660756",
"0.65600026",
"0.6557589",
"0.6467756",
"0.643878",
"0.64028424",
"0.6393356",
"0.6374452",
"0.6329454",
"0.6299891",
"0.62986606",
"0.62953645",... | 0.7188415 | 1 |
API's are equal if all the following attributes are equal | def ==(other)
r = true
[:url, :supported_versions, :salt, :version, :debug].each do |param|
r = r && self.send(param) == other.send(param)
end
r
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other)\n attributes == other.attributes\n end",
"def same_attributes?(spec)\n @@attributes.all? {|name, default| self.send(name) == spec.send(name) }\n end",
"def ==(other)\n self.attributes == (other.respond(:attributes) || {} )\n end",
"def assert_equal_attributes(object, expecte... | [
"0.63939977",
"0.636372",
"0.6348708",
"0.6265852",
"0.6198845",
"0.6186651",
"0.6136603",
"0.61046416",
"0.6098515",
"0.60707206",
"0.606702",
"0.6062241",
"0.60368645",
"0.60092324",
"0.60063803",
"0.59914947",
"0.598974",
"0.5985712",
"0.59493273",
"0.59475935",
"0.5941238... | 0.58752424 | 25 |
Post method Accepts email address and password as input (in JSON format) Authenticates if the email address and the password match Returns corresponding status and status message for debugging | def create
begin
@ShopUser = params[:user]
if @ShopUser
email = @ShopUser["email_address"]
pword = @ShopUser["password"]
#check if input parameters are supplied
if email and pword
message = ShopUser.authenticate_email(email,pword)
else
message = {"status" => 3, "message" => "Incomplete input parameters"}
end
else
message = {"status" => 4, "message" => "No input parameters"}
end
rescue Exception => msg
message = {"status" => 5, "message" => "Tech Error: #{msg}"}
end
render :json => message
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login \n isPasswordCorrect = AuthenticationHelper::Auth.instance.checkPassword( request.body )\n params = JSON.parse( request.body.read )\n emailParams = params[\"email\"]\n \n if ( isPasswordCorrect )\n token = AuthenticationHelper::Auth.instance.generateJWT( e... | [
"0.7333456",
"0.7322311",
"0.72568107",
"0.7231806",
"0.71603745",
"0.70815796",
"0.7037055",
"0.6993499",
"0.6991164",
"0.69681257",
"0.69532007",
"0.69514656",
"0.69504523",
"0.6937419",
"0.68994975",
"0.6868398",
"0.68683445",
"0.6852737",
"0.6831846",
"0.6819531",
"0.6802... | 0.0 | -1 |
override this method from commentable_entity.rb to return the name of the ultimate parent this is on we have to do this somewhat roundabout because until the comment is set and saved, the ultimate_parent method will not work (the thread is not set) and this is being called from before then. | def commentable_name
self.reply_comment? ? self.commentable.ultimate_parent.commentable_name : self.commentable.commentable_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent_name\n @parent ? @parent.full_name : '(unknown)'\n end",
"def parent_name\n parent_info && parent_info.name\n end",
"def ultimate_parent # note: ultimate parent is self, not nil, if self has no parent...\n if parent_id.blank?\n self\n else\n parent.ultimate_parent\n ... | [
"0.7419927",
"0.7389861",
"0.73451173",
"0.7232117",
"0.72224605",
"0.71399903",
"0.71399903",
"0.708931",
"0.6867958",
"0.6856923",
"0.6781221",
"0.6754304",
"0.6733",
"0.6733",
"0.6708299",
"0.6700839",
"0.6652689",
"0.6601245",
"0.65777475",
"0.657579",
"0.6568795",
"0.6... | 0.7226914 | 5 |
don't want to submit anything to Akismet while testing. bad things might happen | def mark_as_spam!
update_attribute(:approved, false)
Akismetor.submit_spam(akismet_attributes)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_nonhero_is_vulnerable\n end",
"def allow_in_post_mortem; end",
"def when_i_submit_bad_url\n given_i_am_signed_in\n # shouldn't get to the stage of finding\n submit_url 'http://thisisspam.com/fake-viagra.html'\nend",
"def wont_be_true(msg=nil)\n TrueAssay.refute!(self, :message=>msg, :backtr... | [
"0.62719405",
"0.60163856",
"0.5991905",
"0.59910226",
"0.59844375",
"0.5874197",
"0.5856557",
"0.57921964",
"0.5757335",
"0.5717968",
"0.56985873",
"0.56777436",
"0.5674995",
"0.56681556",
"0.56669265",
"0.56545115",
"0.5628268",
"0.56231636",
"0.5616189",
"0.5615758",
"0.56... | 0.5305555 | 99 |
this solution is very slow!! (takes a number of hours to run to completion) | def is_abundant?(n)
factors(n).reduce(0, :+) > n
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_kpi_from_key_counter(all_fomula,s1_ip,time_counter_hash,source_file,logger)\n\ncell_size=3\n\ntime_counter_hash.each do |start_time,one_time_counter|\n\n counter_hash=one_time_counter\n #logger.debug \"kpi calculation for start time=#{start_time}\"\n all_cell_hash=Hash.new\n\n all_fomula.each do |fomu... | [
"0.548031",
"0.5328847",
"0.53015554",
"0.5236806",
"0.5204727",
"0.5182975",
"0.5174632",
"0.5113446",
"0.5081588",
"0.5081588",
"0.5081588",
"0.5081588",
"0.5081588",
"0.50653243",
"0.5018727",
"0.5018078",
"0.50173885",
"0.5011533",
"0.49891126",
"0.4976755",
"0.4976109",
... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.