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 |
|---|---|---|---|---|---|---|
This test when found 9 rubies | def test_mood4
assert_equal @p.mood?([9, 0]), 'sad.'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_rubies\n @sample_rubies ||= sample_mri_rubies + %w[ jruby-9.3 ]\n end",
"def test_bad_rubinius_deps\n check_deps_fail BadRubiniusBall unless `/usr/bin/which rbx`.chomp.empty?\n end",
"def sample_mri_rubies\n @sample_mri_rubies ||= %w[ ruby-3.2 ruby-2.7 ]\n end",
"def test_rubies_found_... | [
"0.6857168",
"0.67097574",
"0.66240954",
"0.65992486",
"0.65953755",
"0.64571726",
"0.63883245",
"0.6254133",
"0.62039113",
"0.6201605",
"0.6195706",
"0.6161385",
"0.6081036",
"0.60472536",
"0.60472536",
"0.6003172",
"0.5975586",
"0.5961504",
"0.5864507",
"0.5860492",
"0.5847... | 0.0 | -1 |
This test when found 10 rubies | def test_mood5
assert_equal @p.mood?([10, 0]), 'victorious!'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_rubies\n @sample_rubies ||= sample_mri_rubies + %w[ jruby-9.3 ]\n end",
"def test_rubies_found_positive\n prospector = Rubyist.new(1)\n prospector.rubies_found(2, 2)\n assert prospector.real_ruby_count == 2 && prospector.fake_ruby_count == 2\n end",
"def sample_mri_rubies\n @sample_... | [
"0.6731414",
"0.6711774",
"0.65207714",
"0.6389709",
"0.63414603",
"0.6326461",
"0.61986166",
"0.6160062",
"0.614903",
"0.6110676",
"0.61095417",
"0.60324895",
"0.6005822",
"0.59746015",
"0.59568477",
"0.59517497",
"0.5933567",
"0.5928484",
"0.58905494",
"0.5882204",
"0.58745... | 0.0 | -1 |
This test when found 100 rubies | def test_mood6
assert_equal @p.mood?([100, 0]), 'victorious!'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_rubies\r\n # Add 1 to max_rubies to make maximum inclusive\r\n @random.rand(@max_rubies + 1)\r\n end",
"def test_find_rubies_nonzero\r\n\t\tassert_includes 0..@t.max_rubies, @t.find_rubies\r\n\tend",
"def test_fake_rubies_found\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\... | [
"0.6955006",
"0.6875608",
"0.6873788",
"0.6765082",
"0.6738218",
"0.6694599",
"0.6629453",
"0.64132553",
"0.638477",
"0.6319529",
"0.6239585",
"0.62267745",
"0.61831784",
"0.6135034",
"0.61318135",
"0.6086829",
"0.6078069",
"0.6061363",
"0.6035586",
"0.59994864",
"0.59683067"... | 0.0 | -1 |
UNIT TESTS FOR show_rush_result(x, y, []) | def test_show_rush_result
assert_output("After 2 days, Rubyist 1 found:
10 rubies.
10 fake rubies.
Going home victorious!\n"){ @p.show_rush_result(2, 1, [10, 10]) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_concatonation_6\n find = Finder.new\n arr = []\n arr3 = find.concatonation(arr)\n assert_equal arr3, []\n end",
"def big_result_array\n @my_big_result_array.push(@result)\n #puts \" \"\n #puts \"#{@my_big_result_array}\"\n #puts \" \"\n end",
"def test_print_out_found_long\n ... | [
"0.5895557",
"0.5867255",
"0.583838",
"0.57620066",
"0.56787837",
"0.5641524",
"0.5628743",
"0.55312467",
"0.5474883",
"0.5435381",
"0.54129934",
"0.53561556",
"0.5318023",
"0.531553",
"0.53137696",
"0.5312709",
"0.52847123",
"0.5272771",
"0.5241636",
"0.5240005",
"0.5223984"... | 0.7192215 | 0 |
UNIT TEST FOR dig(location, rng) Equvalent classes: since mock_rng only return the same array that predefined, passing something other than [0,0] will loop infinitely, to see if this is true, please change the [0,0] to any other nonzero pair This test the output when only loop once | def test_dig_once
mock_location = Minitest::Mock.new('location')
mock_rng = Minitest::Mock.new('rng')
def mock_location.name; 'a'; end
def mock_location.random_total_ruby(mock_rng); [0, 0]; end
assert_output(" Found no rubies or fake rubies in a.\n"){@p.dig(mock_location, mock_rng)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dig(current_locaiton, rng)\n current_found = []\n while current_found != [0, 0]\n current_found = current_locaiton.random_total_ruby(rng) # digging\n @day += 1\n @total_ruby_found[0] += current_found[0] # add up the real ruby\n @total_ruby_found[1] += current_found[1] # add up the fak... | [
"0.65181816",
"0.61968327",
"0.58114105",
"0.58022386",
"0.5738806",
"0.57243747",
"0.5701427",
"0.55380976",
"0.5530091",
"0.550793",
"0.55027753",
"0.54968274",
"0.54933864",
"0.5485736",
"0.5479253",
"0.5443515",
"0.5435742",
"0.5435286",
"0.54314697",
"0.53941715",
"0.539... | 0.7199725 | 0 |
UNIT TEST FOR ruby_rush(location) Equvalent classes: no turns to make more than 1 turn This test when no turn is needed EDGE CASE | def test_ruby_rush_no_turn
mock_location = Minitest::Mock.new('location')
mock_rng = Minitest::Mock.new('rng')
@p2 = Prospector.new(1, 0, mock_rng)
def mock_location.name; 'a'; end
def mock_location.random_total_ruby(mock_rng); [0, 0]; end
assert_output("Rubyist #1 starting in Enumerable Canyon.
Found no rubies or fake rubies in a.
After 1 days, Rubyist 1 found:
0 rubies.
0 fake rubies.
Going home empty-handed.\n"){@p2.ruby_rush(mock_location)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_move_turns_duck_type_beach\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_duck_type_beach\n assert_includes ['Enumerable Canyon', 'Matzburg'], ruby_rush.city\n end",
"def test_move_turns_enumerable_can... | [
"0.7230817",
"0.7083209",
"0.7044638",
"0.6998747",
"0.6992644",
"0.69415236",
"0.668375",
"0.6547405",
"0.63591486",
"0.6337923",
"0.63192415",
"0.62576455",
"0.61337245",
"0.6104942",
"0.6095351",
"0.6086338",
"0.6002079",
"0.6000081",
"0.59954333",
"0.59413654",
"0.5937977... | 0.680165 | 6 |
UNIT TEST FOR ruby_rush(location) Equvalent classes: no turns to make more than 1 turn This test when 0 prospector is passed, if run "ruby ruby_rush.rb", it should output nothing, however, in this case it should print Rubyist 0 EDGE CASE | def test_ruby_rush_no_rubyist
mock_location = Minitest::Mock.new('location')
mock_rng = Minitest::Mock.new('rng')
@p2 = Prospector.new(0, 0, mock_rng)
def mock_location.name; 'a'; end
def mock_location.random_total_ruby(mock_rng); [0, 0]; end
assert_output("Rubyist #0 starting in Enumerable Canyon.
Found no rubies or fake rubies in a.
After 1 days, Rubyist 0 found:
0 rubies.
0 fake rubies.
Going home empty-handed.\n"){@p2.ruby_rush(mock_location)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ruby_rush_turns\n mock_location = Minitest::Mock.new('location')\n mock_rng = Minitest::Mock.new('rng')\n @p2 = Prospector.new(1, 2, mock_rng)\n def mock_location.name; 'a'; end\n def mock_location.go_to_next(mock_rng); [self, self][0];end\n def mock_location.random_total_ruby(mock_rng);... | [
"0.76328766",
"0.7544048",
"0.7075955",
"0.69788057",
"0.68797725",
"0.6820669",
"0.67566013",
"0.6733562",
"0.66909605",
"0.6612063",
"0.6569835",
"0.64888614",
"0.6456789",
"0.64035106",
"0.63809",
"0.63476205",
"0.63425696",
"0.6342358",
"0.6258989",
"0.62483585",
"0.61373... | 0.73236626 | 2 |
This test when at least one turn is needed | def test_ruby_rush_turns
mock_location = Minitest::Mock.new('location')
mock_rng = Minitest::Mock.new('rng')
@p2 = Prospector.new(1, 2, mock_rng)
def mock_location.name; 'a'; end
def mock_location.go_to_next(mock_rng); [self, self][0];end
def mock_location.random_total_ruby(mock_rng); [0, 0]; end
assert_output("Rubyist #1 starting in Enumerable Canyon.
Found no rubies or fake rubies in a.
Heading from a to a
Found no rubies or fake rubies in a.
Found no rubies or fake rubies in a.
After 3 days, Rubyist 1 found:
0 rubies.
0 fake rubies.
Going home empty-handed.\n"){@p2.ruby_rush(mock_location)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finished?\n @turns_allowed < 0\n end",
"def initial_turn?(turn)\n max_turn = @players_count\n turn <= max_turn\n end",
"def regular_turn?(turn)\n min_turn = @players_count * 2 + 1\n turn >= min_turn\n end",
"def test_take_one_turn\n turn = Turn.new(@player1, @player2)\n assert_equ... | [
"0.7382166",
"0.7101779",
"0.7051302",
"0.7045431",
"0.7043881",
"0.70234454",
"0.6897063",
"0.6800436",
"0.6782517",
"0.6708824",
"0.67020375",
"0.6700645",
"0.6686612",
"0.66621333",
"0.66278386",
"0.6560461",
"0.65486294",
"0.65314674",
"0.65277857",
"0.64799243",
"0.64639... | 0.0 | -1 |
This method is used because, for nil values, savon will respond with an hash containing all other attributes. If we check that the expected type is matched, we can prevent to retrieve wrong values | def get_if_kind value, kind
value.kind_of?(kind) && value || nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duck_type_hash_values(hash)\n hash.inject(HashWithIndifferentAccess.new) do |corrected_hash, hash_entry|\n key = hash_entry.first\n value = hash_entry.last\n model_attribute = model_attributes[key.to_sym] || {}\n value = ActiveModel::Attributes.convert_to(model_attrib... | [
"0.6222344",
"0.6185397",
"0.6137916",
"0.5797852",
"0.5711898",
"0.5684088",
"0.5650208",
"0.5619862",
"0.5615035",
"0.559395",
"0.5582619",
"0.55615693",
"0.55510503",
"0.55469906",
"0.5544507",
"0.55360687",
"0.5529707",
"0.5524967",
"0.55000794",
"0.5471463",
"0.54710865"... | 0.0 | -1 |
filter_params = ["col=docketNumberColumn&val=legacy|evidence_submission", "col=taskColumn&val=TranslationTask"] [ "cached_appeals_attributes.docket_type IN (?) AND tasks.type in (?)", ["legacy", "evidence_submission"], ["TranslationTask"] ] | def where_clause
return [] if filter_params.empty?
filters = filter_params.map(&QueueFilterParameter.method(:from_string))
where_string = TaskFilter.where_string_from_filters(filters)
where_arguments = filters.map(&:values).reject(&:empty?)
[where_string] + where_arguments
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filtering_params(params)\n params.slice(:shortlist, :client, :category, :updated_at, :costmodel, :state, :prio)\n end",
"def tasks_by_filters\n to_include = [ :users, :tags, :sheets, :todos, :dependencies, :milestone ]\n to_include << { :company => :properties}\n to_include << { :project => ... | [
"0.6277281",
"0.6103675",
"0.60293704",
"0.60208803",
"0.6006719",
"0.60038644",
"0.5992396",
"0.5947627",
"0.59263736",
"0.5913383",
"0.59046406",
"0.59046406",
"0.5891756",
"0.5884239",
"0.5862696",
"0.5862696",
"0.58618766",
"0.5858242",
"0.5830111",
"0.58234847",
"0.58136... | 0.5817226 | 20 |
GET /stock_disposals GET /stock_disposals.xml | def index
@search = StockDisposal.search(params[:search])
@stock_disposals = @search.order('stock_disposal_date DESC').all.uniq.paginate(:page => params[:page], :per_page => 20)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @stock_disposals }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @stock_disposal = StockDisposal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock_disposal }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb... | [
"0.73839664",
"0.69784445",
"0.684364",
"0.68045205",
"0.66675204",
"0.6667231",
"0.6651202",
"0.66298026",
"0.66160965",
"0.66003895",
"0.657",
"0.6551531",
"0.65320325",
"0.6529588",
"0.64958584",
"0.6486223",
"0.64720434",
"0.64450586",
"0.6437113",
"0.6437113",
"0.6437113... | 0.6864505 | 2 |
GET /stock_disposals/1 GET /stock_disposals/1.xml | def show
@stock_disposal = StockDisposal.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @stock_disposal }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def show\n @stock = Stock.find(params[:id])\n default_data\n\n respond_to do |format|\n format.html # show.html.erb\n ... | [
"0.70859355",
"0.69048846",
"0.6814533",
"0.67747676",
"0.6750608",
"0.67310715",
"0.6709758",
"0.6687208",
"0.66353226",
"0.6603198",
"0.6600585",
"0.6586406",
"0.65736115",
"0.65573055",
"0.65422374",
"0.6491666",
"0.64363325",
"0.6431845",
"0.6419068",
"0.63996696",
"0.639... | 0.73961794 | 0 |
GET /stock_disposals/new GET /stock_disposals/new.xml | def new
@stock_disposal = StockDisposal.new
@stock_disposal.stock_disposal_date = Date.today
@stock_disposal.user_id = current_user.id
@stock_disposal.save!
redirect_to edit_stock_disposal_path(@stock_disposal)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def new\n @stockist = Stockist.new\n assign_lovs\n\n respond_to do |format|\n format.html # new.haml\n format.xml { render :xml => @s... | [
"0.7741212",
"0.7340712",
"0.7331441",
"0.7201202",
"0.71404",
"0.71376634",
"0.7123625",
"0.7110244",
"0.7090372",
"0.7082992",
"0.7082992",
"0.7082992",
"0.7082992",
"0.7082992",
"0.7082992",
"0.6971428",
"0.6971428",
"0.6951421",
"0.6936358",
"0.69197434",
"0.68991786",
... | 0.0 | -1 |
POST /stock_disposals POST /stock_disposals.xml | def create
@stock_disposal = StockDisposal.new(params[:stock_disposal])
if @stock_disposal.save
redirect_to(edit_stock_disposal_path(@stock_disposal), :notice => 'Stock disposal was successfully created.')
else
render :action => "new"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @repuesto_servicio = RepuestoServicio.new(repuesto_servicio_params)\n @repuesto_servicio.stock=params[:repuesto_servicio][:stock] = 0.0\n respond_to do |format|\n if @repuesto_servicio.save\n format.html { redirect_to @repuesto_servicio, notice: 'Repuesto o servicio fue creado con... | [
"0.6200757",
"0.6067822",
"0.59701884",
"0.5920933",
"0.5904213",
"0.5868793",
"0.58488536",
"0.57551795",
"0.57526445",
"0.57396585",
"0.57396585",
"0.57396585",
"0.57396585",
"0.5730848",
"0.5726928",
"0.5726928",
"0.5726928",
"0.5726928",
"0.5726928",
"0.5726928",
"0.57123... | 0.63193685 | 0 |
PUT /stock_disposals/1 PUT /stock_disposals/1.xml | def update
@stock_disposal = StockDisposal.find(params[:id])
respond_to do |format|
if @stock_disposal.update_attributes(params[:stock_disposal])
format.html { redirect_to(@stock_disposal, :notice => 'Stock disposal was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @stock_disposal.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n if @stock.update_attributes(params[:stock])\n flash[:notice] = 'Stock was successfully updated.'\n format.html { redirect_to(@stock) }\n format.xml { head :ok }\n else\n format.html { render :act... | [
"0.6463435",
"0.63264483",
"0.6311057",
"0.6310576",
"0.62480193",
"0.6191191",
"0.6191191",
"0.6191191",
"0.61430705",
"0.6135126",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
"0.6111604",
... | 0.6835427 | 0 |
DELETE /stock_disposals/1 DELETE /stock_disposals/1.xml | def destroy
@stock_disposal = StockDisposal.find(params[:id])
@stock_disposal.voided = true
@stock_disposal.save!
flash[:notice] = "Voided Successfully"
respond_to do |format|
format.html { redirect_to(stock_disposals_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @stock = Stock.find(params[:id])\n @stock.destroy\n\n respond_to do |format|\n format.html { redirect_to(stocks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stock = Stock.find(params[:id])\n @stock.destroy\n\n respond_to do |format|\n format.h... | [
"0.6983932",
"0.6983932",
"0.6754126",
"0.66912115",
"0.6672646",
"0.665523",
"0.66400844",
"0.65826917",
"0.65727395",
"0.65109795",
"0.650712",
"0.6475347",
"0.64241",
"0.64241",
"0.64241",
"0.64241",
"0.64241",
"0.64241",
"0.64137226",
"0.64111155",
"0.63989794",
"0.6397... | 0.6327988 | 33 |
This is landing page when lawfirm admin logs in | def index
update_session
@company_id = current_user.company_id
@company = Company.find(@company_id, :include => :product_licences)
@users = User.find(:all,:include=>[:company,:employee,:role,{:product_licence_details=>{:product_licence=>:product}}],:conditions=>['company_id=?',@company.id]) if @company.users_not_client
@employees = @company.employees.size
@totalusers = @users.size
@activeusers = SubproductAssignment.all(:select => ["distinct user_id"], :conditions => ["company_id = ? AND employee_user_id IS NULL", @company_id]).size
@activepermlicence = 0
@activetemplicence = 0
@remainpermlicence = 0
@remaintemplicence = 0
@duration_setting = @company.duration_setting
@company.product_licences.each do |pl|
@activepermlicence += 1 if (pl.licence_type == 0 and pl.status == 1)
@activetemplicence += 1 if (pl.licence_type == 1 and pl.status == 1)
@remainpermlicence += 1 if (pl.licence_type == 0 and pl.status == 0)
@remaintemplicence += 1 if (pl.licence_type == 1 and pl.status == 0)
end
params[:company_id]=current_user.company_id
if params[:company_id].present?
@company ||= Company.find(params[:company_id])
@tne_setting = @company.tne_invoice_setting.id if @company.tne_invoice_setting.present?
end
respond_to do |format|
format.html #index.html.erb
format.xml { render :xml => @users }
authorize!(:index,current_user) unless current_user.role?:lawfirm_admin
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def landing_page\n if current_user\n redirect_to actions_path(current_user[:id])\n end\n end",
"def landing\n redirect_to dashboard_path if current_user\n end",
"def home\n if user_signed_in?\n current_user.update_attribute(:login_status, true) if current_user # update login sta... | [
"0.7578353",
"0.75149035",
"0.74154544",
"0.7392141",
"0.7380116",
"0.7125782",
"0.7101803",
"0.7048784",
"0.7013973",
"0.70138943",
"0.7004813",
"0.6988301",
"0.69840455",
"0.69813025",
"0.69743896",
"0.6942855",
"0.6911446",
"0.69081086",
"0.69081086",
"0.68998235",
"0.6899... | 0.0 | -1 |
GET /lawfirm_admins/new GET /lawfirm_admins/new.xml | def new
@employee = Employee.new
@lawfirm_admin = User.new
@roles = Role.scoped_by_company_id(current_user.company_id)
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @lawfirm_admin }
authorize!(:new,current_user) unless current_user.role?:lawfirm_admin
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @admin = Admin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin }\n end\n end",
"def new\n @admin = Admin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @admin }\n end\n ... | [
"0.7479434",
"0.7479434",
"0.7479434",
"0.73625475",
"0.7280876",
"0.7228282",
"0.7226389",
"0.71882176",
"0.71882176",
"0.7166781",
"0.6993046",
"0.6900532",
"0.6839136",
"0.6838397",
"0.6787496",
"0.67837363",
"0.6780029",
"0.67764145",
"0.6773507",
"0.6769669",
"0.675304",... | 0.0 | -1 |
Creating a new user for lawfirm POST /lawfirm_admins POST /lawfirm_admins.xml | def create
@employee = Employee.new(params[:employee])
@employee.company_id=current_user.company_id
respond_to do |format|
if @employee.save_with_user(params)
flash[:notice] = "#{t(:text_new_user)} " "#{t(:flash_was_successful)} " "#{t(:text_created)}"
format.html { redirect_to lawfirm_admins_url}
format.xml { render :xml => @lawfirm_admin, :status => :created, :location => @lawfirm_admin }
else
format.html { render :action => "new" }
format.xml { render :xml => @lawfirm_admin.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @admin_user = User.new(admin_user_params)\n\n respond_to do |format|\n if @admin_user.save\n format.html { redirect_to @admin_user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @admin_user }\n else\n format.ht... | [
"0.71763515",
"0.71489644",
"0.71198547",
"0.7116344",
"0.7099577",
"0.7099321",
"0.7081512",
"0.70758986",
"0.7055621",
"0.7053395",
"0.70374274",
"0.70353943",
"0.69993305",
"0.6981225",
"0.6969473",
"0.69678545",
"0.69398874",
"0.69397867",
"0.6918515",
"0.691331",
"0.6912... | 0.68165004 | 30 |
PUT /lawfirm_admins/1 PUT /lawfirm_admins/1.xml This function is used to update the lawfirm admin details | def update
@lawfirm_admin = User.find(params[:id])
respond_to do |format|
if @lawfirm_admin.update_attributes(params[:lawfirm_admin])
flash[:notice] = "#{t(:text_lawfirmadmin)} " "#{t(:flash_was_successful)} " "#{t(:text_updated)}"
format.html { redirect_to(@lawfirm_admin) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @lawfirm_admin.errors, :status => :unprocessable_entity }
authorize!(:update,current_user) unless current_user.role?:lawfirm_admin
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @admin = Admin.find(params[:id])\n\n respond_to do |format|\n if @admin.update_attributes(params[:admin])\n format.html { redirect_to([:admin, @admin], :notice => 'Admin was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action ... | [
"0.70015043",
"0.6937324",
"0.68194336",
"0.6771369",
"0.6688973",
"0.6649208",
"0.6625246",
"0.661637",
"0.65906847",
"0.65853345",
"0.6581446",
"0.65613234",
"0.65500945",
"0.6543245",
"0.65211725",
"0.6518823",
"0.6518823",
"0.65128094",
"0.6503596",
"0.6498323",
"0.649218... | 0.74389315 | 0 |
DELETE /lawfirm_admins/1 DELETE /lawfirm_admins/1.xml This function is used to delete the lawfirm admin having provided id | def destroy
@lawfirm_admin = User.find(params[:id])
@lawfirm_employee=Employee.find(:first,:conditions=>["user_id=?",@lawfirm_admin.id])
@product_licence_detail=ProductLicenceDetail.find(:all,:conditions=>["user_id=?",params[:id]])
@subproduct=SubproductAssignment.find(:all,:conditions=>["user_id=? OR employee_user_id=?",params[:id],params[:id]])
respond_to do |format|
if @lawfirm_employee.destroy
for product_licence_detail in @product_licence_detail
product_licence_detail.product_licence.update_attributes(:status=>0)
product_licence_detail.destroy
end
@subproduct.each do |subproduct|
subproduct.destroy
end
@lawfirm_admin.destroy
flash[:notice] = "#{t(:text_new_user)} " "#{t(:flash_was_successful)} " "#{t(:text_deactivated)}"
format.html { redirect_to(:controller=>"lawfirm_admins",:action=>"index") }
format.xml { head :ok }
else
format.html { render :action => "index" }
authorize!(:destroy,current_user) unless current_user.role?:lawfirm_admin
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rem_admin oid\n self.admins.delete oid\n end",
"def destroy\n @admin = Admin.find(params[:id])\n @admin.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_admins_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admin = Admin.find(params[:id])\n... | [
"0.7001102",
"0.69888604",
"0.69888604",
"0.6978432",
"0.6978432",
"0.69739366",
"0.6951878",
"0.6825269",
"0.6825269",
"0.661862",
"0.66075414",
"0.6600806",
"0.6600806",
"0.66003877",
"0.6563595",
"0.65455747",
"0.64972305",
"0.64598364",
"0.6443755",
"0.6438352",
"0.639725... | 0.0 | -1 |
This function is used to update the selected employee details | def update_employee
@user = User.find(params[:id])
@user.update_attributes(:first_name=>params[:lawfirm_admin][:first_name],:last_name=>params[:lawfirm_admin][:last_name])
@employees=Employee.scoped_by_user_id_and_company_id(@user.id,current_user.company_id).first
respond_to do |format|
if @employees.update_attributes(:birthdate => params[:lawfirm_admin][:employee][:birthdate],
:security_question => params[:lawfirm_admin][:employee][:security_question],
:security_answer => params[:lawfirm_admin][:employee][:security_answer],
:billing_rate => params[:lawfirm_admin][:employee][:billing_rate]
)
flash[:notice] = "#{t(:text_user)} " "#{t(:flash_was_successful)} " "#{t(:text_updated)}"
format.html { redirect_to:controller=>"lawfirm_admins",:action=>"index" }
format.xml { head :ok }
else
format.html { render :action => "edit" }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_employee\n @employee = current_user.employees.find(params[:id])\n end",
"def set_employee\n @employee = current_user.employees.find(params[:id])\n end",
"def set_employee_detail\n @employee_detail = EmployeeDetail.find(params[:id])\n end",
"def set_employeedetail\n ... | [
"0.7010766",
"0.69439214",
"0.6918158",
"0.6909097",
"0.68602324",
"0.68302035",
"0.6824709",
"0.6805335",
"0.6800489",
"0.6784139",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
"0.6704679",
... | 0.640846 | 81 |
This function is used to provide the list of deactivated users of the selected company | def deactivated_users
@users=User.find_with_deleted(:all,:conditions=>['company_id=? AND deleted_at IS NOT NULL',current_user.company_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users_eligible_for_cc_list\n User.find(:all, :conditions => 'active=1',:order => 'last_name') -\n Role.find_by_name('HCL Manager').active_users -\n Role.find_by_name('Manager').active_users -\n Role.find_by_name('ECO Admin').active_users ... | [
"0.6757092",
"0.6395814",
"0.6158302",
"0.6103465",
"0.60084844",
"0.5934883",
"0.5920795",
"0.588568",
"0.5873272",
"0.583159",
"0.5816811",
"0.58001757",
"0.5790376",
"0.577243",
"0.5767259",
"0.5761732",
"0.5761732",
"0.5726059",
"0.572201",
"0.5719444",
"0.5711827",
"0.... | 0.7541923 | 0 |
This function is used to reactivate the selected deactivated user | def activate
@users=User.find_with_deleted(params[:id])
@lawfirm_employee=Employee.find_with_deleted(:first,:conditions => {:user_id => @users.id})
respond_to do |format|
if @users.update_attribute('deleted_at','')
@lawfirm_employee.update_attribute('deleted_at','')
flash[:notice] = "#{t(:text_user)} " "#{t(:flash_was_successful)} " "#{t(:text_activated)}"
format.html {redirect_to :controller=>"lawfirm_admins",:action=>"index"}
format.xml { head :ok }
else
format.html { render :action => "deactivated_users" }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reactivate(user)\n if !user.account_active?\n user.reactivate!\n end\n end",
"def activate\r\n Marketplace::Database.instance.delete_deactivated_user(self)\r\n Marketplace::Database.instance.add_user(self)\r\n Marketplace::Activity.create(Activity.USER_REACTIVATE, s... | [
"0.7758062",
"0.756553",
"0.74289834",
"0.7199117",
"0.7058953",
"0.7014198",
"0.6988723",
"0.6914783",
"0.6855231",
"0.68459487",
"0.68384975",
"0.6821023",
"0.67126447",
"0.6705593",
"0.66877896",
"0.6679637",
"0.66748154",
"0.6554469",
"0.6513467",
"0.6510232",
"0.6509916"... | 0.0 | -1 |
Gets the Domain Name | def get_domain(session)
domain = ""
ipv4_info = nil
ipv6_info = nil
begin
subkey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\History"
v_name = "DCName"
domain_dc = registry_getvaldata(subkey, v_name)
rescue
print_error("Could not determine if the host is part of a domain.")
end
if (!domain_dc.nil?)
# leys parse the information
dom_info = domain_dc.split('.')
domain = dom_info[1].upcase
dc = domain_dc.gsub('\\\\','')
print_good("Domain: #{domain}")
print_good("Domain Controller: #{dc}")
# Resolve IPv4 address
begin
ipv4_info = session.net.resolve.resolve_host(dc, AF_INET)
print_good("IPv4: #{ipv4_info[:ip]}")
rescue
print_status("Could not resolve IPv4 for #{dc}")
end
# Resolve IPv6 address
begin
ipv6_info = session.net.resolve.resolve_host(dc, AF_INET6)
print_good("IPv6: #{ipv6_info[:ip]}")
rescue
print_status("Could not resolve IPv6 for #{dc}")
end
else
print_status "Host is not part of a domain."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def domain_name\n return @domain_name\n end",
"def domain_name\n return @domain_name\n end",
"def domain_name\n @domain_name ||= default_name\n end",
"def domain\n unless @domain\n if defined? ActiveSupport::CoreExtensions::S... | [
"0.8669912",
"0.8669912",
"0.8288713",
"0.7990533",
"0.77144927",
"0.77144927",
"0.7672004",
"0.75785726",
"0.75526994",
"0.7537022",
"0.7514205",
"0.74978065",
"0.74932903",
"0.74932903",
"0.7477797",
"0.7467327",
"0.7402699",
"0.7373754",
"0.73704624",
"0.7328876",
"0.73192... | 0.0 | -1 |
Get the query parameters necessary to get the next page of data from Pandora. | def get_next_data_indices(html)
# .js-more-link is found on mobile pages.
show_more = Nokogiri::HTML(html).css('.show_more, .js-more-link')[0]
if show_more
next_indices = {}
data_attributes = ['nextStartIndex', 'nextLikeStartIndex', 'nextThumbStartIndex']
data_attributes.each do |attr_name|
attr = show_more.attributes['data-' + attr_name.downcase]
next_indices[attr_name.to_sym] = attr.value.to_i if attr
end
next_indices
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def params\n @pagination.request.query_parameters\n end",
"def next_page\n url = @entity[:next]\n return unless url\n\n query = URI.decode_www_form(URI(url).query).to_h\n query = query.to_h { |k, v| [k.to_sym, v] }\n self.class.list(**query)\n end",
"def ... | [
"0.6929868",
"0.66783047",
"0.6589785",
"0.64171207",
"0.64108557",
"0.63823503",
"0.6332605",
"0.63242555",
"0.63110876",
"0.6306954",
"0.6299668",
"0.6277547",
"0.6274955",
"0.6257447",
"0.62573224",
"0.6252217",
"0.62498194",
"0.6217454",
"0.620299",
"0.61821204",
"0.61366... | 0.0 | -1 |
Loops over each .infobox container and yields the title and subtitle. | def infobox_each_link(html)
Nokogiri::HTML(html).css('.infobox').each do |infobox|
infobox_body = infobox.css('.infobox-body')
title_link = infobox_body.css('h3 a').text.strip
subtitle_link = infobox_body.css('p a').first
subtitle_link = subtitle_link.text.strip if subtitle_link
yield(title_link, subtitle_link)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def infobox\n infoboxes.first\n end",
"def print_info(info)\n bio = []\n committees = []\n info.each do |li|\n if li.include?(\"ommittee\")\n committees << li\n else\n bio << li\n end\n end\n puts \"---------------------- Personal Bi... | [
"0.56834084",
"0.5539195",
"0.540508",
"0.53586096",
"0.5356067",
"0.5336224",
"0.5262764",
"0.5255277",
"0.5218763",
"0.52040935",
"0.5201281",
"0.5191843",
"0.51775026",
"0.5132716",
"0.5117383",
"0.510193",
"0.5070635",
"0.5040298",
"0.50319785",
"0.50212955",
"0.50076014"... | 0.7267246 | 0 |
Loops over each .doublelink container and yields the title and subtitle. Encountered on mobile pages. | def doublelink_each_link(html)
Nokogiri::HTML(html).css('.double-link').each do |doublelink|
title_link = doublelink.css('.media__bd__header').text.strip
subtitle_link = doublelink.css('.media__bd__subheader').text.strip
yield(title_link, subtitle_link)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_video_page_urls(webpage,options)\r\n puts \"Extracting data from html5 data\"\r\n webpage.css('li.regularitem').each do |post|\r\n link = post.css('h4.itemtitle').css('a').first\r\n description = post.css('div.itemcontent').first.text\r\n download_episode(link.child.text,link['href... | [
"0.5757896",
"0.56283975",
"0.5623225",
"0.5478858",
"0.5420071",
"0.53946555",
"0.5342132",
"0.53353864",
"0.5314344",
"0.5277145",
"0.5217491",
"0.52047503",
"0.5177311",
"0.5176968",
"0.5176968",
"0.5172046",
"0.5168489",
"0.51254624",
"0.5104758",
"0.510346",
"0.50438666"... | 0.76147765 | 0 |
Loops over each .follow_section container. | def get_followx_users(html)
users = []
Nokogiri::HTML(html).css('.follow_section').each do |section|
listener_name = section.css('.listener_name').first
webname = listener_name['webname']
# Remove any 'spans with a space' that sometimes appear with special characters.
listener_name.css('span').each(&:remove)
name = listener_name.text.strip
href = section.css('a').first['href']
users << { name: name, webname: webname, href: href }
end
users
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_section\n @sections.each_value do | section |\n yield( section )\n end\n end",
"def section_looper(email_body)\n section = [:first_section, :second_section, :third_section]\n\n section.each do |section|\n type_looper(email_body, section)\n end\nend",
"def each_secti... | [
"0.5388726",
"0.5186861",
"0.51480687",
"0.5068497",
"0.50241494",
"0.4946938",
"0.48971945",
"0.48966563",
"0.48904923",
"0.4889079",
"0.4866163",
"0.4848056",
"0.48419654",
"0.48185638",
"0.47735327",
"0.47356346",
"0.4717704",
"0.46736893",
"0.4658205",
"0.46570393",
"0.46... | 0.45544216 | 30 |
Creates and initializes a new instance of the ExternalSubscription class. | def initialize(client)
@client = client
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscription\n Zapi::Models::Subscription.new\n end",
"def new\n @subscription = Subscription.new\n end",
"def new\n @subscriber = Subscriber.new\n end",
"def initialize(subscription_purchase)\n @subscription_purchase = subscription_purchase\n end",
"def initia... | [
"0.6230527",
"0.61710626",
"0.6051603",
"0.6007223",
"0.60044414",
"0.5992861",
"0.5931622",
"0.59278744",
"0.59158975",
"0.5833374",
"0.5807633",
"0.5788254",
"0.57842785",
"0.57239157",
"0.57192904",
"0.57192904",
"0.5705709",
"0.5704582",
"0.57011056",
"0.5672389",
"0.5665... | 0.0 | -1 |
route for verifying cas service tickets | def devise_cas_server(mapping, controllers)
# Add specific cas server routes
# "Default" routes are create in the "normal" devise session configuration
resource :session, :only => [], :controller =>
controllers[:cas_server_sessions], :path => '' do
#get :new, :path => mapping.path_names[:sign_in], :as => "new"
#post :create, :path => mapping.path_names[:sign_in], :as => "create"
#match :destroy, :path => mapping.path_names[:sign_out], :as => "destroy"
get "serviceValidate",
:to => "#{controllers[:sessions]}#service_validate"
get "validate",
:to => "#{controllers[:sessions]}#validate"
get "proxyValidate",
:to => "#{controllers[:sessions]}#service_validate"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_ticket(options = {})\n query = create_ticket_query(options)\n make_request(Briareus::Torii::VALIDATE_TICKET, query)\n end",
"def authenticate!\n last_ticket = session[:cas_last_valid_ticket]\n ticket = read_ticket(params)\n\n if ticket\n if resource = mapping.to.... | [
"0.6015382",
"0.59969294",
"0.5995943",
"0.5924438",
"0.5924347",
"0.58806807",
"0.57586455",
"0.5751043",
"0.574028",
"0.5724429",
"0.5716088",
"0.56804955",
"0.5601082",
"0.5588801",
"0.5572531",
"0.55346036",
"0.54623085",
"0.5427396",
"0.538374",
"0.5369777",
"0.53545094"... | 0.56996137 | 11 |
can modify an address if it's not been used in an completed order | def editable?
new_record? || (Spree::Order.complete.where("bill_address_id = ? OR
ship_address_id = ? AND
state != 'complete' AND
shipment_state != 'shipped'", id, id).count == 0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_user_address(user, address)\n logger.debug { \"Work around caTissue prohibition of #{user} address #{address} update by creating a new address record for a dummy user...\" }\n address.identifier = nil\n perform(:create, address) { create_object(address) }\n logger.debug { \"Worked ar... | [
"0.6788056",
"0.67573225",
"0.673295",
"0.673295",
"0.66663474",
"0.66016954",
"0.65904987",
"0.65477854",
"0.6543206",
"0.64874625",
"0.64228237",
"0.6421653",
"0.64139307",
"0.64091563",
"0.6393491",
"0.6385536",
"0.6381176",
"0.63621795",
"0.6309696",
"0.6298268",
"0.62887... | 0.0 | -1 |
Remove readonly validation to be able to modify addresses over the flow | def readonly?
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_original_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def save\n \tself.errors = [\"Shipping Addresses are readonly\"]\n \treturn false\n end",
"def save\n \tself.errors = [\"Shipping Addresses are readonly\"]\n \treturn false\n end",
... | [
"0.6529041",
"0.6417117",
"0.6414065",
"0.6406976",
"0.63714033",
"0.62140036",
"0.5917872",
"0.5861237",
"0.58362716",
"0.583402",
"0.5806216",
"0.57939327",
"0.57844913",
"0.57755953",
"0.57173073",
"0.56794775",
"0.56619424",
"0.56577146",
"0.5621468",
"0.56036043",
"0.559... | 0.0 | -1 |
Use discard ability to not affect order created previously | def destroy
can_be_deleted? ? delete : discard
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discard_order(order)\n @queue.remove(order)\n end",
"def discard; end",
"def discard; end",
"def discard!\n update!(adjustment: 0)\n end",
"def original_order\n end",
"def discard!\n # This should be overridden by concrete adapters.\n end",
"def parts_with_order_remove pa... | [
"0.7194839",
"0.66748106",
"0.66748106",
"0.6154552",
"0.6128351",
"0.60287637",
"0.6027542",
"0.5975205",
"0.59112036",
"0.58811426",
"0.58564126",
"0.5744626",
"0.57152545",
"0.5609577",
"0.56091636",
"0.55947673",
"0.5539908",
"0.5507179",
"0.5493804",
"0.54894567",
"0.547... | 0.0 | -1 |
Applies a block as a mapping on all keys, returning a new hash. | def with_keys
keys.each_with_object self.class.new do |hash_key, hsh|
hsh[ yield hash_key ] = self[ hash_key ]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_mapped(hash, prc, &block)\n new_hash = {}\n hash.each do |k, v|\n new_hash[block.call[k]] = prc.call(v)\n end \n new_hash\nend",
"def map_values &block\n keys.inject({}) {|acc,k|\n acc[k] = yield(k, self[k])\n acc\n }\n end",
"def map_into_hash(&block)\n Hash[*map... | [
"0.7017899",
"0.6760221",
"0.6752278",
"0.6417896",
"0.63462883",
"0.6295345",
"0.6265601",
"0.62649757",
"0.6250273",
"0.6204803",
"0.6175375",
"0.617129",
"0.6165666",
"0.61600757",
"0.611611",
"0.61144835",
"0.60972804",
"0.6071984",
"0.60192746",
"0.601169",
"0.601169",
... | 0.59291345 | 25 |
The difference from with_keys is that modify_keys expects block that takes 2 arguments (key: value pair) and returns the new key. | def modify_keys
each_with_object self.class.new do |hash_pair, hsh|
hsh[ yield( hash_pair ) ] = self[ hash_pair[0] ]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_keys!(options = {}, &block)\n Hash::KeyChanger.new(self).change_keys(options, &block)\n end",
"def transform_keys(&block)\n @key_transformer = block\n end",
"def transform_keys!(&block); end",
"def deep_transform_keys!(&block)\n keys.each do |key|\n value = delete(k... | [
"0.7046134",
"0.6701812",
"0.6563892",
"0.6489941",
"0.6489941",
"0.64120585",
"0.63497555",
"0.6327554",
"0.62617",
"0.6221917",
"0.6221917",
"0.6221917",
"0.6221917",
"0.61262983",
"0.6104013",
"0.6077979",
"0.6073564",
"0.60711193",
"0.6051081",
"0.6031146",
"0.6031146",
... | 0.70331115 | 1 |
Applies a block as a mapping on all values, returning a new hash. | def with_values
each_with_object self.class.new do |(k, v), hsh| hsh[ k ] = yield v end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_into_hash(&block)\n Hash[*map {|x| [x[0], block.call(x)]}.inject([], &:concat)]\n end",
"def map_values &block\n keys.inject({}) {|acc,k|\n acc[k] = yield(k, self[k])\n acc\n }\n end",
"def hash_mapped(hash, prc, &block)\n new_hash = {}\n hash.each do |k, v|\n new_hash[... | [
"0.7244583",
"0.71429604",
"0.7062576",
"0.6548765",
"0.64875376",
"0.64793706",
"0.6475992",
"0.64561754",
"0.64016134",
"0.63935715",
"0.63692224",
"0.63340443",
"0.6298385",
"0.6263541",
"0.6254937",
"0.62542176",
"0.6247096",
"0.6219773",
"0.62044334",
"0.6203134",
"0.617... | 0.54932284 | 82 |
Like do_with_values, but modifies the receiver. | def with_values!
each_with_object self do |(k, v), hsh| hsh[ k ] = yield v end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modify_values!\n each_with_object self do |hash_pair, ꜧ|\n ꜧ[ hash_pair[0] ] = yield( hash_pair )\n end\n end",
"def modify_values\n each_with_object self.class.new do |hash_pair, ꜧ|\n ꜧ[ hash_pair[0] ] = yield( hash_pair )\n end\n end",
"def with_values\n @values = true\n ... | [
"0.6264453",
"0.6167606",
"0.6115198",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"0.6070002",
"... | 0.6076297 | 3 |
The difference from do_with_values is that modify_values expects block that takes 2 arguments (key: value pair) and returns the new value. | def modify_values
each_with_object self.class.new do |hash_pair, ꜧ|
ꜧ[ hash_pair[0] ] = yield( hash_pair )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modify_values!\n each_with_object self do |hash_pair, ꜧ|\n ꜧ[ hash_pair[0] ] = yield( hash_pair )\n end\n end",
"def transform_values! &block # :yields: value\n return enum_for(:transform_values!) unless block_given?\n each do |k, v|\n store k, (yield v)\n end\n self\n ... | [
"0.70878273",
"0.6709955",
"0.6445185",
"0.6364775",
"0.6345696",
"0.61099946",
"0.6093925",
"0.59731215",
"0.59385407",
"0.5900864",
"0.587235",
"0.5830395",
"0.58281344",
"0.57860756",
"0.57767963",
"0.57549393",
"0.5705455",
"0.570011",
"0.56847584",
"0.56792855",
"0.56760... | 0.69693863 | 1 |
Like modify_values, but modifies the receiver. | def modify_values!
each_with_object self do |hash_pair, ꜧ|
ꜧ[ hash_pair[0] ] = yield( hash_pair )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_values(values)\n before_update_values\n this.update(set_values(values))\n end",
"def prepared_modify_values\n @opts[:prepared_modify_values]\n end",
"def update_values\n end",
"def update_values\n end",
"def update!(**args)\n @values = args[:values] if... | [
"0.6396381",
"0.62501186",
"0.61811745",
"0.61811745",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"0.604556",
"... | 0.6025924 | 47 |
Like map that returns a hash. | def modify
each_with_object self.class.new do |hash_pair, ꜧ|
key, val = yield hash_pair
ꜧ[key] = val
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash(*) end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash(key); end",
"def hash()\n #This is a stub, used for indexing\n end",
"def hash; end",
"def hash; end",
"def hash; end",
"def ... | [
"0.8170091",
"0.7908991",
"0.7908991",
"0.7908991",
"0.7908991",
"0.7908991",
"0.7908991",
"0.7908991",
"0.7883063",
"0.77076054",
"0.76870644",
"0.76870644",
"0.76870644",
"0.76870644",
"0.76870644",
"0.76870644",
"0.76870644",
"0.76870644",
"0.76870644",
"0.76870644",
"0.74... | 0.0 | -1 |
A bit like Arrayslice, but only takes 1 argument, which is either a Range, or an Array, and returns the selection of the hash for the keys that match the range or are present in the array. | def slice matcher
self.class[ case matcher
when Array then
select { |key, _| matcher.include? key }
else
select { |key, _| matcher === key }
end ]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slice(*keys)\n self.select { |k,v| keys.include?(k) }\n end",
"def slice_hash\n items = @selector.scan(/['|\"](\\w+)['|\"]/).flatten\n return {} if items.empty?\n if items.size == 1\n items[0] = items[0].to_s if items[0].is_a?(Symbol)\n @value.select {|key| key.to_s.match(ite... | [
"0.633876",
"0.5887167",
"0.587299",
"0.5757401",
"0.5737074",
"0.5715574",
"0.5698993",
"0.56831104",
"0.5671356",
"0.56427866",
"0.55725247",
"0.55609095",
"0.5527846",
"0.5519133",
"0.5504924",
"0.5504924",
"0.54737115",
"0.5471463",
"0.54487014",
"0.5444409",
"0.5407212",... | 0.7008151 | 0 |
Prettyprints the hash consisting of names as keys, and numeric values. Takes 2 named arguments: +:gap+ and +:precision+. | def pretty_print_numeric_values gap: 0, precision: 2
key_strings = keys.map &:to_s
value_strings = values.map { |n| "%.#{precision}f" % n rescue "%s" % n }
lmax, rmax = key_strings.map( &:size ).max, value_strings.map( &:size ).max
lgap = gap / 2
rgap = gap - lgap
key_strings.zip( value_strings ).map do |kς, vς|
"%- #{lmax+lgap+1}s%#{rmax+rgap+1}.#{precision}f" % [ kς, vς ]
end.each { |line| puts line }
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pretty_format\n pretty = \"\"\n sorted = @hash.sort_by { |name, arrays| name }\n\n sorted.each { |name, array|\n pretty.concat(name)\n pretty.concat(\": \")\n pretty.concat(\"#{@hash[name].join(\",\")}\\n\")\n\n }\n pretty\n\n ### FILL IN YOUR CODE HERE\n end",
"def pretty_v... | [
"0.6146382",
"0.6140371",
"0.594296",
"0.58612174",
"0.5827848",
"0.57910174",
"0.57910174",
"0.55943",
"0.556954",
"0.5556113",
"0.5476537",
"0.54356927",
"0.5401115",
"0.5388913",
"0.5348654",
"0.53310674",
"0.52935606",
"0.5293029",
"0.52821684",
"0.5275408",
"0.5253943",
... | 0.7695462 | 0 |
GET /page_modules/1 GET /page_modules/1.xml | def show
@page_module = PageModule.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @page_module }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @page_module = PageModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page_module }\n end\n end",
"def index\n @learning_modules = LearningModule.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n fo... | [
"0.64441085",
"0.63864636",
"0.6316744",
"0.62338394",
"0.6195307",
"0.6128555",
"0.61051494",
"0.6068587",
"0.6030302",
"0.5996949",
"0.59323084",
"0.5863857",
"0.5822671",
"0.5817481",
"0.58161277",
"0.5808764",
"0.57973474",
"0.57889366",
"0.57724065",
"0.57589155",
"0.574... | 0.7119129 | 0 |
GET /page_modules/new GET /page_modules/new.xml | def new
@page_module = PageModule.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @page_module }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @svn_module = SvnModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @svn_module }\n end\n end",
"def new\n @appmodule = Appmodule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml =>... | [
"0.7211834",
"0.7063084",
"0.7055166",
"0.7029531",
"0.69596004",
"0.6869985",
"0.6794622",
"0.67838895",
"0.67770994",
"0.67291987",
"0.67200124",
"0.6697786",
"0.66902775",
"0.6663735",
"0.66628087",
"0.66628087",
"0.66628087",
"0.66628087",
"0.66628087",
"0.66628087",
"0.6... | 0.8038531 | 0 |
POST /page_modules POST /page_modules.xml | def create
@page_module = PageModule.new(params[:page_module])
respond_to do |format|
if @page_module.save
format.html { redirect_to(@page_module) }
format.xml { render :xml => @page_module, :status => :created, :location => @page_module }
format.json { render :text => '{status: "success", message: "成功创建页面模块!"}'}
else
format.html { render :action => "new" }
format.xml { render :xml => @page_module.errors, :status => :unprocessable_entity }
format.json { render :text => "{status: 'failed', error:#{@page_module.errors.full_messages.to_json}}"}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @page_module = PageModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page_module }\n end\n end",
"def rest__create\n module_name = ret_non_null_request_params(:module_name)\n project = get_default_project()\n version = ... | [
"0.6172559",
"0.5698494",
"0.56774724",
"0.5618915",
"0.5584754",
"0.55631",
"0.54533476",
"0.53862584",
"0.5321248",
"0.5309977",
"0.5309809",
"0.52856034",
"0.5281201",
"0.5243053",
"0.52375484",
"0.52229965",
"0.52229315",
"0.5183277",
"0.51749605",
"0.5171544",
"0.5143474... | 0.674445 | 0 |
PUT /page_modules/1 PUT /page_modules/1.xml | def update
@page_module = PageModule.find(params[:id])
respond_to do |format|
if @page_module.update_attributes(params[:page_module])
format.html { redirect_to(@page_module) }
format.xml { head :ok }
format.json { render :text => '{status: "success", message: "成功更新页面模块!"}'}
else
format.html { render :action => "edit" }
format.xml { render :xml => @page_module.errors, :status => :unprocessable_entity }
format.json { render :text => "{status: 'failed', error:#{@page_module.errors.full_messages.to_json}}"}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @page = @club.pages.find(params[:id])\n @page.parent_id = params[:page][:parent_id];\n @page.bns_parent_id = params[:page][:parent_id];\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Pages was successfully updated.'\n format.html... | [
"0.59389526",
"0.5787512",
"0.5784629",
"0.57132316",
"0.57057506",
"0.5674034",
"0.56611675",
"0.56547356",
"0.5620115",
"0.56027734",
"0.5601884",
"0.5565209",
"0.55565965",
"0.55315083",
"0.54726744",
"0.54539186",
"0.5419073",
"0.5417409",
"0.54015625",
"0.5384152",
"0.53... | 0.6645081 | 0 |
DELETE /page_modules/1 DELETE /page_modules/1.xml | def destroy
@page_module = PageModule.find(params[:id])
@page_module.destroy
respond_to do |format|
format.html { redirect_to(page_modules_url) }
format.xml { head :ok }
format.json { render :text => '{status: "success"}'}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_module(org_unit_id, module_id) # DELETE\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/modules/#{module_id}\"\n _delete(query_string)\nend",
"def test_delete_Module\n printf \"\\n@T:#{__method__}\\n\"\n @root = XMLParse.read(\"./tp/test001.xml\")\n golden = [\"D78F1070_EVA... | [
"0.68101585",
"0.66718405",
"0.6510412",
"0.65000826",
"0.6397475",
"0.6387917",
"0.6375594",
"0.628308",
"0.6280498",
"0.62571305",
"0.62564474",
"0.6247245",
"0.6243638",
"0.6240921",
"0.6230516",
"0.6230036",
"0.62296003",
"0.6206045",
"0.6196667",
"0.614248",
"0.60882574"... | 0.73013556 | 0 |
Equality provided mostly for tests. | def ==(other)
stream == other.stream
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other); false; end",
"def ==(*) end",
"def ==(*) end",
"def ==(*) end",
"def eql?(*) end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other); end",
"def ==(other);... | [
"0.7498505",
"0.7401098",
"0.7401098",
"0.7401098",
"0.7356036",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"0.73420465",
"... | 0.0 | -1 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.user_digest_notifier.weekly_progress_report.subject | def weekly_progress_report(user)
@greeting = "Hi"
user_email = @user.email
mail to: user_email
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject\n 'Report a problem'.freeze\n end",
"def email_subject\n sponsor_name = @config.plan.sponsor_name\n display_date = @date.to_s()\n if @config.div_id.present?\n email_subject = \"Payroll report for #{sponsor_name} for division #{@config.division_name}: #{display_date}\"\n else\... | [
"0.63985217",
"0.63680905",
"0.62382925",
"0.622144",
"0.60749763",
"0.60481554",
"0.604445",
"0.6021055",
"0.60129136",
"0.6012118",
"0.600614",
"0.600614",
"0.600614",
"0.600614",
"0.600614",
"0.600614",
"0.5974092",
"0.59584045",
"0.5956085",
"0.5953197",
"0.59258866",
"... | 0.5862136 | 24 |
Define el usuario con el usuario actual | def set_current_user
@user = current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_usuario\n \n end",
"def set_usuario\n @usuario = Usuario.find_by_email(current_usuario.email)\n end",
"def usuario_actual\n \t#se guarda al usuario actual que esta loggeado por cuestion de eficiencia\n \t#para no accesar a la base de datos todo el tiempo\n \t@usuario_actual ||= Alumno.find(... | [
"0.7737487",
"0.69332933",
"0.6925791",
"0.6906926",
"0.6869586",
"0.6801229",
"0.67418927",
"0.66249955",
"0.6600067",
"0.65694207",
"0.6543689",
"0.6543689",
"0.6543689",
"0.6543689",
"0.6543689",
"0.6543689",
"0.6543689",
"0.6543413",
"0.6519364",
"0.6505991",
"0.6480298",... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def image_create_params
params.require(:user).permit(images_attributes: [:title, :description, :image, :imageable])
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.6980957",
"0.6783065",
"0.6747844",
"0.6741468",
"0.67356336",
"0.6592548",
"0.65036845",
"0.64978707",
"0.64825076",
"0.64795035",
"0.64560914",
"0.64397955",
"0.6379666",
"0.6376688",
"0.6366702",
"0.6319728",
"0.6300833",
"0.6300629",
"0.6294277",
"0.6293905",
"0.629117... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def image_params
params.require(:image).permit(:title, :description, :image, :_destroy)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
==== Options options :column_width Width (in pixels) of current grid column :gutter_width Width (in pixels) of current grid gutter :output_path Output path of grid.png file | def initialize(options={})
@able_to_generate = Magick::Long_version rescue false
return unless @able_to_generate
@column_width = options[:column_width] || Blueprint::COLUMN_WIDTH
@gutter_width = options[:gutter_width] || Blueprint::GUTTER_WIDTH
@output_path = options[:output_path] || Blueprint::SOURCE_PATH
@baseline_height = (options[:font_size] || Blueprint::FONT_SIZE) * 1.5
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate!\n total_width = self.column_width + self.gutter_width\n height = @baseline_height\n RVG::dpi = 100\n\n width_in_inches = (total_width.to_f/RVG::dpi).in\n height_in_inches = (height.to_f/RVG::dpi).in\n rvg = RVG.new(width_in_inches, height_in_inches).viewbox(0, 0, total_w... | [
"0.6871367",
"0.6410099",
"0.6394213",
"0.6394213",
"0.63460773",
"0.6181151",
"0.61784434",
"0.61466855",
"0.6085754",
"0.60473514",
"0.5983421",
"0.59493095",
"0.58982646",
"0.5891894",
"0.5871704",
"0.58049023",
"0.5780123",
"0.5710571",
"0.57018894",
"0.5695028",
"0.56888... | 0.5334401 | 54 |
generates (overwriting if necessary) grid.png image to be tiled in background | def generate!
total_width = self.column_width + self.gutter_width
height = @baseline_height
RVG::dpi = 100
width_in_inches = (total_width.to_f/RVG::dpi).in
height_in_inches = (height.to_f/RVG::dpi).in
rvg = RVG.new(width_in_inches, height_in_inches).viewbox(0, 0, total_width, height) do |canvas|
canvas.background_fill = "white"
end
white = ChunkyPNG::Color.from_hex("ffffff")
background = ChunkyPNG::Color.from_hex("e8effb")
line = ChunkyPNG::Color.from_hex("e9e9e9")
png = ChunkyPNG::Image.new(total_width, height, white)
png.rect(0, 0, column_width - 1, height, background, background)
png.rect(0, height - 1, total_width, height - 1, line, line)
FileUtils.mkdir(self.output_path) unless File.exists?(self.output_path)
png.save(File.join(self.output_path, "grid.png"))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_background_image\n split_tile_set_into_tiles\n create_image_list\n\n montage_cmd = \"montage #{@image_list.join(' ')} \"\n montage_cmd += \"-tile #{@maps[:background][0].size}x \"\n montage_cmd += \"-geometry 32x32+0+0 media/grid_one/full_map_image.png\"\n\n system(\"#{mont... | [
"0.7242048",
"0.69752586",
"0.6765756",
"0.6647319",
"0.6641062",
"0.66382104",
"0.6559242",
"0.64883244",
"0.64482284",
"0.6430685",
"0.641923",
"0.63475573",
"0.6343082",
"0.6322847",
"0.6301475",
"0.6280671",
"0.62604064",
"0.6230976",
"0.6205737",
"0.6153527",
"0.61211485... | 0.69902235 | 1 |
f("fixed1", "fixed2", conditional1: true, conditional2: false) => "fixed1 fixed2 conditional1" | def css_classes_for(*args)
return nil if args.empty?
conditions = args.extract_options!
classes = args.dup
conditions.each { |clas, condition| classes << clas if condition }
classes.join(" ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def foo a\r\n if a==1; \"one\" elsif a==2; \"two\" else \"unknown\" end\r\nend",
"def thing(fave_one, fave_two, fave_three)\n \"I love that #{fave_two} too!\"\nend",
"def yeah_or_boo( a,b )\n (a > b) && 'yeah' || 'boo'\nend",
"def boolean_string(rollercoaster)\r\n\tboolean_string = \"\"\r\n\tif rollercoas... | [
"0.62455",
"0.6011409",
"0.58554053",
"0.58431995",
"0.583929",
"0.5825008",
"0.5817523",
"0.57702065",
"0.57702065",
"0.5703952",
"0.56303495",
"0.5625525",
"0.55876",
"0.5579959",
"0.5552538",
"0.5548991",
"0.5539984",
"0.5519309",
"0.549717",
"0.5458062",
"0.54541546",
"... | 0.0 | -1 |
superclass overrides to deal with issues found | def on_callback_path?
# path comparison was failing due to trailing / needed in callback_path option
on_path?(callback_path.delete_suffix("/"))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def errors\n raise 'Method should implemented in inherit class'\n end",
"def issue(*)\n raise NotImplementedError, 'This should be defined in a subclass'\n end",
"def wrapped_causes; end",
"def failure\n super\n end",
"def onerror(&blk); super; end",
"def process_fix\n super\n ... | [
"0.70418084",
"0.6783789",
"0.6609213",
"0.65850514",
"0.6546582",
"0.65158474",
"0.6497864",
"0.6317366",
"0.6317366",
"0.62574524",
"0.6256722",
"0.6234005",
"0.6222967",
"0.6214903",
"0.6211196",
"0.61958206",
"0.6153782",
"0.61146486",
"0.6104191",
"0.60779",
"0.60733485"... | 0.0 | -1 |
~ Instance methods ......................................................... | def contains?(date_or_time)
starts_on <= date_or_time && date_or_time < ends_on
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def initialize\n\t\t\n\tend",
"def implementation; end",
"def implementation; end",
"def initialize\r\n\r\n end",
"def initialize\n \n end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def initialize\n\n end",
"def initialize\n\n end",... | [
"0.837986",
"0.74969923",
"0.7377104",
"0.7377104",
"0.73759943",
"0.7366034",
"0.73333216",
"0.73333216",
"0.73333216",
"0.73333216",
"0.7287168",
"0.7287168",
"0.72387356",
"0.72387356",
"0.72387356",
"0.72387356",
"0.72387356",
"0.72387356",
"0.72387356",
"0.72387356",
"0.... | 0.0 | -1 |
Returns this user's Holding object for a given outcome. | def holdings_of(outcome)
holdings.where(outcome: outcome).first || NullHolding.new(self, outcome)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_holding\n @holding = current_user.holdings.find(params[:id])\n end",
"def set_user_holding\n @user_holding = UserHolding.find(params[:id])\n end",
"def set_loot_outcome\n @loot_outcome = LootOutcome.find(params[:id])\n end",
"def set_holding\n @holding = Holding.find(para... | [
"0.6100916",
"0.5879758",
"0.5676972",
"0.5650062",
"0.5148491",
"0.5148491",
"0.51346636",
"0.5113165",
"0.50934076",
"0.50280094",
"0.5016231",
"0.49437737",
"0.49345815",
"0.49307293",
"0.4896056",
"0.48681924",
"0.48611388",
"0.4850958",
"0.4830227",
"0.48171467",
"0.4786... | 0.7762998 | 0 |
Create a new domain model object based on the given array of models. The given models are assumed to be subclasses of ActiveRecord::Base. | def initialize(models = [], options = {})
@models, @options = models, RailsERD.options.merge(options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instantiate_models(model_class, source)\n return nil if source.nil?\n\n source = prepare_source model_class, source\n\n case source\n when Array\n source.map { |entry| instantiate_models model_class, entry }\n when Hash\n instantiate_model_from_attributes_hash model_class... | [
"0.6667679",
"0.6140844",
"0.59559953",
"0.5891997",
"0.5807097",
"0.5717256",
"0.5671524",
"0.56481475",
"0.562234",
"0.5579276",
"0.5532433",
"0.55264795",
"0.5514828",
"0.5514298",
"0.5505385",
"0.53988016",
"0.5269133",
"0.5204758",
"0.5195574",
"0.51075447",
"0.5092658",... | 0.58664167 | 4 |
Returns the domain model name, which is the name of your Rails application or +nil+ outside of Rails. | def name
defined? Rails and Rails.application and Rails.application.class.parent.name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model_name\n @model.name.demodulize.downcase # ex: posts\n end",
"def model_name\n @model_class ? @model_class.name.demodulize.underscore : self.controller_name.singularize\n end",
"def app_name\n @app_name ||= Rails.app_class.module_parent_name.demodulize.underscore.dasherize\n ... | [
"0.7263753",
"0.71700656",
"0.71473324",
"0.71356696",
"0.7116998",
"0.7052671",
"0.7023878",
"0.69063574",
"0.6862865",
"0.68619114",
"0.68480366",
"0.68460035",
"0.6825837",
"0.6799385",
"0.67410547",
"0.6709598",
"0.67048955",
"0.66771245",
"0.66571885",
"0.6654276",
"0.66... | 0.63760996 | 46 |
Returns all entities of your domain model. | def entities
@entities ||= Entity.from_models(self, @models)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all\n Ribs.with_handle(self.database) do |h|\n h.all(self.metadata.persistent_class.entity_name)\n end\n end",
"def retrieve_all_entities\n response = self.execute(\"RetrieveAllEntities\", {\n EntityFilters: \"Entity\",\n RetrieveAsIfPublished: true\n },\... | [
"0.78919375",
"0.7597153",
"0.75428873",
"0.7468397",
"0.73357433",
"0.72966325",
"0.71746904",
"0.71746904",
"0.7119073",
"0.7119073",
"0.7065918",
"0.70393616",
"0.7035165",
"0.7013245",
"0.69978917",
"0.6986583",
"0.69726026",
"0.696538",
"0.69212455",
"0.6655511",
"0.6633... | 0.7700775 | 1 |
Returns all relationships in your domain model. | def relationships
@relationships ||= Relationship.from_associations(self, associations)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relationships\n model.relationships(repository.name)\n end",
"def relationships\n return [] if empty?\n\n map { |table| Relationship.new(table, TABLE_R, \"../#{table.pn}\") }\n end",
"def list_relationships\n end",
"def relationships\n @relationships ||= {}\n end",
... | [
"0.81011456",
"0.77505183",
"0.7689656",
"0.74655145",
"0.74451214",
"0.7269916",
"0.7255221",
"0.72459984",
"0.719619",
"0.7099128",
"0.7099128",
"0.70877177",
"0.7014621",
"0.69073766",
"0.6791667",
"0.67849773",
"0.67699486",
"0.675404",
"0.6697717",
"0.6570556",
"0.652413... | 0.787333 | 1 |
Returns all specializations in your domain model. | def specializations
@specializations ||= Specialization.from_models(self, @models)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @spec_types = SpecType.all\n end",
"def models\n Typus::Configuration.config.map { |i| i.first }.sort\n end",
"def all\n all_by_type.values.flatten\n end",
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model... | [
"0.62716216",
"0.6215123",
"0.6198799",
"0.6145743",
"0.6068127",
"0.6056818",
"0.60310155",
"0.5995114",
"0.5879379",
"0.5847136",
"0.58442813",
"0.5817161",
"0.5786486",
"0.57570124",
"0.5728031",
"0.57151574",
"0.5676308",
"0.5675259",
"0.5659265",
"0.56174445",
"0.5616258... | 0.8277926 | 0 |
Returns a specific entity object for the given Active Record model. | def entity_for(model) # @private :nodoc:
entity_mapping[model] or raise "model #{model} exists, but is not included in domain"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_model\n model_name.camelize.constantize.find( params[:id] )\n end",
"def fetch_record_by_param\n model.find(params[:id])\n end",
"def get_object(key, model)\n @objects ||= {}\n @objects[key] = model.safe_find(get_integer(key)) unless @objects.key?(key)\n @objects[key]\n end",
"def... | [
"0.6862012",
"0.6601415",
"0.65724206",
"0.6552234",
"0.652704",
"0.652704",
"0.6523794",
"0.651006",
"0.64794374",
"0.64722514",
"0.64207894",
"0.64043504",
"0.636373",
"0.63372946",
"0.633343",
"0.62897295",
"0.62570363",
"0.62390476",
"0.62182724",
"0.6168461",
"0.61416525... | 0.69501793 | 0 |
Returns an array of relationships for the given Active Record model. | def relationships_for(model) # @private :nodoc:
relationships_mapping[model] or []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relationships\n model.relationships(repository.name)\n end",
"def relation_all(model)\n validate_model(model)\n model.all\n end",
"def relationships\n return [] if empty?\n\n map { |table| Relationship.new(table, TABLE_R, \"../#{table.pn}\") }\n end",
"def associations\n... | [
"0.7202642",
"0.71134764",
"0.690465",
"0.680955",
"0.6733298",
"0.6652221",
"0.66227376",
"0.6468133",
"0.6446618",
"0.64291877",
"0.64210516",
"0.6378718",
"0.6329107",
"0.6291643",
"0.6291643",
"0.62878793",
"0.6255121",
"0.62406874",
"0.60722697",
"0.6070839",
"0.6057531"... | 0.8166936 | 0 |
taken from CGI::escape tweaked to fix exception | def escape(string)
string.gsub(/([^ a-zA-Z0-9_.-]+)/) do
$1.nil? ? nil : ('%' + $1.unpack('H2' * $1.bytesize).
compact.join('%').upcase)
end.tr(' ','+')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cgi_escape(input); end",
"def safe_escape(uri); end",
"def check_and_escape(url)\n check url\n CGI.escape url\n end",
"def escape(string); end",
"def uri_escape(input); end",
"def escape(str); end",
"def escape(str)\n CGI.escape(str)\n end",
"def e(value)\n CGI.escape(va... | [
"0.8084458",
"0.73213637",
"0.7263439",
"0.7167144",
"0.71358263",
"0.7029205",
"0.6817555",
"0.6706272",
"0.66064715",
"0.65852493",
"0.6577379",
"0.65755105",
"0.6549132",
"0.6541183",
"0.65331733",
"0.6502181",
"0.6501331",
"0.649861",
"0.64928687",
"0.649137",
"0.64805925... | 0.0 | -1 |
Sets the default namespace to use to the given value, or (if the value is nil or false) to the value returned by the given block. Example: class Project < ActiveRecord::Base set_table_name "project" end | def set_default_namespace(value = nil, &block)
define_attr_method :default_namespace, value, &block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def namespace(value = nil)\n if value\n @namespace = value\n else\n @namespace\n end\n end",
"def set_table_name(value = nil, &block)\n define_attr_method :table_name_without_shard, value, &block\n end",
"def table_name=(value)\n @original_table_name = @ta... | [
"0.6380705",
"0.63291216",
"0.60748833",
"0.5974105",
"0.5974105",
"0.59392923",
"0.5932018",
"0.5927515",
"0.5853463",
"0.5853463",
"0.5810484",
"0.5806982",
"0.5780072",
"0.5780072",
"0.5767254",
"0.5745242",
"0.57407093",
"0.5740127",
"0.5735612",
"0.5721895",
"0.57172245"... | 0.7187948 | 0 |
Defines an "attribute" method (like inheritance_column or table_name). A new (class) method will be created with the given name. If a value is specified, the new method will return that value (as a string). Otherwise, the given block will be used to compute the value of the method. The original method will be aliased, with the new name being prefixed with "original_". This allows the new method to access the original value. Example: class A < ActiveRecord::Base define_attr_method :primary_key, "sysid" define_attr_method( :inheritance_column ) do original_inheritance_column + "_id" end end | def define_attr_method(name, value=nil, &block)
sing = class << self; self; end
sing.send :alias_method, "original_#{name}", name
if block_given?
sing.send :define_method, name, &block
else
# use eval instead of a block to work around a memory leak in dev
# mode in fcgi
sing.class_eval "def #{name}; #{value.to_s.inspect}; end"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_attr_method(name, value=nil, &block)\n case self.connection.adapter_name\n\n when 'PostgreSQL'\n sing = class << self; self; end\n self.class.send :alias_method, \"#{name}\", name\n if block_given?\n sing.send :define_method, name, &block\n else\n ... | [
"0.76874965",
"0.76735723",
"0.7505815",
"0.7474545",
"0.71693015",
"0.71641016",
"0.7155682",
"0.7054294",
"0.6966722",
"0.6955874",
"0.6834607",
"0.6814022",
"0.67936796",
"0.6706752",
"0.66608965",
"0.6630631",
"0.6578157",
"0.65235114",
"0.65134764",
"0.65099055",
"0.6505... | 0.7907928 | 0 |
Confirms a loggedin user. | def require_auth
head :unauthorized unless current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_user\n @user = User.find(params[:id])\n if !current_user?(@user)\n message = \"currently logged in as #{current_user.name}. Not you? \"\n message += \"#{view_context.link_to('Log out.', log_out)}\".html_safe\n flash[:warning] = message\n redirect_to(root_url)\n ... | [
"0.70087826",
"0.6982988",
"0.6919373",
"0.688131",
"0.6845446",
"0.68326277",
"0.67944413",
"0.67929715",
"0.6642435",
"0.6624581",
"0.66114175",
"0.66022736",
"0.6589018",
"0.65539706",
"0.65349805",
"0.65303934",
"0.6512816",
"0.650312",
"0.64878744",
"0.6487622",
"0.64804... | 0.0 | -1 |
auto switch broadcast from live to complete | def validate_broadcast!
# we can't check it each time when user open transmission page
# it generates too many api calls
broadcast_status = Rails.cache.fetch("broadcast_status_#{id}", expires_in: 3.hours) do
broadcast_service.status
end
if broadcast_status == 'complete'
complete!
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def broadcast\n end",
"def broadcast_example_b1\n end",
"def instant_broadcast_processing?\n true\n end",
"def broadcast_ready_changed\n data = {\n action: 'players_ready'\n }\n ActionCable.server.broadcast \"game:#{@room.id}\", data\n end",
"def run!\n broadcast!\n super\n ... | [
"0.7423565",
"0.66371185",
"0.6208594",
"0.61926943",
"0.6174324",
"0.599948",
"0.59905565",
"0.5972775",
"0.5972775",
"0.58450663",
"0.58252233",
"0.5815035",
"0.57889396",
"0.5781223",
"0.57754594",
"0.57260394",
"0.5665126",
"0.5638281",
"0.5631563",
"0.5630843",
"0.562942... | 0.57805824 | 14 |
GET /answers GET /answers.json | def index
redirect_to root_path and return unless current_user.admin? #FIXME Make this it is visible to instructors
@answers = Answer.where('assignment_id = ? and active =?', params[:assignment_id], true).order('user_id').order('created_at DESC').paginate(:page => params[:page])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def answers\n request('answers')\n end",
"def index\n\n @answers = Answer.current\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def answers\n @celebrity = Celebrity.find(params[:id])\n @answers = @celebrity... | [
"0.8011635",
"0.7718146",
"0.7686177",
"0.76641846",
"0.76641846",
"0.76641846",
"0.76641846",
"0.75861204",
"0.75337416",
"0.7378286",
"0.72804594",
"0.72647053",
"0.7170898",
"0.7170898",
"0.7170898",
"0.71279556",
"0.7089768",
"0.7056577",
"0.7055519",
"0.6962942",
"0.6962... | 0.0 | -1 |
GET /answers/1 GET /answers/1.json | def show
respond_to do |format|
format.html {redirect_to root_path}
format.text {render text: @answer.response}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end",
"def index\n\n @answers = Answer.current\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n ... | [
"0.8064372",
"0.7594417",
"0.7428456",
"0.7428456",
"0.7428456",
"0.7428456",
"0.7339359",
"0.72826004",
"0.72826004",
"0.72826004",
"0.71105605",
"0.7107359",
"0.7090169",
"0.7037905",
"0.70348716",
"0.6962064",
"0.68762743",
"0.6874184",
"0.6832382",
"0.6809381",
"0.6796853... | 0.62045914 | 94 |
POST /answers POST /answers.json | def create
@answer = Answer.new(answer_params)
@answer.assignment = Assignment.find(params[:assignment_id])
@answer.user = current_user
respond_to do |format|
if @answer.save
format.html { redirect_to (@answer.assignment or @answer), notice: 'Answer was successfully created.' }
format.json { render action: 'show', status: :created, location: @answer }
format.js
else
format.html { render action: 'new' }
format.json { render json: @answer.errors, status: :unprocessable_entity }
format.js
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def answers\n request('answers')\n end",
"def add_answer\n request('answers/add')\n end",
"def create\n @question = Question.find(params[:question_id])\n @answer = @question.answers.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redi... | [
"0.7289319",
"0.7276055",
"0.7215647",
"0.71726567",
"0.7067945",
"0.7067945",
"0.70665044",
"0.70541114",
"0.70526284",
"0.7042241",
"0.7038466",
"0.69990367",
"0.6996154",
"0.6996154",
"0.69576937",
"0.6925406",
"0.6923861",
"0.6923151",
"0.69152343",
"0.6890862",
"0.684457... | 0.0 | -1 |
PATCH/PUT /answers/1 PATCH/PUT /answers/1.json | def update
unless @answer.user == current_user or current_user.instructor_for?(@answer.assignment.course)
redirect_to assignment_path(@answer.assignment), alert: "You can only edit your own answers!" and return
end
if @answer.submitted?
redirect_to @answer.assignment, alert: "You submitted this answer for a review, so you can't change it anymore." and return
end
respond_to do |format|
if @answer.update(answer_params.merge(active: true)) #set active to true so the answer shows up everywhere
format.html { redirect_to (@answer), notice: 'Answer was successfully updated.' }
format.json { head :no_content }
format.js
else
format.html { render action: 'edit' }
format.json { render json: @answer.errors, status: :unprocessable_entity }
format.js {flash[:alert] = @answer.errors.full_messages.join(","); render}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @question = Question.update(params[:id], { \n :body => params[:body], \n :answer_type => params[:answer_type] }, \n params[:answers].values\n )\n\n respond_to do |format|\n format.json { render :json => @question.as_json({:include => :answers}) }\n\n # if @que... | [
"0.74345315",
"0.7360197",
"0.7190411",
"0.70442027",
"0.70442027",
"0.7028407",
"0.7019093",
"0.6977991",
"0.69718504",
"0.6914882",
"0.6914467",
"0.6898194",
"0.68933165",
"0.68796027",
"0.6867792",
"0.6852608",
"0.68504494",
"0.68504494",
"0.68504494",
"0.67942584",
"0.678... | 0.0 | -1 |
DELETE /answers/1 DELETE /answers/1.json | def destroy
@assignment = @answer.assignment
@answer.destroy
respond_to do |format|
format.html { redirect_to @assignment }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n answer = Answer.find(params[:answer_id])\n answer.destroy\n \n render json: {success: true}\n end",
"def destroy\n @answer = Answer.find_by_key(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :n... | [
"0.78710014",
"0.78369373",
"0.7804042",
"0.7804042",
"0.7779011",
"0.7779011",
"0.77608424",
"0.76613045",
"0.7621687",
"0.7613219",
"0.75670874",
"0.75555795",
"0.75216275",
"0.7514131",
"0.7514131",
"0.7514131",
"0.7514131",
"0.7514131",
"0.75009054",
"0.75009054",
"0.7500... | 0.0 | -1 |
To import csv answers | def upgrade
#from submitted for early feedback to submitted for final feedback
@answer = Answer.find(params[:id])
@answer.submitted = true
@answer.is_final = true
@answer.submitted_at = Time.now
respond_to do |format|
if @answer.save
format.html {redirect_to assignment_path(@answer.assignment), notice: "Your draft was submitted to be graded"}
format.json { head :no_content }
format.js
else
format.html {redirect_to answer_path(@answer), alert: "We couldn't submit your assignment because " + @answer.errors.full_messages.join(". ")}
format.json { render json: @answer.errors, status: :unprocessable_entity }
format.js
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_csv_full\n \n end",
"def import_csv_smart\n \n end",
"def import_from_csv(file_name)\r\n #implementation goes here\r\n csv_text = File.read(file_name)\r\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\r\n # #8 iterate over table rows, create hash for each,... | [
"0.7265433",
"0.6926908",
"0.64697284",
"0.64539534",
"0.6453542",
"0.64080936",
"0.6397478",
"0.63435084",
"0.6275576",
"0.62676257",
"0.62381655",
"0.6237344",
"0.62215894",
"0.62123317",
"0.62077856",
"0.6183603",
"0.61436254",
"0.61054975",
"0.6105216",
"0.61006325",
"0.6... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_answer
@answer = Answer.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 answer_params
params.permit(:assignment_id)
params.permit(:page)
params.require(:answer).permit(:response, :revision_name, :revision_list, :question_id, :user_id, :predicted_score, :current_score, :evaluations_wanted, :total_evaluations, :confidence, :assignment_id,
:reflection, :review_request, :revision_email_sent, :useful_feedback)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
attr_reader attr_writer attr_accessor (both read and write) | def drank_blood_today
return @drank_blood_today
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_accessor(*args)\n attr_reader(*args)\n attr_writer(*args)\n end",
"def attr_accessor(*fields)\n attr_reader *fields\n attr_writer *fields\n end",
"def attr_accessor_sybling(method)\n attr_reader?(method) ? to_attr_writer(method) : to_attr_reader(method)\n end",
... | [
"0.7965225",
"0.7577414",
"0.74163663",
"0.74144804",
"0.7346127",
"0.7346127",
"0.7346127",
"0.7315455",
"0.7181794",
"0.7098788",
"0.7067853",
"0.6967938",
"0.6936819",
"0.6773722",
"0.67544323",
"0.66915053",
"0.66883624",
"0.6675539",
"0.6666812",
"0.6634692",
"0.661875",... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_pay_grade
@pay_grade = PayGrade.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def pay_grade_params
params.require(:pay_grade).permit(:level, :active)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Input a package. The 'package' can be any of: A name of a package on pypi (ie; easy_install somepackage) The path to a directory containing setup.py The path to a setup.py | def input(package)
path_to_package = download_if_necessary(package, version)
if File.directory?(path_to_package)
setup_py = File.join(path_to_package, "setup.py")
else
setup_py = path_to_package
end
if !File.exist?(setup_py)
logger.error("Could not find 'setup.py'", :path => setup_py)
raise "Unable to find python package; tried #{setup_py}"
end
load_package_info(setup_py)
install_to_staging(setup_py)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input(package)\n installdir = attributes[:virtualenv_install_location]\n m = /^([^=]+)==([^=]+)$/.match(package)\n package_version = nil\n\n is_requirements_file = (File.basename(package) == \"requirements.txt\")\n\n if is_requirements_file\n if !File.file?(package)\n raise FPM::Inva... | [
"0.6721181",
"0.6697817",
"0.66569793",
"0.64866537",
"0.6472683",
"0.63942647",
"0.63173234",
"0.62789947",
"0.6266253",
"0.62093824",
"0.6207135",
"0.61850464",
"0.6180435",
"0.61732876",
"0.6159014",
"0.61224234",
"0.61205924",
"0.61154926",
"0.6093139",
"0.6078945",
"0.60... | 0.83499026 | 0 |
def input Download the given package if necessary. If version is given, that version will be downloaded, otherwise the latest is fetched. | def download_if_necessary(package, version=nil)
# TODO(sissel): this should just be a 'download' method, the 'if_necessary'
# part should go elsewhere.
path = package
# If it's a path, assume local build.
if File.directory?(path) or (File.exist?(path) and File.basename(path) == "setup.py")
return path
end
logger.info("Trying to download", :package => package)
if version.nil?
want_pkg = "#{package}"
else
want_pkg = "#{package}==#{version}"
end
target = build_path(package)
FileUtils.mkdir(target) unless File.directory?(target)
if attributes[:python_internal_pip?]
# XXX: Should we detect if internal pip is available?
attributes[:python_pip] = [ attributes[:python_bin], "-m", "pip"]
end
# attributes[:python_pip] -- expected to be a path
if attributes[:python_pip]
logger.debug("using pip", :pip => attributes[:python_pip])
# TODO: Support older versions of pip
pip = [attributes[:python_pip]] if pip.is_a?(String)
setup_cmd = [
*attributes[:python_pip],
"download",
"--no-clean",
"--no-deps",
"--no-binary", ":all:",
"-d", build_path,
"-i", attributes[:python_pypi],
]
if attributes[:python_trusted_host]
setup_cmd += [
"--trusted-host",
attributes[:python_trusted_host],
]
end
setup_cmd << want_pkg
safesystem(*setup_cmd)
# Pip removed the --build flag sometime in 2021, it seems: https://github.com/pypa/pip/issues/8333
# A workaround for pip removing the `--build` flag. Previously, `pip download --build ...` would leave
# behind a directory with the Python package extracted and ready to be used.
# For example, `pip download ... Django` puts `Django-4.0.4.tar.tz` into the build_path directory.
# If we expect `pip` to leave an unknown-named file in the `build_path` directory, let's check for
# a single file and unpack it. I don't know if it will /always/ be a .tar.gz though.
files = ::Dir.glob(File.join(build_path, "*.tar.gz"))
if files.length != 1
raise "Unexpected directory layout after `pip download ...`. This might be an fpm bug? The directory is #{build_path}"
end
safesystem("tar", "-zxf", files[0], "-C", target)
else
# no pip, use easy_install
logger.debug("no pip, defaulting to easy_install", :easy_install => attributes[:python_easyinstall])
safesystem(attributes[:python_easyinstall], "-i",
attributes[:python_pypi], "--editable", "-U",
"--build-directory", target, want_pkg)
end
# easy_install will put stuff in @tmpdir/packagename/, so find that:
# @tmpdir/somepackage/setup.py
dirs = ::Dir.glob(File.join(target, "*"))
if dirs.length != 1
raise "Unexpected directory layout after easy_install. Maybe file a bug? The directory is #{build_path}"
end
return dirs.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def package_url\n \"https://github.com/arduino/arduino-cli/releases/download/#{@desired_version}/#{package_file}\"\n end",
"def pkg_fetch\n return if File::exists? @srcdir\n\n sysprint \"#{@name} fetch: #{@fetch_url}\"\n\n # Try to guess by package URL extension\n if @fetch_url.match(/\\.git$... | [
"0.66082",
"0.6500708",
"0.65005857",
"0.63652635",
"0.63261336",
"0.6306271",
"0.6284326",
"0.62791574",
"0.6231793",
"0.6183503",
"0.6091942",
"0.6078996",
"0.6056343",
"0.60539496",
"0.60408443",
"0.6037726",
"0.6022357",
"0.59733886",
"0.5967504",
"0.5946641",
"0.59356016... | 0.69730264 | 0 |
def download Load the package information like name, version, dependencies. | def load_package_info(setup_py)
if !attributes[:python_package_prefix].nil?
attributes[:python_package_name_prefix] = attributes[:python_package_prefix]
end
begin
json_test_code = [
"try:",
" import json",
"except ImportError:",
" import simplejson as json"
].join("\n")
safesystem("#{attributes[:python_bin]} -c '#{json_test_code}'")
rescue FPM::Util::ProcessFailed => e
logger.error("Your python environment is missing json support (either json or simplejson python module). I cannot continue without this.", :python => attributes[:python_bin], :error => e)
raise FPM::Util::ProcessFailed, "Python (#{attributes[:python_bin]}) is missing simplejson or json modules."
end
begin
safesystem("#{attributes[:python_bin]} -c 'import pkg_resources'")
rescue FPM::Util::ProcessFailed => e
logger.error("Your python environment is missing a working setuptools module. I tried to find the 'pkg_resources' module but failed.", :python => attributes[:python_bin], :error => e)
raise FPM::Util::ProcessFailed, "Python (#{attributes[:python_bin]}) is missing pkg_resources module."
end
# Add ./pyfpm/ to the python library path
pylib = File.expand_path(File.dirname(__FILE__))
# chdir to the directory holding setup.py because some python setup.py's assume that you are
# in the same directory.
setup_dir = File.dirname(setup_py)
output = ::Dir.chdir(setup_dir) do
tmp = build_path("metadata.json")
setup_cmd = "env PYTHONPATH=#{pylib}:$PYTHONPATH #{attributes[:python_bin]} " \
"setup.py --command-packages=pyfpm get_metadata --output=#{tmp}"
if attributes[:python_obey_requirements_txt?]
setup_cmd += " --load-requirements-txt"
end
# Capture the output, which will be JSON metadata describing this python
# package. See fpm/lib/fpm/package/pyfpm/get_metadata.py for more
# details.
logger.info("fetching package metadata", :setup_cmd => setup_cmd)
success = safesystem(setup_cmd)
#%x{#{setup_cmd}}
if !success
logger.error("setup.py get_metadata failed", :command => setup_cmd,
:exitcode => $?.exitstatus)
raise "An unexpected error occurred while processing the setup.py file"
end
File.read(tmp)
end
logger.debug("result from `setup.py get_metadata`", :data => output)
metadata = JSON.parse(output)
logger.info("object output of get_metadata", :json => metadata)
self.architecture = metadata["architecture"]
self.description = metadata["description"]
# Sometimes the license field is multiple lines; do best-effort and just
# use the first line.
if metadata["license"]
self.license = metadata["license"].split(/[\r\n]+/).first
end
self.version = metadata["version"]
self.url = metadata["url"]
# name prefixing is optional, if enabled, a name 'foo' will become
# 'python-foo' (depending on what the python_package_name_prefix is)
if attributes[:python_fix_name?]
self.name = fix_name(metadata["name"])
else
self.name = metadata["name"]
end
# convert python-Foo to python-foo if flag is set
self.name = self.name.downcase if attributes[:python_downcase_name?]
if !attributes[:no_auto_depends?] and attributes[:python_dependencies?]
metadata["dependencies"].each do |dep|
dep_re = /^([^<>!= ]+)\s*(?:([~<>!=]{1,2})\s*(.*))?$/
match = dep_re.match(dep)
if match.nil?
logger.error("Unable to parse dependency", :dependency => dep)
raise FPM::InvalidPackageConfiguration, "Invalid dependency '#{dep}'"
end
name, cmp, version = match.captures
next if attributes[:python_disable_dependency].include?(name)
# convert == to =
if cmp == "==" or cmp == "~="
logger.info("Converting == dependency requirement to =", :dependency => dep )
cmp = "="
end
# dependency name prefixing is optional, if enabled, a name 'foo' will
# become 'python-foo' (depending on what the python_package_name_prefix
# is)
name = fix_name(name) if attributes[:python_fix_dependencies?]
# convert dependencies from python-Foo to python-foo
name = name.downcase if attributes[:python_downcase_dependencies?]
self.dependencies << "#{name} #{cmp} #{version}"
end
end # if attributes[:python_dependencies?]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_and_extract_package\n @fetcher.get_package_file(@package_name, @version)\n Gem::Package::TarReader.new( Zlib::GzipReader.open @fetcher.temp_package_file_path ) do |tar|\n tar.each do |entry|\n next unless entry.file? and entry.full_name.match(\"DESCRIPTION\")\n @package_desc =... | [
"0.71004707",
"0.6919434",
"0.6706333",
"0.66661835",
"0.6638764",
"0.6534065",
"0.64495856",
"0.6425193",
"0.6380011",
"0.6289728",
"0.6289728",
"0.62469417",
"0.61961335",
"0.6192742",
"0.60085183",
"0.60044193",
"0.5964927",
"0.594745",
"0.59355146",
"0.59159374",
"0.59005... | 0.0 | -1 |
def load_package_info Sanitize package name. Some PyPI packages can be named 'pythonfoo', so we don't want to end up with a package named 'pythonpythonfoo'. But we want packages named like 'pythonweb' to be suffixed 'pythonpythonweb'. | def fix_name(name)
if name.start_with?("python")
# If the python package is called "python-foo" strip the "python-" part while
# prepending the package name prefix.
return [attributes[:python_package_name_prefix], name.gsub(/^python-/, "")].join("-")
else
return [attributes[:python_package_name_prefix], name].join("-")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def safe_base_package_name\n if project.package_name =~ /\\A[a-z0-9\\.\\+\\-]+\\z/\n project.package_name.dup\n else\n converted = project.package_name.downcase.gsub(/[^a-z0-9\\.\\+\\-]+/, \"-\")\n\n log.warn(log_key) do\n \"The `name' component of IPS package names can only... | [
"0.69934404",
"0.6959691",
"0.6787717",
"0.6310151",
"0.6293955",
"0.62888145",
"0.62537575",
"0.6212074",
"0.6195865",
"0.6192598",
"0.614291",
"0.6097812",
"0.6068529",
"0.605559",
"0.6009521",
"0.60049826",
"0.5959391",
"0.594701",
"0.59226805",
"0.5913534",
"0.5860331",
... | 0.7285747 | 0 |
def fix_name Install this package to the staging directory | def install_to_staging(setup_py)
project_dir = File.dirname(setup_py)
prefix = "/"
prefix = attributes[:prefix] unless attributes[:prefix].nil?
# Some setup.py's assume $PWD == current directory of setup.py, so let's
# chdir first.
::Dir.chdir(project_dir) do
flags = [ "--root", staging_path ]
if !attributes[:python_install_lib].nil?
flags += [ "--install-lib", File.join(prefix, attributes[:python_install_lib]) ]
elsif !attributes[:prefix].nil?
# setup.py install --prefix PREFIX still installs libs to
# PREFIX/lib64/python2.7/site-packages/
# but we really want something saner.
#
# since prefix is given, but not python_install_lib, assume PREFIX/lib
flags += [ "--install-lib", File.join(prefix, "lib") ]
end
if !attributes[:python_install_data].nil?
flags += [ "--install-data", File.join(prefix, attributes[:python_install_data]) ]
elsif !attributes[:prefix].nil?
# prefix given, but not python_install_data, assume PREFIX/data
flags += [ "--install-data", File.join(prefix, "data") ]
end
if !attributes[:python_install_bin].nil?
flags += [ "--install-scripts", File.join(prefix, attributes[:python_install_bin]) ]
elsif !attributes[:prefix].nil?
# prefix given, but not python_install_bin, assume PREFIX/bin
flags += [ "--install-scripts", File.join(prefix, "bin") ]
end
if !attributes[:python_scripts_executable].nil?
# Overwrite installed python scripts shebang binary with provided executable
flags += [ "build_scripts", "--executable", attributes[:python_scripts_executable] ]
end
if !attributes[:python_setup_py_arguments].nil? and !attributes[:python_setup_py_arguments].empty?
# Add optional setup.py arguments
attributes[:python_setup_py_arguments].each do |a|
flags += [ a ]
end
end
safesystem(attributes[:python_bin], "setup.py", "install", *flags)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fix_name(name)\n if name.start_with?(\"python\")\n # If the python package is called \"python-foo\" strip the \"python-\" part while\n # prepending the package name prefix.\n return [attributes[:python_package_name_prefix], name.gsub(/^python-/, \"\")].join(\"-\")\n else\n return [att... | [
"0.65917933",
"0.63511",
"0.6306356",
"0.6238577",
"0.61479294",
"0.61351377",
"0.61154866",
"0.61124915",
"0.60569876",
"0.6034344",
"0.59926045",
"0.5987415",
"0.5973787",
"0.5944547",
"0.5918022",
"0.5917931",
"0.59167546",
"0.58606595",
"0.58522594",
"0.5835223",
"0.57918... | 0.0 | -1 |
Always true. See Tasknull? | def null?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def explain_false(task); end",
"def explain_true(task); end",
"def force_task?(task)\n !!metadata[\"run_#{task}\"]\n end",
"def task_defined?(task_name) \n lookup(task_name) != nil\n end",
"def empty?; tasks.empty? end",
"def compatible_state?(task)\n\t finished? || !(running? ^... | [
"0.73489714",
"0.72424287",
"0.7216759",
"0.70551294",
"0.7000186",
"0.6902323",
"0.6864136",
"0.6852977",
"0.6821365",
"0.67038155",
"0.67016536",
"0.67004806",
"0.66960746",
"0.6691695",
"0.666782",
"0.66551936",
"0.6650127",
"0.66335934",
"0.66335934",
"0.66274774",
"0.659... | 0.6309867 | 53 |
Set a backup object based on what we have in params. | def set_backup
if params[:id] && !params[:id].blank?
@backup = Backup.new(nil, current_user.id)
@backup.id_from_epoch(params[:id])
else
@backup = Backup.new(nil, current_user.id)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_backup\n @backup = Backup.find(params[:id])\n end",
"def backup\n BACKUP_MODELS.each do |obj|\n puts \"Preparing to back up #{obj}\"\n self.send(obj.to_sym)\n end \n end",
"def backup_params\n params.require(:backup).permit(:path, :user_id, :host_id)\n end",
"def set_... | [
"0.72942555",
"0.61201036",
"0.6024181",
"0.585538",
"0.5719127",
"0.56921726",
"0.5686715",
"0.55867815",
"0.5510881",
"0.54973894",
"0.54604304",
"0.54046106",
"0.5393775",
"0.5385141",
"0.5384656",
"0.53843826",
"0.5372695",
"0.53487617",
"0.5341689",
"0.53400165",
"0.5315... | 0.7260783 | 1 |
Create and save a change_log for the backup action. | def create_change_log_entry
@change_log = @backup.create_change_log_entry(params[:action])
@change_log.save!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log!(action)\n case action\n when :started\n Logger.info \"Performing Backup for '#{label} (#{trigger})'!\\n\" \\\n \"[ backup #{VERSION} : #{RUBY_DESCRIPTION} ]\"\n\n when :finished\n if exit_status > 1\n ex = exit_status == 2 ? Error : FatalError\n er... | [
"0.6761372",
"0.66833407",
"0.64603484",
"0.6280295",
"0.6056268",
"0.60428065",
"0.6022665",
"0.60060525",
"0.6004752",
"0.60007346",
"0.59747875",
"0.5862887",
"0.5823843",
"0.58127964",
"0.5797069",
"0.5739223",
"0.5724134",
"0.57126516",
"0.56855327",
"0.55084604",
"0.547... | 0.8248232 | 0 |
Lists all Metric Descriptors. | def all(filter: nil, page_size: nil, page_token: nil)
data = service.list_metric_descriptors(
:filter => filter,
:page_size => page_size,
:page_token => page_token
).to_h[:metric_descriptors] || []
load(data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all(options = {})\n data = service.list_metric_descriptors(options).body[\"metricDescriptors\"] || []\n load(data)\n end",
"def all(options = {})\n data = service.list_metric_descriptors(options).body['metrics'] || []\n load(data)\n end",
"def index\n @m... | [
"0.78932357",
"0.7837211",
"0.6679147",
"0.6605859",
"0.639798",
"0.6339336",
"0.62915057",
"0.62335235",
"0.6220586",
"0.61459005",
"0.61459005",
"0.6113629",
"0.603261",
"0.60318696",
"0.5982686",
"0.5971572",
"0.5931032",
"0.586969",
"0.58605045",
"0.58431226",
"0.57919186... | 0.66986626 | 2 |
Get a Metric Descriptors. | def get(metric_type)
data = service.get_metric_descriptor(metric_type).to_h
new(data)
rescue ::Google::Apis::ClientError => e
raise e unless e.status_code == 404
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all(options = {})\n data = service.list_metric_descriptors(options).body['metrics'] || []\n load(data)\n end",
"def get_metrics\n {\n method: \"Performance.getMetrics\"\n }\n end",
"def all(options = {})\n data = service.list_metric_descriptors(... | [
"0.6498434",
"0.64717406",
"0.64246106",
"0.61260754",
"0.61247015",
"0.59966314",
"0.59639174",
"0.5959368",
"0.5916593",
"0.5909137",
"0.58886355",
"0.58862513",
"0.587014",
"0.5859049",
"0.58295923",
"0.5827986",
"0.579407",
"0.5791534",
"0.5762079",
"0.56138515",
"0.56029... | 0.5752902 | 19 |
Encodes a request msg | def encoderequest(sender, target, msg, requestid, filter={})
serialized = Marshal.dump(msg)
digest = makehash(serialized)
@log.debug("Encoding a request for '#{target}' with request id #{requestid}")
request = {:body => serialized,
:hash => digest,
:senderid => @config.identity,
:requestid => requestid,
:msgtarget => target,
:filter => filter,
:msgtime => Time.now.to_i}
# if we're in use by a client add the callerid to the main client hashes
request[:callerid] = callerid if @initiated_by == :client
Marshal.dump(request)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode(msg)\n proc.call msg\n end",
"def encode_body\n body = ''\n body += encode_bits(@connack_flags)\n body += encode_bytes(@return_code.to_i)\n body\n end",
"def encoderequest(sender, target, msg, requestid, filter={})\n @log.debug(\"Encoding a request... | [
"0.6424981",
"0.63148844",
"0.6269933",
"0.62282616",
"0.6210985",
"0.61697453",
"0.61449206",
"0.6130633",
"0.6104965",
"0.60915184",
"0.6008699",
"0.5921019",
"0.58890426",
"0.5834426",
"0.579513",
"0.57921994",
"0.57860625",
"0.5757325",
"0.57281667",
"0.5721147",
"0.57181... | 0.655947 | 0 |
Checks the md5 hash in the request body against our psk, the request sent for validation should not have been deserialized already | def validrequest?(req)
digest = makehash(req[:body])
if digest == req[:hash]
@stats[:validated] += 1
return true
else
@stats[:unvalidated] += 1
raise("Received an invalid signature in message")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate\n return false unless @digest_parts.any? # RUBY\n\n a2 = @request.method + ':' + @digest_parts['uri']\n\n if @digest_parts['qop'] == 'auth-int'\n # Making sure we support this qop value\n return false unless @qop & QOP_AUTHINT\n\n # We need t... | [
"0.71422464",
"0.6615576",
"0.6254384",
"0.6179126",
"0.6147874",
"0.60476065",
"0.60288227",
"0.5990138",
"0.5988776",
"0.59881806",
"0.5977048",
"0.59718204",
"0.59566367",
"0.59323597",
"0.5925171",
"0.59047824",
"0.59033847",
"0.5784152",
"0.57425696",
"0.57300836",
"0.56... | 0.67861265 | 1 |
Retrieves the value of plugin.psk and builds a hash with it and the passed body | def makehash(body)
if ENV.include?("MCOLLECTIVE_PSK")
psk = ENV["MCOLLECTIVE_PSK"]
else
raise("No plugin.psk configuration option specified") unless @config.pluginconf.include?("psk")
psk = @config.pluginconf["psk"]
end
Digest::MD5.hexdigest(body.to_s + psk)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makehash(body)\n signer = SSH::Key::Signer.new\n if @config.pluginconf[\"sshkey\"]\n signer.add_key_file(@config.pluginconf[\"sshkey\"])\n signer.use_agent = false\n end\n signatures = signer.sign(body).collect { ... | [
"0.6142206",
"0.5646437",
"0.543187",
"0.5422822",
"0.54045266",
"0.53697145",
"0.5309388",
"0.5285571",
"0.5274934",
"0.52340317",
"0.519007",
"0.51736236",
"0.5155452",
"0.5137371",
"0.513657",
"0.5126693",
"0.51163393",
"0.50850827",
"0.50850827",
"0.50850827",
"0.50826174... | 0.77462536 | 0 |
TODO delete this once docker image uses new selector class for clean | def max_age= max_age
self[:max_age] = max_age
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_selector(input); end",
"def build_selectors\n temp_release_docs.uniq(&:kubernetes_role_id).flat_map(&:build_selectors).uniq\n end",
"def selectors\n self.class.selectors\n end",
"def io_selector_backend(backend); end",
"def acts_as_selector\n define_method(\"is_selector?... | [
"0.6032926",
"0.58167946",
"0.5771887",
"0.56665564",
"0.5619729",
"0.55234057",
"0.5514823",
"0.5497935",
"0.5491535",
"0.54881376",
"0.5315589",
"0.5288512",
"0.52695775",
"0.5254959",
"0.52051276",
"0.5161834",
"0.51610154",
"0.5154018",
"0.5154018",
"0.5149632",
"0.514686... | 0.0 | -1 |
12 == 21 513 = 531 2017 = 2071 if no bigger digit return 1 input: a positive integer output: the next biggest integer using the same digits Rules: if there is no bigger integer return 1 return 1 if all the numbers are the same if the number is already sorted in its highest possible iteration, return 1 Algorithm: we will return 1 if all the digits are the same. we will return if the digits after being sorted are in the same state as the original integer intialiaze a local variable called combinations with the return value of the possibl permutations make the combinations whole digits by iterating over each combination and transforming it to a string and then to a integer iterate over the combinations and select the combination that is the current number select the index + 1 end | def next_bigger_num(num)
return -1 if num if num.digits.all? {|digit| digit == num[0]}
return -1 if num.digits.sort! {|a,b| b <=> a}.join.to_i == num
combinations = num.digits.permutation(num.digits.length).to_a
combinations.map! do |arr|
arr.join.to_i
end.sort!
combinations.each.with_index do |number, index|
return combinations[index + 1] if number == num
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_bigger_num(num)\r\n digits = num.digits\r\n sorted_digits = digits.sort { |a, b| b <=> a }\r\n if digits.count(digits[0]) == digits.size || digits.size < 2 || sorted_digits == digits.reverse\r\n return -1\r\n end\r\n \r\n permutation = digits.permutation.to_a.map do |sub_arr|\r\n sub_arr.join(... | [
"0.7711993",
"0.7032367",
"0.70059085",
"0.69975924",
"0.69776857",
"0.69644326",
"0.69474304",
"0.69390625",
"0.6934768",
"0.69321847",
"0.68976086",
"0.68664044",
"0.6816182",
"0.68135726",
"0.6739254",
"0.6727198",
"0.66841376",
"0.6656685",
"0.6629968",
"0.66275394",
"0.6... | 0.82220703 | 0 |
Complete or uncomplete transaction. If the move is FROM a real account, don't debit the account until after transaction is completed. If the move is TO an envelope, credit the envelope when transaction is initiated and debit the envelope when completed. | def complete_xaction
if valid?
# For new records, certain types of transactions will be automatically set as completed.
self.completed = true if new_record? && (to.is_account? && (from_id.nil? || from.is_account?))
# If amount changes, we have to update the envelope amount if it's still pending; otherwise update just the account amount.
if !new_record? && dirty_attributes.keys.include?(Xaction.properties[:amount])
if completed
# update the debited account
diff = amount - Xaction.get(id).amount
from.update_attributes(:actual_amount => from.actual_amount.to_f + diff)
else
# update the envelope amount
diff = amount - Xaction.get(id).amount
to.update_attributes(:actual_amount => to.actual_amount.to_f + diff)
end
end
# Complete/Pending
if dirty_attributes.keys.include?(Xaction.properties[:completed])
# Envelope side
if to && !to.is_account?
if new_record? && !completed
# credit the envelope
to.update_attributes(:actual_amount => to.actual_amount.to_f + amount.to_f)
end
if !new_record?
if completed
# debit the envelope
to.update_attributes(:actual_amount => to.actual_amount.to_f - amount.to_f)
to.budget.update_attributes(:amount => amount.to_f < from.budget.amount.to_f ? to.budget.amount.to_f - amount.to_f : 0) # If spending, take it out of the current budget too.
else
# undo the debit
to.update_attributes(:actual_amount => to.actual_amount.to_f + amount.to_f)
to.budget.update_attributes(:amount => amount.to_f < to.budget.amount.to_f ? to.budget.amount.to_f + amount.to_f : 0) # If spending, take it out of the current budget too.
end
end
end
# Debiting from Account
if from && from.is_account?
if completed
# debit the account
from.update_attributes(:actual_amount => from.actual_amount.to_f - amount.to_f)
elsif !new_record? && !completed
# undo the debit
from.update_attributes(:actual_amount => from.actual_amount.to_f + amount.to_f)
end
end
# Crediting to Account
if to && to.is_account?
if completed
# debit the account
to.update_attributes(:actual_amount => to.actual_amount.to_f + amount.to_f)
elsif !new_record? && !completed
# undo the debit
to.update_attributes(:actual_amount => to.actual_amount.to_f - amount.to_f)
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def complete\n\t\t\t@from.short_of_cash(@amount) if @from.balance < @amount\n\t\t\tamount_to_pay = ( @from.balance >= @amount ? @amount : @from.balance )\n\n\t\t\t@to.receive(amount_to_pay)\n\t\t\t@from.deduct(amount_to_pay)\n\t\t\tpaying_to = @to.owner.name\n\n\t\t\tif amount_to_pay < amount\n\t\t\t\t@from.owner.... | [
"0.6982691",
"0.65402544",
"0.6481989",
"0.64782345",
"0.62614524",
"0.6249735",
"0.62164265",
"0.61531687",
"0.6118449",
"0.6071084",
"0.6047062",
"0.6001378",
"0.5998204",
"0.59557205",
"0.59552795",
"0.5935379",
"0.5930211",
"0.59248596",
"0.592124",
"0.59104985",
"0.59075... | 0.7126264 | 0 |
This is customized because GENCAT don't Processes Groups on Index Page | def collection
@collection ||= participatory_processes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def i_groups; end",
"def index\n @title = \"groups_title\"\n #save_navi_state(['groups_title', 'browse_groups']) #moved to filter\n public_group_ids = Group.get_public_group_ids(session[:cookie])\n # add groups to Kassi db if there are new (made in other services)\n Group.add_new_groups_to_kassi_d... | [
"0.720992",
"0.7156306",
"0.71492815",
"0.71492815",
"0.71492815",
"0.67437506",
"0.6737039",
"0.671414",
"0.66787845",
"0.6656012",
"0.66070586",
"0.65212923",
"0.64800763",
"0.64789146",
"0.6470866",
"0.64298844",
"0.6407856",
"0.64005226",
"0.6335072",
"0.63215625",
"0.632... | 0.0 | -1 |
This is customized because GENCAT don't Processes Groups on Index Page | def filtered_processes
search.results.where(decidim_participatory_process_group_id: Rails.application.config.regulation)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def i_groups; end",
"def index\n @title = \"groups_title\"\n #save_navi_state(['groups_title', 'browse_groups']) #moved to filter\n public_group_ids = Group.get_public_group_ids(session[:cookie])\n # add groups to Kassi db if there are new (made in other services)\n Group.add_new_groups_to_kassi_d... | [
"0.720833",
"0.7154749",
"0.7147088",
"0.7147088",
"0.7147088",
"0.67428076",
"0.6735224",
"0.67125964",
"0.6676358",
"0.66545063",
"0.66057444",
"0.65207285",
"0.6478785",
"0.6477006",
"0.6468802",
"0.6428491",
"0.64075553",
"0.6398134",
"0.63345194",
"0.6318886",
"0.6318827... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.