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
Convert from Roman numeral e.g. "MCCCXLIIII" = 1344
def from_roman(str) hash = {} str.each_char do |letter| hash.default = 0 hash[rn_to_decimal(letter)] += 1 end array = [] hash.each do |k, v| array << k*v end array.reduce(:+) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def roman_numeral num_to_convert\n\t\n\tnum_converted = ''\n\n\tthousands = num_to_convert / 1000\n\tnum_converted = 'M'*thousands\n\tremainder = num_to_convert % 1000\n\n\tfivehundreds = remainder / 500\n\tif remainder >= 900\n\t\tnum_converted += 'CM'\n\t\tremainder = remainder % 900\n\telse\n\t\tnum_converted +...
[ "0.8061476", "0.77942055", "0.77868134", "0.77571356", "0.7749923", "0.7722985", "0.76693827", "0.7665349", "0.7661817", "0.7660929", "0.7650465", "0.76304746", "0.76304746", "0.76294374", "0.7607817", "0.7603713", "0.75980407", "0.75574124", "0.75451344", "0.75168806", "0.74...
0.72678304
44
Never trust parameters from the scary internet, only allow the white list through.
def customer_params params.require(:customer).permit(:lastName, :firstName, :email) 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
given an argument, e.g., an item in a args list, return the proper datatypepair (to be put into a Hash)
def process_argument arg, idx=0 if arg.is_a?(String) if arg.length < @@max_key_size [arg, arg] else [idx, arg] end elsif arg.respond_to?(:name) and arg.respond_to?(:read) [arg.name, arg] elsif arg.respond_to?(:id) and arg.respond_to?(:data) [arg.id, arg.data] elsif arg.is_a?(Hash) if arg.has_key? :id and arg.has_key? :data [arg[:id], arg[:data]] elsif arg.has_key? 'id' and arg.has_key? 'data' [arg['id'], arg['data']] end else raise ApiError, "Invalid argument: #{ arg }" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_args(arg)\n if arg.is_a?(Hash) and Knj::ArrayExt.hash_numeric_keys?(arg)\n arr = []\n \n arg.each do |key, val|\n arr << val\n end\n \n return self.parse_args(arr)\n elsif arg.is_a?(Hash)\n arg.each do |key, val|\n arg[key] = self.parse_args(val)\n ...
[ "0.6284345", "0.60438216", "0.5710495", "0.5710495", "0.5681673", "0.5545383", "0.55292404", "0.5523642", "0.5505313", "0.54543525", "0.5436568", "0.5424389", "0.5423641", "0.541908", "0.5406427", "0.5406427", "0.5406427", "0.5406427", "0.5406427", "0.5406427", "0.5406427", ...
0.5896077
2
get every test to pass before coding runner below
def runner welcome subTotal = initial_round until subTotal > 21 subTotal = hit?(subTotal) display_card_total(subTotal) end end_game(subTotal) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_tests\n puts \"Running exactly #{@spec.size} tests.\"\n @spec.each do |test_case|\n sleep test_case.wait_before_request\n response = send_request_for(test_case)\n Checker.available_plugins.each do |plugin|\n result = @expectation.check(plugin, response, test_case)\n if no...
[ "0.7275367", "0.72012377", "0.7191292", "0.71326625", "0.7128869", "0.7035493", "0.68615764", "0.6822212", "0.6807081", "0.6791164", "0.6791164", "0.67651623", "0.6570472", "0.6553684", "0.65485567", "0.65461046", "0.6529981", "0.6459336", "0.64472514", "0.64472514", "0.64417...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_car_make @car_make = CarMake.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a trusted parameter "white list" through.
def car_make_params params.require(:car_make).permit(:name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
after_save callback to handle group_ids
def update_groups unless group_ids.nil? self.groups_members.each do |m| m.destroy unless group_ids.include?(m.group_id.to_s) group_ids.delete(m.group_id.to_s) end group_ids.each do |g| self.groups_members.create(:group_id => g) unless g.blank? end reload self.group_ids = nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_save\n api.group_save(self)\n end", "def before_save\n prepare_attributes\n find_song_groups!\n end", "def save_groups\n self.groups.each { |c| if c.destroy_association? then c.destroy else c.save end }\n self.added_groups.each { |c| c.save unless c.nil? } unless se...
[ "0.6678652", "0.65834385", "0.6480518", "0.63523304", "0.62736356", "0.6183997", "0.61800325", "0.608343", "0.6023749", "0.5958896", "0.59534556", "0.5942502", "0.59390146", "0.5904299", "0.5874774", "0.5874774", "0.5874774", "0.5837167", "0.5814282", "0.5814282", "0.5814282"...
0.5533892
34
method filter_ne rubocop:disable Metrics/MethodLength
def indifferent_dig hsh, keys keys.reduce(hsh) do |nested, key| next nil unless nested case key when String nested.key?(key) ? nested[key] : nested[key.intern] when Symbol nested.key?(key) ? nested[key] : nested[key.to_s] else nested[key] end # case end # method reduce end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter!; end", "def filter; end", "def filter; end", "def filter; end", "def filter(expr); end", "def filter(expr); end", "def filter\n end", "def not(filters)\n @nots ||= {}\n @nots.merge!(filters)\n self\n end", "def except *filter_list\n filter...
[ "0.67323965", "0.6702157", "0.6702157", "0.6702157", "0.6171177", "0.6171177", "0.606631", "0.5881562", "0.5857028", "0.5802551", "0.57800514", "0.5727158", "0.570965", "0.5707902", "0.5705528", "0.5662627", "0.5662384", "0.56397176", "0.5620243", "0.5619739", "0.56086785", ...
0.0
-1
method indifferent_dig rubocop:enable Metrics/MethodLength
def partition_selector @subhash = {} @filters = {} partition_selector_hash @selector, [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nested_under_indifferent_access\n self\n end", "def indifferent_dig hsh, keys\n keys.reduce(hsh) do |nested, key|\n next nil unless nested\n\n case key\n when String\n nested.key?(key) ? nested[key] : nested[key.intern]\n when Symbol\n nested.key?(ke...
[ "0.6929075", "0.68925136", "0.68583006", "0.66974765", "0.6678602", "0.6678602", "0.6678602", "0.63357294", "0.6313151", "0.6290456", "0.6188316", "0.5822255", "0.57962763", "0.5716163", "0.55900913", "0.55633575", "0.549049", "0.5479947", "0.545152", "0.5440766", "0.54324144...
0.0
-1
Define presentationspecific methods here. Helpers are accessed through `helpers` (aka `h`). You can override attributes, for example: def created_at helpers.content_tag :span, class: 'time' do object.created_at.strftime("%a %m/%d/%y") end end
def number_of_guests guests_count = guests.size [ guests_count, Guest.model_name.human.pluralize(guests_count, I18n.locale).downcase ].join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def created_at_tag\n\t\th.content_tag :span, class: \"time\" do\n\t\t\th.record_time(self.created_at)\n\t\tend\n\tend", "def time_to_show\n \n end", "def helper_attr(*attrs); end", "def helpers; end", "def helpers; end", "def helpers; end", "def helper_method(*methods); end", "def generic_datetim...
[ "0.5624672", "0.55944777", "0.55779487", "0.5577156", "0.5577156", "0.5577156", "0.5482865", "0.5463144", "0.5420486", "0.5386988", "0.53837246", "0.53254336", "0.52590626", "0.52589893", "0.5258427", "0.5257027", "0.5251863", "0.5244733", "0.5239579", "0.5237558", "0.5226607...
0.0
-1
Quick create a SignRequest
def signrequest_quick_create_create(data, opts = {}) data, _status_code, _headers = signrequest_quick_create_create_with_http_info(data, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def signing_request\n req = OpenSSL::X509::Request.new\n req.public_key = key.public_key\n req.subject = OpenSSL::X509::Name.new([['CN', domain]])\n req.sign(key, OpenSSL::Digest::SHA256.new)\n end", "def create_signed_request(http_method, path, token = nil, request_options = {}, *argument...
[ "0.7389531", "0.7192417", "0.6996315", "0.6916166", "0.6834115", "0.68050534", "0.666823", "0.66569924", "0.64275825", "0.64254564", "0.64093435", "0.63917786", "0.63514537", "0.6308596", "0.6240326", "0.6211949", "0.62073445", "0.6196489", "0.61721903", "0.61508954", "0.6126...
0.68295777
5
Quick create a SignRequest
def signrequest_quick_create_create_with_http_info(data, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SignrequestQuickCreateApi.signrequest_quick_create_create ...' end # verify the required parameter 'data' is set if @api_client.config.client_side_validation && data.nil? fail ArgumentError, "Missing the required parameter 'data' when calling SignrequestQuickCreateApi.signrequest_quick_create_create" end # resource path local_var_path = '/signrequest-quick-create/' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(data) auth_names = ['Token'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'SignRequestQuickCreate') if @api_client.config.debugging @api_client.config.logger.debug "API called: SignrequestQuickCreateApi#signrequest_quick_create_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def signing_request\n req = OpenSSL::X509::Request.new\n req.public_key = key.public_key\n req.subject = OpenSSL::X509::Name.new([['CN', domain]])\n req.sign(key, OpenSSL::Digest::SHA256.new)\n end", "def create_signed_request(http_method, path, token = nil, request_options = {}, *argument...
[ "0.7388415", "0.7192352", "0.6995836", "0.69167674", "0.6834379", "0.6829596", "0.6805652", "0.6666756", "0.6656511", "0.64283407", "0.6424126", "0.64097714", "0.6395066", "0.63519937", "0.6309432", "0.6240095", "0.6211625", "0.62079227", "0.6196525", "0.6171549", "0.61478287...
0.5874596
36
create task from thought or /tasks/new
def create # This makes the create task and destroy thought into 1 commit transaction so if either fails # the whole action of create and destroy doesn't leave data in a bad area. ActiveRecord::Base.transaction do @task = Task.new(task_params) if @task.save if params[:thought_id].present? thought = Thought.find(params[:thought_id]) thought.destroy notice = 'Thought was deleted and a Task was successfully created.' else notice = 'Task was successfully created.' end redirect_to root_path, notice: notice else # ASK Lailson why does this not work with render? # render :new # NOTE: triggers when saving a thought fails. # # Test via setting if !@thought.save alert = 'Task failed to be saved.' redirect_to new_task_path, alert: alert # TODO: preserve description and priorioty when new page is rerendered end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_task\n\t@task = Task.create(:quest_id => params[:id], :user_id => @current_user.id, :title => params[:task][:title])\n\tredirect_to quest_path(params[:id])\n\tend", "def create_task\n task = Task.create!(\n description: 'Test Task'\n )\nend", "def create\n @task = Task.create!(task_params)\n ...
[ "0.8236826", "0.79268867", "0.78932434", "0.7833309", "0.7797091", "0.7785207", "0.77439624", "0.772236", "0.7719772", "0.7712039", "0.763796", "0.76377356", "0.7635276", "0.761304", "0.7597839", "0.7597519", "0.7586014", "0.7581233", "0.7564946", "0.7552142", "0.75508803", ...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_task @task = Task.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a list of trusted parameters through.
def task_params params.require(:task).permit(:description, :priority) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.6948149", "0.68135875", "0.68015283", "0.67953765", "0.6745843", "0.67416775", "0.652725", "0.6521263", "0.649084", "0.64307743", "0.64307743", "0.64307743", "0.6398334", "0.63553715", "0.6355045", "0.6346211", "0.63444513", "0.6338212", "0.63267356", "0.63267356", "0.6326...
0.0
-1
MONKEY PATCH to handle ips (bigger numbers better) or others (smaller numbers better)
def slowdown(baseline) if baseline.central_tendency > central_tendency [baseline.central_tendency.to_f / central_tendency, 0] else [central_tendency.to_f / baseline.central_tendency, 0] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nodeIP(num)\n return \"10.17.4.#{num+200}\"\nend", "def ip; end", "def ip; end", "def snag_ip\n java.net.NetworkInterface.network_interfaces.each do |networkInterface|\n networkInterface.inet_addresses.each do |inet|\n addr = inet.address\n if addr[0] == 10 && addr.length == 4 && a...
[ "0.64794755", "0.63747156", "0.63747156", "0.63399655", "0.63348883", "0.63348883", "0.6213612", "0.61530983", "0.6105175", "0.60506445", "0.60375845", "0.5984076", "0.5984076", "0.5984076", "0.5984076", "0.5984076", "0.5984076", "0.59612674", "0.5950604", "0.59506005", "0.59...
0.0
-1
Return entry's standard deviation of iteration per second in percentage.
def error_percentage 100.0 * (error.to_f / central_tendency) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stddev()\n if mean == -1\n mean()\n end\n\n sum = 0\n @difference.each do |item|\n sum += (item - @mean) ** 2\n end\n\n stddev = (sum / difference.length) ** 0.5\n\n return stddev\n end", "def std_dev\n count = self.size\n mean = self.avg\n return Math.sqrt( self.inje...
[ "0.7521294", "0.74545246", "0.7383976", "0.73453075", "0.73392504", "0.73127234", "0.7260004", "0.7217221", "0.71873116", "0.71747845", "0.71314514", "0.7116342", "0.7116276", "0.71049047", "0.7091512", "0.7079897", "0.7057833", "0.70313925", "0.6998702", "0.69948846", "0.697...
0.0
-1
Omniauth callback handler when using force_authentication
def auth_callback current_user omniauth_origin = session[:omniauth_origin] session.delete(:omniauth_origin) redirect_to omniauth_origin || '/' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def callback\n rpx_auth\n after_auth(params[:on_complete_url])\n end", "def callback\n # This stores all the user information that came from Auth0\n # and the IdP\n userinfo = request.env['omniauth.auth']\n\n begin\n result = SessionService.process!(userinfo, session)\n\n if result.n...
[ "0.7225204", "0.70925313", "0.7067971", "0.70650685", "0.7060526", "0.7015651", "0.6954364", "0.69541097", "0.693902", "0.6821414", "0.6720906", "0.6704461", "0.6691844", "0.66876256", "0.6672339", "0.6670314", "0.66494757", "0.66198695", "0.6615188", "0.6559628", "0.6507348"...
0.72212446
1
Extract omniauth credentials from the request environment
def omniauth_credentials if omniauth_hash = request.env['omniauth.auth'] { provider: omniauth_hash['provider'], uid: omniauth_hash['uid'], email: omniauth_hash['info']['email'], name: omniauth_hash['info']['name'], } else nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auth_hash\n request.env['omniauth.auth']\n end", "def auth_hash\n request.env['omniauth.auth']\n end", "def auth_hash\n request.env['omniauth.auth']\n end", "def auth_hash\n request.env['omniauth.auth']\n end", "def auth_hash\n request.env['omniauth.auth']\n end", "def auth_hash\n...
[ "0.7366053", "0.7366053", "0.7366053", "0.7366053", "0.7366053", "0.7366053", "0.73515856", "0.7265247", "0.71680605", "0.7126297", "0.7126297", "0.7086515", "0.70861953", "0.70861953", "0.7060423", "0.69462854", "0.6922967", "0.6922967", "0.6918792", "0.6902276", "0.6902276"...
0.7681923
0
this module assumes a method location which returns a valid subversion URL
def changes_since(path, from, to = "HEAD") if from.is_a?(Time) then return changes_since_time(path, from, to) else return changes_since_revision(path, from, to) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def url\n raise \"Implement in child class\"\n end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def...
[ "0.6548998", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.6512187", "0.64452815", ...
0.0
-1
Suites and Sections see
def get_suite(suite_id, opts = {}) request.get('get_suite', suite_id, opts) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def section\n section_test.section\n end", "def print_test_suite_section(options={})\n options = {\n }.merge(options)\n\n in_test_suite_section = false\n\n # go thru file data\n @testflow_lines.each_index do |linenum|\n line = @testflow_lines[linenum]\n line.gsub!(/\\r/,\"\"); line.gsub!(/\\n/...
[ "0.68792844", "0.6775629", "0.6741634", "0.65502626", "0.64807427", "0.6464936", "0.6464936", "0.63970584", "0.63219345", "0.62735856", "0.6257715", "0.62318957", "0.62291694", "0.6222901", "0.6222901", "0.6131445", "0.60727", "0.60040057", "0.6001844", "0.6000619", "0.600061...
0.0
-1
point for messages that, after consumption, are conserved in the execution's "closing_messages" array
def do_run @unit.logger.log_run_start(self) counter_next('runs') t0 = Time.now (@unit.conf['exe_max_messages'] || 77).times do |i| break if @shutdown m = @messages.shift break unless m m = (@messages << m).shift \ if m['point'] == 'terminated' && @messages.any? # # handle 'terminated' messages last ms = process(m) @consumed << m ims, oms = ms.partition { |mm| mm['exid'] == @exid } # qui est "in", qui est "out"? counter_add('omsgs', oms.size) # keep track of "out" messages, messages to other executions @messages.concat(ims) @unit.storage.put_messages(oms) end @alive = false @execution.merge!( closing_messages: @consumed.select { |m| CLOSING_POINTS.include?(m['point']) }) @unit.storage.put_execution(@execution) @unit.storage.consume(@consumed) @unit.storage.put_messages(@messages) du = Time.now - t0 t0 = Flor.tstamp(t0) @unit.logger.log_run_end(self, t0, du) @unit.hooker.notify(self, make_end_message(t0, du, @execution['size'])) @consumed.clear rescue Exception => exc # TODO eventually, have a dump dir fn = [ 'flor', @unit.conf['env'], @unit.identifier, @exid, 'r' + counter('runs').to_s ].collect(&:to_s).join('_') + '.dump' @unit.logger.error( "#{self.class}#do_run()", exc, "(dumping to #{fn} ...)") File.open(fn, 'wb') do |f| f.puts(Flor.to_pretty_s({ execution: @execution, messages: @messages, consumed: @consumed, traps: @traps.collect(&:to_h), exid: @exid, alive: @alive, shutdown: @shutdown, thread: [ @thread.object_id, @thread.to_s ] })) f.puts('-' * 80) f.puts(on_do_run_exc(exc)) end @unit.logger.error( "#{self.class}#do_run()", exc, "(dumped to #{fn})") #puts on_do_run_exc(exc) # dump notification above end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def buffered_messages; end", "def on_after_consume\n coordinator.on_finished do |first_group_message, last_group_message|\n on_after_consume_regular(first_group_message, last_group_message)\n end\n end", "def cleanup_phase\n ::Ractor.current.close_incoming\n maybe_log(...
[ "0.6250176", "0.6174741", "0.5838872", "0.5834594", "0.5773094", "0.5753315", "0.57489353", "0.56858754", "0.564335", "0.5628616", "0.5623863", "0.5609502", "0.5609502", "0.5563569", "0.55438894", "0.5541095", "0.55296785", "0.5521984", "0.5502117", "0.5499915", "0.5496615", ...
0.57905906
4
TODO find_some Cacheable: current_user.articles.where(:status => 1).visiable.find(params[:id]) Uncacheable: Article.where("user_id = '1'").find(params[:id]) Article.where("user_id > 1").find(params[:id]) Article.where("articles.user_id = 1").find(prams[:id]) Article.where("user_id = 1 AND ...").find(params[:id])
def find_one_with_second_level_cache(id) return find_one_without_second_level_cache(id) unless second_level_cache_enabled? return find_one_without_second_level_cache(id) unless select_all_column? id = id.id if ActiveRecord::Base === id if cachable? if record = @klass.read_second_level_cache(id) return record end end if cachable_without_conditions? if record = @klass.read_second_level_cache(id) return record if where_match_with_cache?(where_values, record) end end record = find_one_without_second_level_cache(id) record.write_second_level_cache record end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_article_by_user\n @article = @current_user.articles.find(params[:id])\n end", "def get_user_articles\n @user = User.find(params[:user_id])\n case params[:articles_type]\n when Article::List::Type::RECOMMEND\n @articles = @user.recommend_articles.accessibles(current_user).order_by_recom...
[ "0.6747193", "0.661781", "0.659087", "0.6373584", "0.6366748", "0.6326541", "0.63053805", "0.62272096", "0.6215502", "0.6202086", "0.6194505", "0.61679035", "0.6153565", "0.6105115", "0.6074881", "0.6014602", "0.59102684", "0.58726233", "0.58572596", "0.58448577", "0.58326817...
0.0
-1
opposite of encrypt method. put letters back 1
def encrypt(password) split_string = string.password(//) split_string.each do |letter| letter.next end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encrypt(password)\n\tcounter = 0\n\twhile counter < password.length\n\tif password[counter] == \" \"\n\t\tpassword[counter] = \" \"\n\t\tcounter += 1\n\telse\n\t\talphabet = \"abcdefghijklmnopqrstuvwxyz\"\n\t\talphabet.reverse!\n\t\tinstance_in_alphabet = alphabet[alphabet.index(password[counter])]\n\t\tpasswo...
[ "0.74310577", "0.7422014", "0.7418544", "0.7394762", "0.7385722", "0.73697305", "0.73586226", "0.7349921", "0.7346757", "0.73202336", "0.7245393", "0.7237596", "0.72042835", "0.7190062", "0.71771926", "0.71643287", "0.7149674", "0.7149039", "0.7145107", "0.7122261", "0.711368...
0.0
-1
Return Erector parser, ready to render results.
def prepare_engine(params={}, &content) file, scope, locals = parameters(params, :file, :scope, :locals) scope, locals = make_external(scope, locals, &content) unless scope.respond_to?(:to_struct) scope_locals = {} scope.instance_variables.each do |k| next if k == "@target" name = k.to_s.sub('@','').to_sym v = scope.instance_variable_get(k) scope_locals[name] = v end locals = scope_locals.merge(locals) end create_engine(params).new(locals) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parser\n @parser ||= Parser.new(self)\n end", "def parser\n @parser ||= Parser.new(self)\n end", "def parser\n @parser ||= Parser.new(self)\n end", "def parser; end", "def parser; end", "def parser; end", "def parser; end", "def pluggable_parser; end", "def parser\n ...
[ "0.63622284", "0.63540465", "0.63540465", "0.63352406", "0.63352406", "0.63352406", "0.63352406", "0.6332947", "0.6141033", "0.60985774", "0.6081678", "0.6081474", "0.59809554", "0.5905831", "0.5898809", "0.5799554", "0.57317567", "0.5713644", "0.5690801", "0.56695247", "0.56...
0.0
-1
TODO: how to support scope ? Erector constructor support caching.
def create_engine(params={}) text, prefix = parameters(params, :text, :prefix) cached(prefix, text) do Class.new(::Erector::Widget) do module_eval %{ def #{prefix}; self; end } if prefix module_eval %{ def content #{text} end } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rect=(rectangle); end", "def rect; end", "def rect; end", "def compute_self\n rect.set(self.x, self.y, self.width, self.height)\n rect.compute_self\n self.true_ox = rect.true_x - rect.abs_x + self.ox\n self.true_oy = rect.true_y - rect.abs_y + self.oy\n compute_z\n end", "def inspect; \...
[ "0.65410316", "0.6327887", "0.6327887", "0.6063183", "0.58814985", "0.57938397", "0.57938397", "0.5752454", "0.5715136", "0.57123667", "0.5653828", "0.56107295", "0.55911416", "0.54944265", "0.546639", "0.5422446", "0.5412564", "0.5409077", "0.53696877", "0.5360564", "0.53603...
0.0
-1
Load Erector library if not already loaded.
def require_engine return if defined? ::Erector require_library 'erector' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def require_engine\n return if defined? ::Erubius\n require_library('erubis')\n end", "def load_library\n raise NotImplementedError, \"loading extension libraries is not implemented\"\n end", "def load_libs; end", "def set_up_libraries\n R.eval <<-EOR\n suppressMessages(library(R...
[ "0.5841934", "0.5740633", "0.5573599", "0.5430756", "0.52505094", "0.52422917", "0.5194662", "0.51029646", "0.50986636", "0.5083197", "0.5039686", "0.501193", "0.5003072", "0.49959105", "0.49949673", "0.49933836", "0.49916852", "0.4976375", "0.49466842", "0.4939017", "0.49390...
0.71635115
0
Use callbacks to share common setup or constraints between actions.
def set_shop @shop = current_user.shops.find_by!(id: params[:id]) if current_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.5...
0.0
-1
Only allow a trusted parameter "white list" through.
def shop_params params.require(:shop).permit! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
default cong_hash. already symbolized. memoized.
def get_defaults unless @defaults conf_str = JustInCase::Templates::CONFIG_FILE conf_hash = JSON.parse(conf_str) @defaults = conf_hash.symbolize_keys! end return @defaults 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=(_arg0); end", "def hash()\n #This is a stub, used for indexing\n end", "def hash_code; end", "def hash(*) end", "def default?; to_hash.gibbler == D...
[ "0.64098465", "0.64098465", "0.64098465", "0.64098465", "0.64098465", "0.64098465", "0.64098465", "0.6389336", "0.6342766", "0.63177294", "0.6267721", "0.6249039", "0.6247899", "0.6240187", "0.6078807", "0.606173", "0.60491455", "0.6047894", "0.6047894", "0.6047894", "0.60478...
0.0
-1
Called when the script view is loaded
def getText if defined?($otrunkHelperScript) otImport($otrunkHelperScript) @otrunkHelper = OTrunkHelper.new end otImport($xmlReportScript) if defined?($xmlReportScript) init if $action actionStr = $action.string else actionStr = "default_template" end eval(actionStr) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_script\n @adapter.init_script\n end", "def on_after_load\n end", "def run_init_script; end", "def onLoad\n end", "def on_before_load\n end", "def after_view_setup\n end", "def on_load\n clear_output\n end", "def script_load(script); end", "def runInitS...
[ "0.69557357", "0.68258023", "0.68182766", "0.6635101", "0.65340096", "0.65338737", "0.6508138", "0.6440444", "0.62399274", "0.6190206", "0.6190206", "0.61116785", "0.60865724", "0.6075502", "0.6058728", "0.60500294", "0.60500294", "0.60500294", "0.6040505", "0.5968406", "0.59...
0.0
-1
return current choice: deal with new and old choice data model
def currentChoice(input) # handle old case first choice = input.currentChoice return choice if choice != nil begin choices = input.currentChoices.vector return nil if choices.size == 0 return choices[0] rescue return nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def the_choice\n key = eval_param(:selection)\n\n if key.nil?\n raise IndexError, \":selection returned nil value\"\n end\n\n obj = @choices[key]\n if obj.nil?\n # instantiate choice object\n choice_klass, choice_params = no_eval_param(:choices)[key]\n if choice...
[ "0.7187207", "0.67949307", "0.6759313", "0.6732765", "0.6212983", "0.6014036", "0.59450305", "0.58910143", "0.58910143", "0.58910143", "0.585239", "0.584267", "0.5803162", "0.5791573", "0.57759595", "0.5768508", "0.57673025", "0.57559323", "0.56810814", "0.5658392", "0.559250...
0.61856383
5
Return user answer for a multichoice question as a label (a, b, c, etc.)
def answerLabel(question) if question.input.is_a? org.concord.otrunk.ui.OTChoice return choiceLabel(question.input, currentChoice(question.input)) else return questionAnswer(question) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def answerLabel(question) \n if question.input.is_a? org.concord.otrunk.ui.OTChoice\n \treturn choiceLabel(question.input, question.input.currentChoice)\n else\n \treturn questionAnswer(question)\n end\nend", "def answer_humanized\n I18n.t(yes_no ? 'answer.yes' : 'answer.no')\n end", "def quiz_answer(...
[ "0.7392411", "0.7106858", "0.6932624", "0.6832072", "0.6832072", "0.6797069", "0.6797069", "0.6786185", "0.67309624", "0.6581796", "0.6561078", "0.6543467", "0.6503193", "0.6447206", "0.6398252", "0.6356411", "0.6338861", "0.6326042", "0.62931013", "0.6218933", "0.62185794", ...
0.7352631
1
Return correct answer for a multichoice question as a label (a, b, c, etc.)
def correctAnswerLabel(question) if question.input.is_a? org.concord.otrunk.ui.OTChoice return choiceLabel(question.input, question.correctAnswer) else return 'Not Available' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def answer_humanized\n I18n.t(yes_no ? 'answer.yes' : 'answer.no')\n end", "def quiz_answer(quiz)\n if quiz.answer_type == 'multi'\n show_multi_answer(quiz.answers.first.text, quiz.answer_input)\n elsif quiz.answer_type == 'check'\n show_check_answer(quiz.answers.first.text, quiz.answer_input...
[ "0.7038741", "0.7031977", "0.6972173", "0.69329816", "0.67941076", "0.67638254", "0.67638254", "0.6754297", "0.6748971", "0.67046297", "0.6693846", "0.65613735", "0.64929044", "0.6490465", "0.64834875", "0.63878727", "0.6318874", "0.62985134", "0.6270546", "0.62503684", "0.62...
0.7029022
3
this takes a userQuestion
def questionAnswer(question) answer = questionAnswerRaw(question) answer = "No Answer" if answer == nil return answer end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform(user, questions)\n \n end", "def ask_user_question\n return unless (@target = find_or_goto_index(User, params[:id].to_s)) &&\n can_email_user_question?(@target) &&\n request.method == \"POST\"\n\n subject = params[:email][:subject]\n content = params[:em...
[ "0.7570824", "0.6838483", "0.6787245", "0.6595339", "0.65614355", "0.6538316", "0.6514613", "0.64868265", "0.64731485", "0.6447961", "0.6407399", "0.6401191", "0.639009", "0.6383523", "0.6371648", "0.63682836", "0.6357837", "0.63572866", "0.6349412", "0.6343584", "0.6320792",...
0.58582485
78
this takes a userQuestion
def questionCorrect (question) return nil unless question.correctAnswer return nil if question.input.is_a? org.concord.otrunk.ui.OTText if question.input.is_a? org.concord.otrunk.ui.OTChoice choice = currentChoice(question.input) if choice == nil return nil else return question.correctAnswer == choice end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform(user, questions)\n \n end", "def ask_user_question\n return unless (@target = find_or_goto_index(User, params[:id].to_s)) &&\n can_email_user_question?(@target) &&\n request.method == \"POST\"\n\n subject = params[:email][:subject]\n content = params[:em...
[ "0.757121", "0.6838069", "0.6786995", "0.6596228", "0.6565419", "0.6541612", "0.6516993", "0.64892477", "0.6473733", "0.6449284", "0.64089966", "0.6402864", "0.6392628", "0.6383562", "0.6374366", "0.637062", "0.63594425", "0.6356993", "0.6349499", "0.6344734", "0.6321413", ...
0.5940935
62
this takes an authored question
def questionGradable (question) return true if question.input.is_a? org.concord.otrunk.ui.OTChoice and question.correctAnswer end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authored_questions\n Question.find_by_author_id(self.id)\n end", "def authored_questions\n Question.find_by_author_id(self.id)\n end", "def authored_questions\n Question.find_by_author_id(@id)\n end", "def author\n # data = QuestionsDatabase.instance.execute(\"SELECT fname, lname FROM ques...
[ "0.74455655", "0.74455655", "0.7443473", "0.651109", "0.64899296", "0.636976", "0.6358252", "0.6323257", "0.6248816", "0.61526436", "0.6095246", "0.60911196", "0.60581005", "0.6020249", "0.6006026", "0.5956279", "0.5943959", "0.5939847", "0.5898461", "0.58869004", "0.5884089"...
0.5560628
61
this takes a userQuestion
def questionAnswerHtml(question) correct = questionCorrect question text = questionAnswer question return '' if text == nil shortText = truncate text, 30 return text if correct == nil return "<font color=\"ff0000\">#{shortText}</font>" unless correct return "<font color=\"009900\">#{shortText}</font>" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform(user, questions)\n \n end", "def ask_user_question\n return unless (@target = find_or_goto_index(User, params[:id].to_s)) &&\n can_email_user_question?(@target) &&\n request.method == \"POST\"\n\n subject = params[:email][:subject]\n content = params[:em...
[ "0.757121", "0.6838069", "0.6786995", "0.6596228", "0.6565419", "0.6541612", "0.6516993", "0.64892477", "0.6473733", "0.6449284", "0.64089966", "0.6402864", "0.6392628", "0.6383562", "0.6374366", "0.637062", "0.63594425", "0.6356993", "0.6349499", "0.6344734", "0.6321413", ...
0.0
-1
Very quick way of getting back any question in this section that has a specific uuid
def sectionQuestionsForIds(section, otids) questions = [] return questions unless section.content.is_a? org.concord.otrunk.ui.OTCardContainer return sectionQuestions(section) if otids.empty? pageCards = allPages(section) pageCards.each do | doc | questions.concat documentQuestionsForIds(doc, otids) end questions end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def questions\n questions = Pairwise::Question.find(:all, :params => {:creator => @local_identifier})\n questions.select {|q| q if q.local_identifier == @local_identifier.to_s }\n end", "def find_question_by_id(question_id)\n question = Pairwise::Question.find question_id\n return question #if quest...
[ "0.59440583", "0.58771616", "0.58159006", "0.58159006", "0.5800138", "0.57479215", "0.570155", "0.56611145", "0.5658671", "0.5558048", "0.5544907", "0.5500879", "0.545824", "0.5428612", "0.54177094", "0.5329642", "0.53089994", "0.529271", "0.528911", "0.5282533", "0.5279438",...
0.5408706
15
takes an authored section
def relatedQuestions(section) relQuestions = [] questions = sectionQuestions(pretest()) questions.each do |question| question.getActivityReferences.getVector.each do |reference| if section.equals(reference.getReferencedObject) relQuestions << question break end end end relQuestions end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def section; end", "def initialize\n super\n @section = \"auth\"\n end", "def audit section\n\t\t\tsection\n\t\tend", "def sections(*args); end", "def show\n authorize Section\n end", "def load_section!\n if @extra_page\n @section = current_cookbook.sections.find @extra_page.sect...
[ "0.6541135", "0.62859654", "0.6037333", "0.6024204", "0.59813786", "0.5955112", "0.5871524", "0.5820877", "0.5805925", "0.57801515", "0.57700425", "0.57607466", "0.55835825", "0.55797565", "0.5542231", "0.5542231", "0.55419564", "0.55260044", "0.5494799", "0.5491141", "0.5482...
0.0
-1
rubocop:disable Metrics/MethodLength rubocop:disable AbcSize
def import_from_lms lms_name = current_organization.lti_configuration.lms_name(default_name: "your learning management system") all_students = lms_membership new_students = filter_new_students(all_students) if all_students.present? && new_students.empty? raise LtiImportError, "No students created. Your roster is already up to date with #{lms_name}." end @student_ids = new_students.map(&:user_id) @identifiers = { "User IDs": @student_ids, "Names": new_students.map(&:name), "Emails": new_students.map(&:email) }.select { |_, v| v.any? } respond_to do |format| format.js { render :import_from_lms, locals: { lms_name: lms_name } } format.html { render :import_from_lms, locals: { lms_name: lms_name } } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def implementation; end", "def implementation; end", "def private_method\n end", "def probers; end", "def schubert; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def refutal()\n end", "def used?; end", "def custom; end", "de...
[ "0.7520478", "0.613987", "0.613987", "0.6005437", "0.5936553", "0.5845366", "0.57771313", "0.57771313", "0.57771313", "0.57771313", "0.57769585", "0.57713467", "0.57055044", "0.57055044", "0.5694011", "0.5644352", "0.5637007", "0.5631899", "0.5631899", "0.5620816", "0.5612488...
0.0
-1
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize
def lms_membership unless current_organization.lti_configuration.supports_membership_service? lms_name = current_organization.lti_configuration.lms_name(default_name: "your learning management system") msg = "GitHub Classroom does not have access to your course roster on #{lms_name}. Please ensure that you've allowed GitHub Classroom to retrieve your course membership from #{lms_name} and try again." raise LtiImportError, msg end membership_service = GitHubClassroom::LTI::MembershipService.new( current_organization.lti_configuration.context_membership_url, current_organization.lti_configuration.consumer_key, current_organization.lti_configuration.shared_secret, lti_version: current_organization.lti_configuration.lti_version ) begin membership_service.students(body_params: current_organization.lti_configuration.context_membership_body_params) rescue Faraday::ClientError, JSON::ParserError => error report_error(error) lms_name = current_organization.lti_configuration.lms_name(default_name: "your learning management system") msg = "GitHub Classroom is unable to fetch membership from #{lms_name} at this time. If the problem persists, re-launch GitHub Classroom from your learning management system and try again." raise LtiImportError, msg end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def implementation; end", "def implementation; end", "def refutal()\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def schubert; end", "def offences_by; end", "def strategy; end", "def used?; end", "def custo...
[ "0.76538837", "0.62887454", "0.62282014", "0.62282014", "0.61805004", "0.6156519", "0.6156519", "0.6156519", "0.6156519", "0.612837", "0.59572196", "0.5944528", "0.5892693", "0.5819787", "0.5819787", "0.5808322", "0.5808322", "0.58052987", "0.5795088", "0.57326925", "0.568785...
0.0
-1
Manages the authentification process with the login page
def login # If the person is already logged in, redirected to the index redirect_to(:controller=>"neurons", :action=>"index") unless session[:user_id].nil? if request.post? user = User.authenticate(params[:name], params[:password]) if user session[:user_id]=user.id redirect_to(:controller=>"neurons", :action=>"index") else flash.now[:error] = "Wrong password" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loginpage\n end", "def authenticate_user\n \tif !logged_in?\n \tredirect_to login_url\n \tend\n end", "def login_page\n end", "def authenticate\n redirect_to login_path if !logged_in\n end", "def auth\n #redirect to login page unless already logged in\n redirect_to n...
[ "0.74692947", "0.7370912", "0.7351678", "0.72716516", "0.7243408", "0.72426105", "0.72404927", "0.7234613", "0.7234613", "0.7234613", "0.7234613", "0.7234613", "0.7234613", "0.7234613", "0.7234613", "0.7234613", "0.7211475", "0.7211475", "0.7209773", "0.71915334", "0.71268165...
0.0
-1
Manages the logout process
def logout session[:user_id]=nil redirect_to(:controller=>"neurons", :action=>"index") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exec_logout\n core_destroySession\n redirect_to lato_core.login_path\n end", "def logout\n if @logged_in\n cmd(\"exit\", true, true, @logout_token)\n handle_logout\n end\n end", "def logout\n end", "def logout\n end", "def handle_logout\n reset_sessi...
[ "0.7977114", "0.79634196", "0.7933469", "0.7933469", "0.7891681", "0.75510186", "0.7451748", "0.7413324", "0.7331114", "0.7331114", "0.7331114", "0.73238087", "0.7311147", "0.73052704", "0.7292156", "0.7273557", "0.7273362", "0.72684026", "0.7263066", "0.7243484", "0.7221657"...
0.0
-1
Go through the IMAP server and checks for new neurons to be added
def checkbrainmailbox #Check if token is present logger.info params["token"] if APP_CONFIG['token_action'].to_s == params["token"] #Start the actual work imap = Net::IMAP.new(APP_CONFIG['imap_host'], APP_CONFIG['imap_port'] , APP_CONFIG['imap_ssl'], nil, false) imap.authenticate('LOGIN', APP_CONFIG['imap_user'], APP_CONFIG['imap_password']) imap.select('INBOX') @output = "Connected to IMAP server\n" @n=0 #Select unseen messages only imap.search(["NOT", "SEEN"]).each do |message_id| #Get the full content raw = imap.fetch(message_id, "BODY[]")[0].attr["BODY[]"] imap.store(message_id, '+FLAGS', [:Seen]) #Parse it with mail library mail = Mail.read_from_string(raw) token = mail.to.to_s #If multipart or auth token not included, then discard the mail and send a warning if mail.multipart? or (not token.include?(APP_CONFIG['token_email'].to_s)) imap.copy(message_id, 'Untreated') @output=@output+Time.now.getutc.to_s+" - 1 untreated mail\n" send_warning_mail(mail.from, raw) else content = mail.body.decoded name = mail.subject date = mail.date #Detect if labels are specified in first line if content.lines.first.to_s[0]=="@" labels = content.lines.first.chomp content = content.lines.to_a[1..-1].join end #Here, create the neuron @output=@output+Time.now.getutc.to_s+" - 1 neuron created from a mail\n" puts "One neuron created with name '#{name}', labels '#{labels}' and content '#{content}'" neuron = Neuron.new neuron.name = name neuron.content = content neuron.labels = labels neuron.date = date neuron.save imap.copy(message_id, 'Treated') end imap.store(message_id, '+FLAGS', [:Deleted]) @n+=1 end imap.expunge #Delete all mails with deleted flags imap.close end render :layout => false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_new_noti\n Settings.Repos.each do |repo|\n notis = @git_client.repository_events(repo.url)\n next if notis.empty?\n\n puts \"New Notification in #{repo.display_name}\"\n\n notis.each do |noti|\n event = launcher.git_client.get(noti.subject.latest_comment_url)\n next u...
[ "0.5470487", "0.53915864", "0.5303326", "0.5292831", "0.52482986", "0.51993287", "0.5161401", "0.5074733", "0.5057677", "0.50561756", "0.50456345", "0.50015026", "0.49745363", "0.4970481", "0.49572054", "0.49408963", "0.4931937", "0.49265385", "0.49256727", "0.49048698", "0.4...
0.58153826
0
GET /corpora/1 GET /corpora/1.json
def show @corpus = Corpus.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @corpus } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @corps = Corp.all\n end", "def index\n @corps = Corp.all\n end", "def index\n @corporacions = Corporacion.all\n end", "def index\n @company_authorities = CompanyAuthority.all\n\n render json: @company_authorities\n end", "def show\n @corporation = Corporation.find(params[:...
[ "0.63682646", "0.63682646", "0.6187487", "0.6061551", "0.6040779", "0.5997402", "0.5980911", "0.59593886", "0.5917118", "0.58336353", "0.58187544", "0.5816938", "0.57974803", "0.57595223", "0.5748102", "0.5740932", "0.5708466", "0.5701271", "0.56954104", "0.5657736", "0.56491...
0.64728695
0
GET /corpora/new GET /corpora/new.json
def new @corpus = Corpus.new respond_to do |format| format.html # new.html.erb format.json { render json: @corpus } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @corporation = Corporation.new\n @page_header = \"Добавление новой Корпорации\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @corporation }\n end\n end", "def create\n @corp = Corp.new(corp_params)\n\n respond_to do |format|\n if...
[ "0.73843336", "0.6983767", "0.6911128", "0.69019794", "0.68982935", "0.6896339", "0.6708909", "0.67025316", "0.6695764", "0.6655364", "0.665283", "0.665283", "0.66286016", "0.66286016", "0.66286016", "0.66286016", "0.66286016", "0.66286016", "0.66286016", "0.66286016", "0.662...
0.72877485
1
POST /corpora POST /corpora.json
def create @corpus = Corpus.new(params[:corpus]) saved = @corpus.save @corpus.compile_histogram if saved respond_to do |format| if saved format.html { redirect_to @corpus, notice: 'Corpus was successfully created.' } format.json { render json: @corpus, status: :created, location: @corpus } else format.html { render action: "new" } format.json { render json: @corpus.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @corp = Corp.new(corp_params)\n\n respond_to do |format|\n if @corp.save\n format.html { redirect_to @corp, notice: 'Corp was successfully created.' }\n format.json { render :show, status: :created, location: @corp }\n else\n format.html { render :new }\n fo...
[ "0.6723431", "0.6649012", "0.6408352", "0.62415767", "0.56128615", "0.55641955", "0.55604833", "0.5519433", "0.55168724", "0.5501135", "0.5500149", "0.54928607", "0.5489781", "0.54794925", "0.54303825", "0.5417388", "0.54032296", "0.5364889", "0.5340375", "0.5317184", "0.5314...
0.5086623
53
PUT /corpora/1 PUT /corpora/1.json
def update @corpus = Corpus.find(params[:id]) saved = @corpus.update_attributes(params[:corpus]) @corpus.compile_histogram if saved respond_to do |format| if saved format.html { redirect_to @corpus, notice: 'Corpus was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @corpus.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @corp.update(corp_params)\n format.html { redirect_to @corp, notice: 'Corp was successfully updated.' }\n format.json { render :show, status: :ok, location: @corp }\n else\n format.html { render :edit }\n format.json { render json: @...
[ "0.6399539", "0.63623387", "0.62942165", "0.6107409", "0.58722734", "0.5830111", "0.582989", "0.582989", "0.57392794", "0.56721526", "0.5669468", "0.5648739", "0.561544", "0.5604487", "0.54899454", "0.54750633", "0.5458965", "0.5440439", "0.54351765", "0.5391658", "0.53785914...
0.0
-1
DELETE /corpora/1 DELETE /corpora/1.json
def destroy @corpus = Corpus.find(params[:id]) @corpus.destroy respond_to do |format| format.html { redirect_to corpora_url } format.json { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @corp.destroy\n respond_to do |format|\n format.html { redirect_to corps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @corporation = Corporation.find(params[:id])\n @corporation.destroy\n\n respond_to do |format|\n format.html { redirect_to...
[ "0.7190633", "0.70271176", "0.69689596", "0.69452494", "0.6680206", "0.66241443", "0.65317476", "0.64834005", "0.6455675", "0.6441667", "0.6404749", "0.6391204", "0.6389134", "0.6384927", "0.6384014", "0.6383476", "0.6383429", "0.6368701", "0.6366622", "0.63661397", "0.636000...
0.7091533
1
Calling this method clears stored ApiClient instance if configured previously.
def reset @client = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset\n self.api_key = nil\n self.endpoint = DEFAULT_ENDPOINT\n self.user_agent = DEFAULT_USER_AGENT\n self.platform_client_id = nil\n self.platform_client_secret = nil\n self\n end", "def reset_client\n @client = nil\n init_client\n end", "def clear_api_stubs\...
[ "0.72306323", "0.72285837", "0.71590143", "0.7011325", "0.700555", "0.7005509", "0.6999171", "0.6995187", "0.6895969", "0.6837422", "0.68132746", "0.67844105", "0.6760814", "0.6734568", "0.6644611", "0.6628414", "0.6571396", "0.6547588", "0.64256287", "0.6394077", "0.6376392"...
0.7210243
2
Use callbacks to share common setup or constraints between actions.
def set_note @note = Note.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.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.5...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def note_params params.require(:note).permit(:prospect_id, :body, :user_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Rotate the ZBlock clockwise. The result is the same as rotating right.
def rotateLeft() twoTypeRotate() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotate_clockwise2\n if !game_over? and @game.is_running?\n @current_block2.move(0, 0, 1)\n end\n draw\n end", "def zrotation\n end", "def apply_rotation\n if @rotation_block != nil\n (1..@rotation.modulo(@rotation_cycle)).each do |i|\n @blocks.each do |block...
[ "0.69366276", "0.68038344", "0.65870076", "0.65380335", "0.6492444", "0.64347607", "0.6287588", "0.6282795", "0.6270677", "0.6243805", "0.62425256", "0.62418115", "0.6232898", "0.61633134", "0.614589", "0.6134629", "0.6115925", "0.6093495", "0.6079993", "0.60793376", "0.60784...
0.6282089
8
Rotate the ZBlock counterclockwise. The result is the same as rotating left.
def rotateRight() twoTypeRotate() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotate_clockwise2\n if !game_over? and @game.is_running?\n @current_block2.move(0, 0, 1)\n end\n draw\n end", "def zrotation\n end", "def rotateLeft()\n fourTypeRotate(Tetromino::CLOCKWISE)\n end", "def rotate_back\n @falling_piece.current_rotation = (@falling_piece.current_rotatio...
[ "0.687528", "0.66887367", "0.643874", "0.6366196", "0.6301064", "0.6276315", "0.62619877", "0.6215848", "0.617772", "0.6172448", "0.6094118", "0.6065805", "0.606484", "0.6062793", "0.6026756", "0.59858954", "0.5919443", "0.5912306", "0.5870962", "0.58192784", "0.5790854", "...
0.58760905
18
param row is the row of the center block param col is the column of the center block return the Block array that represents the rotated Tetromino
def getRotatedBlocks(row, col) return [ Block.new(row, col), Block.new(row + 1, col), Block.new(row, col + 1), Block.new(row - 1, col + 1) ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getUnrotatedBlocks(row, col)\n return [\n Block.new(row, col),\n Block.new(row + 1, col),\n Block.new(row + 1, col + 1),\n Block.new(row, col - 1)\n ]\n end", "def getOrientation(row, col)\n case (@orientation_index)\n when 0\n return [\n Block.new(row, col),\n ...
[ "0.708242", "0.68828505", "0.63537157", "0.63379335", "0.6247654", "0.6221967", "0.61549836", "0.61509883", "0.61347663", "0.613227", "0.61099595", "0.60264665", "0.6019819", "0.59984267", "0.5970503", "0.5955721", "0.5879156", "0.58720636", "0.5844844", "0.58140105", "0.5813...
0.75202084
0
param row is the row of the center block param col is the column of the center block return the Block array that represents the unrotated Tetromino
def getUnrotatedBlocks(row, col) return [ Block.new(row, col), Block.new(row + 1, col), Block.new(row + 1, col + 1), Block.new(row, col - 1) ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getRotatedBlocks(row, col)\n return [\n Block.new(row, col),\n Block.new(row + 1, col),\n Block.new(row, col + 1),\n Block.new(row - 1, col + 1)\n ]\n end", "def getOrientation(row, col)\n case (@orientation_index)\n when 0\n return [\n Block.new(row, col),\n ...
[ "0.73055553", "0.66456926", "0.5919547", "0.5773488", "0.5728293", "0.5726664", "0.5687911", "0.5665346", "0.56508815", "0.560746", "0.56044793", "0.5598201", "0.55916965", "0.5584476", "0.5560859", "0.5537131", "0.5534976", "0.5510539", "0.5491537", "0.54808533", "0.54772776...
0.7448116
0
Called to remove the +fd+ from the poller and delete any callbacks
def deregister(fd:) delete_from_selector(fd: fd) delete_callbacks(fd: fd) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def callback_handler_remove\n rl_callback_handler_remove\n @rl_callback_handler = nil\n end", "def delete_from_selector(fd:)\n register(\n fd: fd,\n request: nil,\n filter: Constants::EVFILT_READ,\n flags: Constants::EV_DELETE\n )\n\n register...
[ "0.65609103", "0.65216446", "0.6316601", "0.61804414", "0.61397696", "0.60827285", "0.6033023", "0.5963925", "0.58836204", "0.5881828", "0.58782107", "0.5863964", "0.58273953", "0.5819471", "0.5809038", "0.5796241", "0.57951945", "0.5778471", "0.57656646", "0.57610416", "0.57...
0.75666076
0
Dispatches the registered reads and writes to +kevent+. We can queue up to MAX_EVENTS in the changelist before we flush to +kevent+.
def poll Logger.debug(klass: self.class, name: 'kqueue poller', message: 'calling kevent') t = shortest_timeout rc = Platforms.kevent(@kq_fd, @events[0], @change_count, @events[0], MAX_EVENTS, shortest_timeout) @change_count = 0 Logger.debug(klass: self.class, name: 'kqueue poller', message: "kevent returned [#{rc}] events!") if rc >= 0 rc.times { |index| process_event(event: @events[index]) } else Logger.debug(klass: self.class, name: 'kqueue poller', message: "rc [#{rc}], errno [#{::FFI.errno}]") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ev_do_handle_events(readers, writers); end", "def process\n read_events.each {|event| event.callback!}\n end", "def write_events(events)\n @events += @before_write.call(events)\n end", "def flush(events, key, teardown=false)\r\n @logger.info(\"Flush #{events.length} events\")\r...
[ "0.6561977", "0.55304205", "0.5446997", "0.53065664", "0.52335197", "0.52219695", "0.5180783", "0.5170972", "0.508685", "0.50741845", "0.5068227", "0.5001425", "0.4945976", "0.49425462", "0.49049908", "0.48897338", "0.48761457", "0.48318392", "0.48269066", "0.48257622", "0.47...
0.5295722
4
Due to the vagaries of the blocking +close+ function being called by the worker pool, the +fd+ might already be deleted from the kqueue. If it is already gone, then we'll get an EV_ERROR on the next poll. If it's not gone, this will clean it up.
def delete_from_selector(fd:) register( fd: fd, request: nil, filter: Constants::EVFILT_READ, flags: Constants::EV_DELETE ) register( fd: fd, request: nil, filter: Constants::EVFILT_WRITE, flags: Constants::EV_DELETE ) Logger.debug(klass: self.class, name: :delete_from_selector, message: "deleting, fd [#{fd}]") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close\n self << nil\n @worker.join\n @fd.close\n super\n end", "def deregister(fd:)\n delete_from_selector(fd: fd)\n delete_callbacks(fd: fd)\n end", "def close\n @queue_filler.exit\n @queue.close\n end", "def on_closed( fd, endpoint )\n\t\t\tself.lo...
[ "0.57048833", "0.5651322", "0.55560637", "0.5525912", "0.5514824", "0.54958653", "0.5449203", "0.5398703", "0.5365406", "0.5344374", "0.53017604", "0.53017604", "0.5253209", "0.52494097", "0.5246194", "0.52180856", "0.5212547", "0.520552", "0.51918364", "0.51790893", "0.51736...
0.5604567
2
Use callbacks to share common setup or constraints between actions.
def set_bait @bait = Bait.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a trusted parameter "white list" through.
def bait_params params.require(:bait).permit(:producer_id, :taste, :color, :size, :bait_type_id, :shape) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def task_params params.require(:task).permit(:taskname, :describe, :anticipated,:status) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69780594", "0.678054", "0.6742781", "0.67387927", "0.67346025", "0.6590683", "0.6501642", "0.6495788", "0.6479752", "0.64763314", "0.645457", "0.6437739", "0.6377168", "0.6372484", "0.6363871", "0.63179374", "0.62981373", "0.6297456", "0.62916917", "0.6290227", "0.628954",...
0.0
-1
TIA graphic circuits are triggered when the visible counter value changes, so graphics should provide this listener. The ball will also trigger it on strobe (and that is why it draws immediately and not on the next scanline)
def on_change(&block) @change_listener = block end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_timer\n @radius+=@increment\n @increment*=-1 if @radius==100 or @radius==0\n #on_draw # NOK : disk drawn. Same context\n queue_draw # OK : growing circle drawn). New context\n end", "def pbCaveEntranceEx(exiting)\n sprite = BitmapSprite.new(Graphics.width,Graphics.height)\n sprite.z = 10...
[ "0.60955524", "0.60911524", "0.5967972", "0.59663236", "0.587115", "0.5761479", "0.57556814", "0.57304394", "0.57074547", "0.5677049", "0.565157", "0.56316507", "0.5605973", "0.5600385", "0.55984205", "0.5589514", "0.5585004", "0.55659604", "0.555899", "0.5549364", "0.5531331...
0.0
-1
Horizontal movement (HMOV) is implemented by extending the horizontal blank by 8 pixels. That shortens the visible scanline to 152 pixels (producing the "comb effect" on the left side) and pushes all graphics 8 pixels to the right...
def start_hmove(register_value) @ticks_added = 0 @movement_required = !ticks_to_add(register_value).zero? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_horizontal_segment\n @pixel_y = @cmd_options[@cmd_options.length-2]-1\n @color = @cmd_options.last\n\n @pixel_xs = (@cmd_options[0]..@cmd_options[1]).to_a\n\n @pixel_xs.each do |pixel_x|\n pixel_x -=1\n @matrix[@pixel_y][pixel_x] = @color\n end\n end", "def move(io_h)\n if i...
[ "0.61005306", "0.6080258", "0.5933669", "0.5746067", "0.57108736", "0.54354054", "0.5416143", "0.53552884", "0.52652544", "0.5263821", "0.5244976", "0.5219164", "0.5219001", "0.5218539", "0.5208759", "0.5200733", "0.51483035", "0.5118261", "0.50863826", "0.5065763", "0.505369...
0.46478224
75
...but then TIA stuffs each counter with an extra cycle, counting those until it reaches the current value for the HMMxx register for that graphic). Each extra tick means pushing the graphic 1 pixel to the left, so the final movement ends up being something betwen 8 pixels to the right (0 extra ticks) and 7 pixels to the left (15 extra ticks)
def apply_hmove(register_value) return unless @movement_required tick @ticks_added += 1 @movement_required = false if @ticks_added == ticks_to_add(register_value) true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @counter == 30\n self.x += 1\n elsif @counter == 60\n self.x -= 1\n @counter = 0\n end\n @counter += 1\n end", "def update\n if @counter == 30\n self.x -= 1\n elsif @counter == 60\n self.x += 1\n ...
[ "0.63832134", "0.6260791", "0.6061653", "0.60531634", "0.60448706", "0.5650192", "0.5572508", "0.5552526", "0.5523257", "0.5508672", "0.55038345", "0.5471559", "0.54600865", "0.5440398", "0.5432989", "0.54197085", "0.53919274", "0.538324", "0.5362183", "0.53366387", "0.533548...
0.5294625
22
GET /inputs GET /inputs.json
def index @inputs = Input.all respond_to do |format| format.html # index.html.erb format.json { render json: @inputs } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_inputs\n HTTParty.get(self.class.url_to(\"#{ id }/inputs\"))\n end", "def inputs\n @inputs ||= JSON.parse(inputs_json || \"null\")\n end", "def index\n extras = ActiveModel::Type::Boolean.new.cast(params[:include_extras])\n\n render json: InputSerializer.collection(\n Inp...
[ "0.7268673", "0.71775204", "0.6979958", "0.6778529", "0.67656505", "0.67656505", "0.67656505", "0.6466062", "0.63928616", "0.61085516", "0.61053497", "0.60878766", "0.6046454", "0.6024347", "0.601983", "0.59806585", "0.597283", "0.5961404", "0.5907694", "0.58553725", "0.58506...
0.7307782
0
GET /inputs/1 GET /inputs/1.json
def show @input = Input.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @input } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @inputs = Input.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @inputs }\n end\n end", "def all_inputs\n HTTParty.get(self.class.url_to(\"#{ id }/inputs\"))\n end", "def index\n extras = ActiveModel::Type::Boolean.new.cast...
[ "0.70453656", "0.69100755", "0.66493607", "0.65699404", "0.6562362", "0.6562362", "0.6562362", "0.6157469", "0.6133018", "0.60546386", "0.5991548", "0.5850487", "0.5848651", "0.5839219", "0.5765283", "0.5745048", "0.57173324", "0.5716303", "0.5711918", "0.56907517", "0.564779...
0.6518454
7
GET /inputs/new GET /inputs/new.json
def new @input = Input.new respond_to do |format| format.html # new.html.erb format.json { render json: @input } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @input = Input.new params[:input]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @input }\n end\n end", "def new\n @mathematical_model_input = MathematicalModelInput.new\n\n respond_to do |format|\n format.html # new.html.erb\n ...
[ "0.69438607", "0.6797679", "0.66080827", "0.65670073", "0.6530532", "0.6480315", "0.6480315", "0.6480315", "0.6480315", "0.6480315", "0.64662695", "0.6349722", "0.6348676", "0.63486654", "0.6338843", "0.63232005", "0.6322248", "0.63023686", "0.63023686", "0.63023686", "0.6288...
0.7644047
0
POST /inputs POST /inputs.json
def create @input = Input.new(params[:input].merge!(:user => current_user)) respond_to do |format| if @input.save format.html { redirect_to @input, notice: 'Input was successfully created.' } format.json { render json: @input, status: :created, location: @input } else format.html { render action: "new" } format.json { render json: @input.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inputs\n @inputs ||= JSON.parse(inputs_json || \"null\")\n end", "def create(inputs)\n inputs = [inputs] unless inputs.is_a? Array\n inputs = inputs.map { |input| Clarinet::Utils.format_input(input) }\n\n data = @app.client.inputs_create inputs\n Clarinet::Inputs.new data[:inputs]\n ...
[ "0.67788553", "0.6366666", "0.6258508", "0.624256", "0.6162406", "0.61257297", "0.6009228", "0.59106934", "0.5878681", "0.582387", "0.5812539", "0.5811615", "0.5736345", "0.5736345", "0.5736345", "0.57257926", "0.57191235", "0.57181853", "0.5680219", "0.5671164", "0.5648778",...
0.612879
5
PUT /inputs/1 PUT /inputs/1.json
def update #@input = Input.find(params[:id]) respond_to do |format| if @input.update_attributes(params[:input]) format.html { redirect_to outputs_path, notice: 'Input was successfully updated.' } format.json { head :ok } format.js {@updates=params[:input].keys} else format.html { render action: "edit" } format.json { render json: @input.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update!(**args)\n @inputs = args[:inputs] if args.key?(:inputs)\n end", "def update!(**args)\n @inputs = args[:inputs] if args.key?(:inputs)\n end", "def update!(**args)\n @inputs = args[:inputs] if args.key?(:inputs)\n end", "def update!(**args)\n ...
[ "0.6532006", "0.6532006", "0.6532006", "0.6532006", "0.6532006", "0.6532006", "0.6532006", "0.64180773", "0.6386248", "0.6386248", "0.6386248", "0.6386248", "0.6386248", "0.6386248", "0.6386248", "0.6386248", "0.6386248", "0.6360259", "0.62434494", "0.62434494", "0.61894965",...
0.61458784
22
DELETE /inputs/1 DELETE /inputs/1.json
def destroy @input = Input.find(params[:id]) @input.destroy respond_to do |format| format.html { redirect_to inputs_url } format.json { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @input.destroy\n respond_to do |format|\n format.html { redirect_to inputs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @input = Input.find(params[:id])\n @input.destroy\n\n respond_to do |format|\n format.html { redirect_to(inputs_url) }\n...
[ "0.7309403", "0.70451075", "0.6997988", "0.6997988", "0.6997988", "0.6887394", "0.65374714", "0.652305", "0.65057194", "0.6461966", "0.6441626", "0.640747", "0.64021426", "0.63745564", "0.63741076", "0.6368931", "0.6332445", "0.6304461", "0.6283431", "0.6283336", "0.62789583"...
0.737331
0
Add an event to a user
def create event = Event.find_or_create_from_lastfm(params[:lastfm_id]) # Populate the event event.populate! user = User.get(params[:user_id]) if user.events.include?(event) # already been added to profile render 'api/v1/base/result.json', locals: {result: 'already added'} else user.events << event render 'api/v1/base/result.json', locals: {result: 'success'} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @event = Event.new(params[:event])\n @event.users << User.find(params['add_to_event']) if params['add_to_event']\n\n respond_to do |format|\n if @event.save\n flash[:notice] = 'Event was successfully created.'\n format.html { redirect_to event_url(@event) }\n format....
[ "0.76129097", "0.734235", "0.7337755", "0.72366375", "0.7190434", "0.71881074", "0.7020084", "0.7018246", "0.6991245", "0.68662024", "0.68223876", "0.67985475", "0.67985475", "0.67985475", "0.6786863", "0.67861366", "0.6772217", "0.6763255", "0.6753038", "0.6736272", "0.67151...
0.658527
28
Defining has_role? is optional when you use 'acts_as_authorized_user'. You can check roles against hardwired names before passing it off to default role checking.
def has_role?( role, authorized_object = nil ) return true if self.username.downcase == 'bill' and (role == 'bill' or role == 'site_admin') return true if self.username.downcase == 'nobody' and role == 'nobody' # Note that no 'conquerer' role is hardwired in, so it must be in role table & checked through mixin has_role? method. super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_role? (role_name)\n self.role ? self.role.name==(role_name.to_s) : false\n end", "def has_role? (role_name)\n self.role ? self.role.name==(role_name.to_s) : false\n end", "def has_role?\n Role.roles.include? role.try(:name)\n end", "def has_role?(role)\n role = role.name if role.is_a?(...
[ "0.84467274", "0.84467274", "0.8430303", "0.8408084", "0.8377634", "0.8377634", "0.8377634", "0.8377634", "0.8377634", "0.8377634", "0.83566695", "0.8331733", "0.82896286", "0.82669604", "0.82640827", "0.8255601", "0.82108706", "0.82065845", "0.820409", "0.8203593", "0.818656...
0.78983
48
Add more helper methods to be used by all tests here...
def sign_in post session_path, params: { password: TEST_PASSWORD } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_legacy_helpers\n assert_equal @patron.primary_phone, @patron.primary_address_phone\n assert_equal @patron.secondary_phone, @patron.secondary_address_phone\n assert_nil @patron.primary_address_mobile_phone\n assert_nil @patron.secondary_address_mobile_phone\n end", "def helpers; end", "def...
[ "0.7329752", "0.7017696", "0.7017696", "0.7017696", "0.6775608", "0.6682785", "0.6682785", "0.6585091", "0.65529233", "0.63792354", "0.6374989", "0.6330858", "0.62822473", "0.62822473", "0.62519825", "0.6144406", "0.6139013", "0.61233354", "0.6108507", "0.6098546", "0.6096015...
0.0
-1
Sends a GET request
def get(endpoint) respond_with( connection(endpoint).get(prepare(endpoint.uri), endpoint.req_params), endpoint ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_get(uri)\n _send_request('GET', uri, nil)\n end", "def get\n start { |connection| connection.request http :Get }\n end", "def get\n execute_request('GET') do |uri, headers|\n HTTP.http_client.get(\n uri,\n follow_redirect: true,\n header...
[ "0.81829524", "0.8084237", "0.79564637", "0.77929425", "0.76565224", "0.76565224", "0.76197904", "0.76102436", "0.76066047", "0.7593971", "0.75466543", "0.7500847", "0.7500051", "0.7500051", "0.7452378", "0.74191", "0.740295", "0.73861474", "0.7362048", "0.7355199", "0.731495...
0.0
-1
Sends a POST request
def post(endpoint) respond_with( connection(endpoint).post(prepare(endpoint.uri), custom_dump(endpoint.req_params)), endpoint ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_post_request url, body, headers = []\n make_request url, method: ::Rack::POST, body: body, headers: headers\n end", "def post(url, post_vars={})\n send_request url, post_vars, 'POST'\n end", "def post endpoint, data\n do_request :post, endpoint, data\n end", "def post url, bo...
[ "0.7851501", "0.7730397", "0.76628125", "0.7512887", "0.74998355", "0.7318232", "0.73098576", "0.72907484", "0.72470075", "0.7237079", "0.7203732", "0.71951294", "0.71795416", "0.7120137", "0.71174407", "0.7100258", "0.70864457", "0.7051167", "0.70475656", "0.7020375", "0.700...
0.0
-1
Sends a PUT request
def put(endpoint) respond_with( connection(endpoint).put(prepare(endpoint.uri), custom_dump(endpoint.req_params)), endpoint ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put(*args)\n request :put, *args\n end", "def put(*args)\n request(:put, *args)\n end", "def put!\n request! :put\n end", "def put_request(path, params={}, options={})\n request(:put, path, params, options)\n end", "def put endpoint, data\n do_request :put, endpoint, da...
[ "0.80587924", "0.7932907", "0.7888217", "0.77880675", "0.7733536", "0.7683917", "0.7644163", "0.7627574", "0.7619776", "0.7542595", "0.7499559", "0.74962664", "0.7458159", "0.741922", "0.7372634", "0.7372634", "0.73652524", "0.73574746", "0.7352663", "0.73510134", "0.7349245"...
0.0
-1
Sends a PATCH request
def patch(endpoint) respond_with( connection(endpoint).patch(prepare(endpoint.uri), endpoint.req_params.nil? ? nil : custom_dump(endpoint.req_params)), endpoint ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch!\n request! :patch\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def patch(path, data, params ...
[ "0.8003777", "0.7868311", "0.7821677", "0.77775997", "0.77775997", "0.7670369", "0.7572596", "0.7572596", "0.75657034", "0.75650114", "0.7384607", "0.7316691", "0.7296743", "0.7202912", "0.7184904", "0.7172116", "0.7098499", "0.7098499", "0.7058268", "0.69147074", "0.6902744"...
0.6231629
57
Sends a DELETE request
def delete(endpoint) respond_with( connection(endpoint).delete(prepare(endpoint.uri)) do |req| req.body = custom_dump endpoint.req_params end, endpoint ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n request(:delete)\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n ...
[ "0.8344563", "0.83107454", "0.82630295", "0.82630295", "0.82564485", "0.8207322", "0.8207322", "0.8139102", "0.80632055", "0.7991963", "0.7984373", "0.79601103", "0.79601103", "0.79601103", "0.79601103", "0.7862136", "0.78474045", "0.7792422", "0.77791333", "0.7746431", "0.77...
0.0
-1
Get rid of double slashes in the `path`, leading and trailing slash
def prepare(path) path.delete_prefix('/').gsub(%r{//}, '/').gsub(%r{/+\z}, '') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_leading_slash(path); end", "def clean_path(path)\n if path\n (path[0] != '/' ? path.insert(0, '/') : path).gsub(/\\/{2,}/, '/')\n end\n end", "def sanitize_path(path)\n # joining (e.g. `foo + \"/\" + bar`)\n path = path.gsub(/^\\/+/, '/')\n\n # remove leading and t...
[ "0.8629492", "0.8548553", "0.81154305", "0.80399317", "0.80322325", "0.80157554", "0.8015284", "0.80013114", "0.7859749", "0.77948296", "0.7724372", "0.770686", "0.770686", "0.758023", "0.75762486", "0.7570558", "0.75611496", "0.7433342", "0.74193263", "0.74038136", "0.738654...
0.75470245
17
Encode the Url ID
def shorten encode end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode_url\n return (id.to_s + (1+rand(8)).to_s).reverse.to_i.base62_encode\n end", "def to_param\n if url\n url.gsub(/[\\/\\ \\.]/,'-')+\"-\"+id.to_s\n end\n end", "def uri_encode(identifier)\n URI.escape(identifier)\n end", "def generate_short_url\n # encode base 10 id as base ...
[ "0.79344964", "0.75170255", "0.7393862", "0.70510894", "0.6922675", "0.6916669", "0.68846285", "0.6827305", "0.67881227", "0.6787826", "0.67488354", "0.67488354", "0.67488354", "0.67488354", "0.6731273", "0.6692057", "0.6607791", "0.66076684", "0.66035587", "0.6571247", "0.65...
0.0
-1
Generate new or return previously created shorten url
def generate_short_url(base_url) build_shorten_url.update( uniq_id: shorten, expired_at: Time.now.utc + 1.year ) unless shorten_url shorten_url.link(base_url) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_short_url\n url = ([*('a'..'z'),*('0'..'9')]).sample(UNIQUE_ID_LENGTH).join\n old_url = ShortenedUrl.where(short_url: url).last\n if old_url.present?\n self.generate_short_url\n else\n self.short_url = url\n end\n end", "def create_short_url\n rand_url = ('a'..'z').to_a....
[ "0.86129725", "0.84483624", "0.83582973", "0.8333842", "0.83287334", "0.83028793", "0.83028793", "0.82988054", "0.82732975", "0.8253497", "0.8250283", "0.82193786", "0.8135227", "0.811594", "0.8040161", "0.8031075", "0.7939915", "0.79004675", "0.78997546", "0.78308845", "0.77...
0.83603483
2
=> one Each UUID consists of 32 hexadecimal characters, and is typically broken into 5 sections like this 844412 and represented as a string. It looks like this: "f65c57f6a6aa17a8faa1a67f2dc9fa91" Write a method that returns one UUID when called with no parameters. UUID maker
def make_uuid hex_arr = (0..9).to_a + ('a'..'f').to_a hex_arr = hex_arr.map!(&:to_s) uuid = "" sections = [8, 4, 4, 4, 12] sections.each_with_index do |section, index| section.times { uuid += hex_arr.sample } uuid += '-' unless index >= sections.size - 1 end uuid end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_UUID_1\n uuid = ''\n hex_index = (0..15)\n hex_values = ('0'..'9').to_a + ('a'..'f').to_a\n\n (0..8).each do |num|\n uuid << hex_values[rand(hex_index)]\n end\n uuid << '-'\n (0..4).each do |num|\n uuid << hex_values[rand(hex_index)]\n end\n uuid << '-'\n (0..4).each do |num|\n uuid...
[ "0.80546385", "0.79484874", "0.77744967", "0.77582204", "0.7690825", "0.767431", "0.7659814", "0.7659814", "0.7659814", "0.76501226", "0.76463395", "0.76453835", "0.763973", "0.763021", "0.7628114", "0.7601022", "0.7598863", "0.7573362", "0.7561044", "0.75486696", "0.75311136...
0.7588728
17
The add button declares what association to add with dataassociation
def association a = element.dataset[:association] # send is spoopy, make sure the message you're sending is actually an association return unless safe?(session[:model], a) session[:model].send(a) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add\n association.build\n end", "def link_to_add_association(name, f, association)\n new_object = f.object.class.reflect_on_association(association).klass.new\n model_name = new_object.class.name.underscore\n hidden_div = content_tag('div', :id => \"#{model_name}_fields_template\", :style ...
[ "0.71722794", "0.6869801", "0.6703249", "0.6647621", "0.65141064", "0.64147264", "0.63760006", "0.63215375", "0.63215375", "0.61836016", "0.610845", "0.60934275", "0.6063254", "0.60600156", "0.6059809", "0.6052921", "0.60493803", "0.6032171", "0.59960526", "0.5969672", "0.596...
0.0
-1
We need to determine if we're `send`ing a safe message to the model We don't want someone to modify the name of an html element and send `destroy!` for example
def safe?(model, thing) safe = false safe ||= !model.association(thing).nil? if model.respond_to?('association') if model.respond_to? 'attributes' safe ||= model.attributes.keys.include?(thing) end safe end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_send?\n !sent?\n end", "def sent?\n sender_id.present?\n end", "def do_not_send?\n !self.do_not_send.blank?\n end", "def message?\n false\n end", "def sent?\n !@id.nil?\n end", "def send?\n type == 'send'\n end", "def unsent?\n !sent?\n end", ...
[ "0.65348905", "0.61535996", "0.6090694", "0.6059298", "0.60432506", "0.59335566", "0.58551705", "0.57645", "0.57636607", "0.57246715", "0.5723248", "0.56914556", "0.56423116", "0.56359446", "0.56112367", "0.55824304", "0.5533959", "0.5519825", "0.5508357", "0.5491256", "0.548...
0.0
-1
Creates a new, empty association.
def add association.build end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create!(params = {})\n association.build(model, params).tap(&:save!)\n end", "def create(params = {})\n association.build(model, params).tap(&:save)\n end", "def create_associations\n self.associates.each do |associate|\n self.add_associated(associate)\n end\n end", "d...
[ "0.71107394", "0.6739133", "0.6588295", "0.6250829", "0.6231789", "0.5998947", "0.58744216", "0.5861808", "0.5781509", "0.5706141", "0.56929463", "0.5678586", "0.5618211", "0.561358", "0.561098", "0.560959", "0.55853707", "0.55687124", "0.553955", "0.55039036", "0.55032355", ...
0.6208051
5
Removes an unsaved association. This for for the use case where the user has added a new association, hasn't saved the form yet, and wants to remove the unsaved association.
def delete association.delete association[element.dataset[:index].to_i] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_from(associated_model)\n self.send(associated_model.class.to_s.foreign_key + '=', nil)\n save(false)\n end", "def scaffold_remove_associated_object(association, object, associated_object)\n object.send(association).delete(associated_object)\n object.save\n end", "def remove_curre...
[ "0.627688", "0.6209247", "0.6110562", "0.6004137", "0.5907259", "0.58967227", "0.57949877", "0.57718706", "0.57285976", "0.56827986", "0.5677899", "0.5672478", "0.56572586", "0.56451243", "0.56201106", "0.5578278", "0.55737394", "0.5539355", "0.5497229", "0.5446147", "0.54321...
0.45480487
92
GET /magazines GET /magazines.json
def index @magazines = Magazine.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @magissues = Magissue.all\n @magazines = Magazine.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @magissues }\n end\n end", "def index\n@magazines = Magazine.all\nend", "def show\n @magzine = Magzine.find(params[:id])\n\n ...
[ "0.6659627", "0.6467082", "0.6440691", "0.6130968", "0.6038243", "0.59940106", "0.5991416", "0.59370166", "0.5842765", "0.5840806", "0.5819476", "0.5742363", "0.5730488", "0.5727327", "0.5703852", "0.5681324", "0.5646103", "0.562473", "0.56184125", "0.56181586", "0.5576871", ...
0.6554077
1
GET /magazines/1 GET /magazines/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @magzine = Magzine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @magzine }\n end\n end", "def index\n @magissues = Magissue.all\n @magazines = Magazine.all\n \n respond_to do |format|\n format.html # index....
[ "0.68931097", "0.6673018", "0.6458417", "0.637372", "0.6358383", "0.6147881", "0.61165965", "0.5976483", "0.5972259", "0.5942933", "0.58952826", "0.5893229", "0.587526", "0.58706826", "0.58524334", "0.58370847", "0.58222127", "0.5737753", "0.5733618", "0.5728133", "0.5717559"...
0.0
-1
POST /magazines POST /magazines.json
def create @magazine = Magazine.new(magazine_params) respond_to do |format| if @magazine.save format.html { redirect_to @magazine, notice: 'Magazine was successfully created.' } format.json { render :show, status: :created, location: @magazine } else format.html { render :new } format.json { render json: @magazine.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @magzine = current_user.magzines.new(magzine_params)\n\n respond_to do |format|\n if @magzine.save\n format.html { redirect_to @magzine, notice: 'Magzine was successfully created.' }\n format.json { render :show, status: :created, location: @magzine }\n else\n form...
[ "0.6200867", "0.6153493", "0.5941931", "0.5873281", "0.57471937", "0.56246096", "0.544311", "0.54365575", "0.5426452", "0.5360658", "0.5315113", "0.5312656", "0.5304427", "0.5271311", "0.52286786", "0.5188605", "0.51552254", "0.5142663", "0.51410836", "0.51359713", "0.5133956...
0.53982735
9
PATCH/PUT /magazines/1 PATCH/PUT /magazines/1.json
def update respond_to do |format| if @magazine.update(magazine_params) format.html { redirect_to @magazine, notice: 'Magazine was successfully updated.' } format.json { render :show, status: :ok, location: @magazine } else format.html { render :edit } format.json { render json: @magazine.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @magzine = Magzine.find(params[:id])\n\n respond_to do |format|\n if @magzine.update_attributes(params[:magzine])\n format.html { redirect_to @magzine, notice: 'Magzine was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"...
[ "0.66837287", "0.65013695", "0.6137677", "0.57351565", "0.570854", "0.57055277", "0.5682325", "0.5660725", "0.5646954", "0.56131244", "0.5563281", "0.555817", "0.55410165", "0.54903257", "0.5474648", "0.54671884", "0.5460009", "0.5437483", "0.5437483", "0.54296225", "0.542613...
0.5829063
3
DELETE /magazines/1 DELETE /magazines/1.json
def destroy @magazine.destroy respond_to do |format| format.html { redirect_to magazines_url, notice: 'Magazine was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @magzine = Magzine.find(params[:id])\n @magzine.destroy\n\n respond_to do |format|\n format.html { redirect_to magzines_url }\n format.json { head :ok }\n end\n end", "def destroy\n @magzine.destroy\n respond_to do |format|\n format.html { redirect_to magzines_url,...
[ "0.71318895", "0.6899682", "0.6721096", "0.6679029", "0.6631472", "0.6608482", "0.66027856", "0.65711033", "0.65708876", "0.6473994", "0.6455345", "0.63778275", "0.6347134", "0.6346322", "0.63309103", "0.63271767", "0.6321506", "0.63184947", "0.6316077", "0.62953544", "0.6295...
0.66725546
4
Use callbacks to share common setup or constraints between actions.
def set_magazine @magazine = Magazine.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 magazine_params params.fetch(:magazine, {}) 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.69780594", "0.678054", "0.6742781", "0.67387927", "0.67346025", "0.6590683", "0.6501642", "0.6495788", "0.6479752", "0.64763314", "0.645457", "0.6437739", "0.6377168", "0.6372484", "0.6363871", "0.63179374", "0.62981373", "0.6297456", "0.62916917", "0.6290227", "0.628954",...
0.0
-1
returns an array of numbers needed to calculate the factorial for a given number
def numbers_to_calculate_factorial(number) factorials = [number] number.times do if number > 1 # <-- ensures 0 is not pushed into the factorials array factorials << number - 1 number -= 1 end end factorials end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def factorial n\n arr = []\n while n >= 1\n arr.push n\n n -=1\n end\n arr.reduce(:*)\nend", "def factorial n\n\treturn (1..n).reduce(:*)\nend", "def factorial(n)\n # until ((n - 1) = 0)\n # do n - 1\n if n == 0\n return 1\n else\n fact_array = Array.new(n) {|f| f = f + 1}\n fact_array.inj...
[ "0.81138426", "0.7770233", "0.77066725", "0.77008164", "0.7647926", "0.76333183", "0.76022875", "0.7587209", "0.7568949", "0.75637376", "0.7553988", "0.7553575", "0.7518669", "0.7494432", "0.746128", "0.74447817", "0.7431704", "0.7416647", "0.73908263", "0.73858714", "0.73680...
0.796926
1
calculates factorials for an array of different numbers
def factorial_non_recursion(numbers) numbers.each do |number| result = 1 # <-- reset result to 1 so factorial results from other numbers aren't combined together numbers_to_calculate = numbers_to_calculate_factorial(number) numbers_to_calculate.each {|number| result *= number} puts "The factorial of the the number #{number} is #{result}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def factorial(number)\n ary = []\n if number < 0\n p \"Provide a positive number.\"\n elsif number == 0\n p 1\n elsif number == 1\n p 1\n elsif\n number_plus1 = number + 1\n while number_plus1 > 1 do\n number_plus1 -= 1\n ary.push(number_plus1)\n end\n # ary.each {|x| number_plu...
[ "0.76873255", "0.7678501", "0.7629309", "0.7547835", "0.7523187", "0.74928224", "0.7465559", "0.74325", "0.74229294", "0.7421967", "0.74174947", "0.74110615", "0.7410952", "0.7366034", "0.7343874", "0.728668", "0.7275145", "0.72725654", "0.7266284", "0.7266284", "0.72626555",...
0.0
-1
calculates factorial for any given number
def factorial(number) if number == 1 # <-- BASE CASE: scenario that tells recusion when to stop return 1 else number * factorial(number - 1) # <-- RULE: determines when recursion should continue end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def factorial(number)\r\ntotal = 1\t\r\n\twhile number != 0\r\n\t\ttotal *= number\r\n\t\tnumber = number -1\r\n\tend\r\n\ttotal\r\nend", "def factorial(number)\n if number == 0\n \treturn 1\n elsif number == 1\n \treturn 1\n end\n i=number-1\n f=number*i\n while i > 1\n \ti=i-1\n \tf=f*i\n end\n ret...
[ "0.8482512", "0.8465158", "0.84626865", "0.84597206", "0.84498376", "0.8423633", "0.84152454", "0.8404408", "0.8401257", "0.8401257", "0.840002", "0.8389782", "0.8388112", "0.8388112", "0.8381772", "0.83783036", "0.83719885", "0.8371007", "0.8367598", "0.8366692", "0.836544",...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_shmfunding @shmfunding = Shmfunding.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.61637366", "0.60446453", "0.59452957", "0.591511", "0.58885515", "0.5834122", "0.57761765", "0.5702554", "0.5702554", "0.5652102", "0.5619581", "0.5423898", "0.5409782", "0.5409782", "0.5409782", "0.5394745", "0.53780794", "0.5356209", "0.5338898", "0.53381324", "0.5328622...
0.0
-1
Only allow a trusted parameter "white list" through.
def shmfunding_params params.require(:shmfunding).permit(:userID, :merchantID, :fundingType, :email, :phoneNumber, :accountNumber, :routingNumber, :fundingDate) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.71230334", "0.70530915", "0.69479465", "0.6902122", "0.67367256", "0.67172784", "0.6689043", "0.66784793", "0.6660117", "0.6555213", "0.6528485", "0.6458438", "0.6452378", "0.6451654", "0.64478326", "0.6433326", "0.6413599", "0.6413599", "0.63907677", "0.63787645", "0.6378...
0.0
-1